Skip to content

feat(server): emit usage chunk on streaming completion when include_usage=true - #184

Merged
penta2himajin merged 1 commit into
mainfrom
mavis/issue181-stream-usage
Oct 6, 2026
Merged

penta2himajin merged 1 commit into
mainfrom
mavis/issue181-stream-usage

Conversation

@penta2himajin

Copy link
Copy Markdown
Owner

Closes #181

Streaming SSE now honors stream_options.include_usage by sending a final usage-only chunk (empty choices) before [DONE], per the OpenAI Chat Completions spec. Without this, streaming clients (e.g. Hermes agent) recorded output_tokens=0 for all streaming calls.

Verification:

  • COMPTEST 112/112 (new stream_options_roundtrip guard)
  • FAKE-backend wire test: usage chunk present with flag, absent without

…sage=true

Fixes #181: streaming SSE now honors stream_options.include_usage by
sending a final usage-only chunk (empty choices) before [DONE], matching
the OpenAI Chat Completions spec. Non-streaming path already returned
usage; streaming clients previously saw output_tokens=0.

COMPTEST stream_options_roundtrip guards the request decoding.

Co-Authored-By: mavis
@penta2himajin
penta2himajin merged commit 05e745b into main Oct 6, 2026
1 check passed
@penta2himajin
penta2himajin deleted the mavis/issue181-stream-usage branch October 6, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streaming responses missing usage field (stream_options.include_usage=true has no effect)

1 participant