Skip to content

fix(llm): treat early stream close as a drop in codex and codeassist; no Map-index panic - #496

Merged
mrnasil merged 2 commits into
mainfrom
fix/llm-stream-eof-and-map-index
Nov 25, 2026
Merged

mrnasil merged 2 commits into
mainfrom
fix/llm-stream-eof-and-map-index

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 25, 2026

Copy link
Copy Markdown
Member

Early EOF. codex and codeassist treated a stream that closed before its finish event (response.completed, or a finishReason) as a complete answer. A reply cut short was kept, and a function call still in flight was dropped silently; codex only emits a call on output_item.done. Both now raise the retryable unexpected EOF error that the anthropic and chat-completions parsers already raise (#393). Code Assist still accepts a stream that has a finishReason but no usage chunk.

Panic. anthropic indexed a serde_json::Map for usage and stop_reason. Map indexing panics on a missing key, and this ran inside stream polling. An Anthropic-compatible proxy that omits those keys now reads as zero usage and no stop reason. Indexing goes through Value, as in the rest of the parser.

Tests:

  • codex complete without response.completed errors, and with it assembles the text and the tool call;
  • codeassist: a stream without a finish errors, and a finish without usage still ends cleanly;
  • anthropic: message_start without usage and an empty delta parse without panicking.

Three lines that were uncovered on main in these files are now covered.

🤖 Generated with Claude Code

… no Map-index panic

- codex and codeassist took a stream that closed before its finish
  (`response.completed` / a `finishReason`) as a whole answer: a reply
  cut short was kept, and a function call still in flight (codex only
  emits it on `output_item.done`) was dropped without a word. Both now
  raise the retryable "unexpected EOF" the anthropic and chat parsers
  already raise. Code Assist still accepts a finishReason without the
  usage chunk.
- anthropic indexed a serde_json::Map for `usage` and `stop_reason`,
  which panics on a missing key, inside stream polling. A proxy that
  leaves them out now reads as zero / no stop reason.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mrnasil
mrnasil merged commit bca3769 into main Nov 25, 2026
7 checks passed
@mrnasil
mrnasil deleted the fix/llm-stream-eof-and-map-index branch November 25, 2026 22:37
@mrnasil mrnasil mentioned this pull request Nov 26, 2026
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