test(e2e): cover streaming usage chunk passthrough across providers
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 157
- Forks
- 32
- Avg merge
- 1h 25m
- Merged PRs (30d)
- 145
Description
Background
Surfaced from #148 audit (M2). The cross-provider matrix non-stream test asserts `completion.usage.total_tokens` round-trips, but the streaming variant has no `usage` assertion — the test's mock SSE chunks don't include a `usage:` field.
Gap
OpenAI's streaming wire supports `stream_options: {include_usage: true}` which appends a final chunk like:
```
data: {"choices":[],"usage":{"prompt_tokens":N,"completion_tokens":M,"total_tokens":K}}
```
Today the matrix tests don't exercise that path, so a regression where the gateway:
- drops the final usage-only chunk
- mistranslates `usage` field names across providers
- forwards usage on the wrong chunk
would not be caught.
Proposed coverage
Add a streaming case (per provider) that:
- Caller passes `stream_options: { include_usage: true }`
- Mock upstream emits the final usage-bearing chunk
- Test asserts the SDK surfaces `chunk.usage` on the matching chunk
References:
- OpenAI Chat Completions streaming usage: https://platform.openai.com/docs/api-reference/chat/streaming
- Existing matrix file: `tests/e2e/src/cases/cross-provider-matrix-e2e.test.ts`
Priority
P2 — feature-coverage gap, not a regression. Track alongside other matrix-tightening tasks.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in tests/e2e/src/cases/cross-provider-matrix-e2e.test.ts and compare the existing non-stream usage assertion with the streaming cases and mock SSE chunks. Add the per-provider stream_options case with a final usage-bearing chunk, then verify that chunk.usage is surfaced on the matching chunk for every provider.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, testing-qa
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100