Skip to content

docs: refresh the corpus; pin the streaming usage chunk that stopped existing - #25

Merged
lroolle merged 1 commit into
mainfrom
usage-wire-0828
Aug 28, 2026
Merged

docs: refresh the corpus; pin the streaming usage chunk that stopped existing#25
lroolle merged 1 commit into
mainfrom
usage-wire-0828

Conversation

@lroolle

@lroolle lroolle commented Aug 28, 2026

Copy link
Copy Markdown
Member

DeepSeek changed the documented streaming wire shape on 2026-08-27, in both Chat Completions and the FIM beta, with no changelog entry.

Beforestream_options.include_usage added one more chunk before data: [DONE]:

{"choices":[],"usage":{"prompt_tokens":11,"completion_tokens":2}}

Now — no separate usage chunk is emitted. The statistics ride on the last content chunk:

{"choices":[{"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":11,"completion_tokens":2}}

A parser that recognised the usage chunk by its empty choices now finds usage on no chunk at all and prices the call at zero. Nothing errors. The bill just disappears — the worst failure this tool has, because the number at the bottom is the whole point of it.

What was and wasn't broken

Our assembler already takes usage from whatever chunk carries it (internal/deepseek/chat.go), so nothing was broken. Nothing tested it either — no test in this repo has ever streamed a usage-bearing chunk, so the one line standing between us and a silent zero was unguarded.

TestStreamTakesUsageFromTheLastContentChunk pins the shape the docs describe rather than the shape we happened to be written against.

The test was checked for teeth rather than assumed to have them. Narrowing the assembler to the old rule, written the obvious way:

if chunk.Usage != nil && len(chunk.Choices) == 0 {
--- FAIL: TestStreamTakesUsageFromTheLastContentChunk
    client_test.go:219: no usage assembled: a streamed call that reports no tokens cannot be priced

Corpus

Repacked from the mirror at thevibeworks/deepseek-docs@2e1187d. 75 pages, en minus dsh, as before; create-chat-completion.md and create-completion.md now carry the new wording in docs ask.

make check: All checks passed.

…existing

DeepSeek changed the documented streaming wire shape on 2026-08-27, in
both Chat Completions and the FIM beta, with no changelog entry.

Before: `stream_options.include_usage` added ONE MORE chunk before
`data: [DONE]` — `usage` populated, `choices` an empty array.

Now: no separate usage chunk is emitted at all. The token statistics
ride on the last CONTENT chunk, which carries exactly one choice with
no new text and a non-null `finish_reason`.

A parser that recognised the usage chunk by its empty `choices` now
finds no usage on any chunk and prices the call at zero. Nothing
errors. The bill simply disappears — which is the worst failure this
tool has, because the whole point of it is the number at the bottom.

Our assembler already takes `usage` from whatever chunk carries it, so
nothing was broken. Nothing tested it either: no test in this repo has
ever streamed a usage-bearing chunk, so the one line standing between
us and a silent zero was unguarded. Now it is pinned, against the
shape the docs describe rather than the shape we happened to be
written against.

The test was checked for teeth rather than assumed to have them:
narrowing the assembler to `chunk.Usage != nil && len(chunk.Choices)
== 0` — the old rule, written the obvious way — makes it fail with
"no usage assembled".

Corpus repacked from the mirror at thevibeworks/deepseek-docs@2e1187d.
75 pages, en minus dsh, as before; `create-chat-completion.md` and
`create-completion.md` now carry the new wording in `docs ask`.

make check: All checks passed.
@lroolle
lroolle merged commit ff82c38 into main Aug 28, 2026
8 checks passed
@lroolle
lroolle deleted the usage-wire-0828 branch August 28, 2026 08:01
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.

1 participant