[GH-ISSUE #2865] [Bug]: chat/completions stream ignores stream_options.include_usage (usage stays on the finish_reason chunk) #1157

Closed
opened 2026-11-04 01:48:58 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Eranicus30666 on GitHub (Oct 17, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2865

What happened

OpenAI's streaming contract: with "stream_options": {"include_usage": true}, the last chunk before [DONE] has "choices": [] and carries usage; the other chunks carry no usage. /v1/chat/completions ignores stream_options and always puts usage on the same chunk as finish_reason.

In my setup (LiteLLM in front of Strata), LiteLLM does not read the usage from that chunk and recounts the tokens itself, lower than the engine's count. A client that uses this number to decide when to compact its context then compacts too late.

Expected: with include_usage: true, the usage in its own last chunk with "choices": []; unchanged without the option. A PR with a fix follows.

Related: #2278 adds the legacy /v1/completions endpoint and says its final chunk already carries the usage; this issue is only about /v1/chat/completions.

Strata version, GPU, OS

0.1.45 · 2x NVIDIA A2 16GB (sm_86) · Debian 13, CUDA 13.4

Originally created by @Eranicus30666 on GitHub (Oct 17, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/2865 ### What happened OpenAI's streaming contract: with `"stream_options": {"include_usage": true}`, the last chunk before `[DONE]` has `"choices": []` and carries `usage`; the other chunks carry no usage. `/v1/chat/completions` ignores `stream_options` and always puts `usage` on the same chunk as `finish_reason`. In my setup (LiteLLM in front of Strata), LiteLLM does not read the usage from that chunk and recounts the tokens itself, lower than the engine's count. A client that uses this number to decide when to compact its context then compacts too late. Expected: with `include_usage: true`, the usage in its own last chunk with `"choices": []`; unchanged without the option. A PR with a fix follows. Related: #2278 adds the legacy /v1/completions endpoint and says its final chunk already carries the usage; this issue is only about /v1/chat/completions. ### Strata version, GPU, OS 0.1.45 · 2x NVIDIA A2 16GB (sm_86) · Debian 13, CUDA 13.4
Author
Owner

@Niko1221 commented on GitHub (Oct 19, 2026):

Thanks for taking the time to report this.

We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6271323932 --> @Niko1221 commented on GitHub (Oct 19, 2026): Thanks for taking the time to report this. We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1157
No description provided.