docs: refresh the corpus; pin the streaming usage chunk that stopped existing - #25
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_usageadded one more chunk beforedata: [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
choicesnow 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
usagefrom 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.TestStreamTakesUsageFromTheLastContentChunkpins 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:
Corpus
Repacked from the mirror at
thevibeworks/deepseek-docs@2e1187d. 75 pages,enminusdsh, as before;create-chat-completion.mdandcreate-completion.mdnow carry the new wording indocs ask.make check: All checks passed.