Skip to content

Propagate DeepSeek SSE token usage to /v1/responses and remove stale POW env docs#234

Merged
CJackHwang merged 4 commits intodevfrom
codex/fix-documentation-and-accumulated_token_usage
Apr 7, 2026
Merged

Propagate DeepSeek SSE token usage to /v1/responses and remove stale POW env docs#234
CJackHwang merged 4 commits intodevfrom
codex/fix-documentation-and-accumulated_token_usage

Conversation

@CJackHwang
Copy link
Copy Markdown
Owner

Motivation

  • Fix an observed gap where DeepSeek SSE snapshots (e.g. accumulated_token_usage / token_usage) were not consistently reflected in OpenAI-compatible /v1/responses usage fields.
  • Address a PR review note about stale documentation that advertised an unimplemented DS2API_POW_CONCURRENCY env var.

Description

  • Propagate upstream prompt/output usage into responses: added promptTokens tracking to responsesStreamRuntime, capture PromptTokens/OutputTokens from parsed SSE lines and apply them to the final usage object (recomputing total_tokens).
  • Non-stream responses now apply upstream token_usage.prompt_tokens as input_tokens and apply output_tokens overrides when present, and always recompute total_tokens from the final values.
  • Added regression tests in Go (internal/adapter/openai/stream_status_test.go) and Node (tests/node/chat-stream.test.js) to cover response BATCH snapshots with accumulated_token_usage and token_usage cases, and updated a prompt-build test to match current tool-call instruction wording.
  • Removed the outdated DS2API_POW_CONCURRENCY entries from README.MD and README.en.md.

Testing

  • Ran go test ./internal/adapter/openai -count=1 and it passed (ok).
  • Ran the Node parser tests with node --test tests/node/chat-stream.test.js and they passed (ok).
  • Ran the full unit suite via ./tests/scripts/run-unit-all.sh and it completed successfully (ok).
  • Ran lint via ./scripts/lint.sh, which bootstrapped golangci-lint and reported 0 issues.

Codex Task

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ds2api Ready Ready Preview, Comment Apr 7, 2026 2:59am

@CJackHwang CJackHwang marked this pull request as ready for review April 7, 2026 02:17
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 668b9c26bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/translatorcliproxy/stream_writer.go
@CJackHwang CJackHwang merged commit 9813188 into dev Apr 7, 2026
3 checks passed
@CJackHwang CJackHwang deleted the codex/fix-documentation-and-accumulated_token_usage branch April 7, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant