Skip to content

fix(agent): recover tools after stream parse errors#6136

Open
usr-bin-roygbiv wants to merge 1 commit into
can1357:mainfrom
usr-bin-roygbiv:fix/openai-responses-midstream-parse-retry
Open

fix(agent): recover tools after stream parse errors#6136
usr-bin-roygbiv wants to merge 1 commit into
can1357:mainfrom
usr-bin-roygbiv:fix/openai-responses-midstream-parse-retry

Conversation

@usr-bin-roygbiv

Copy link
Copy Markdown

What

  • recover completed registered tool calls after explicit transient stream JSON parse failures
  • drop incomplete calls and keep unknown, refused, sensitive, and non-stream error turns non-executable
  • classify persisted parser diagnostics narrowly without weakening provider-context Error classification

Why

OpenAI Responses can complete a tool call and then emit a malformed non-trailing SSE event. OMP 17.0.5 surfaced JSON Parse error: Unterminated string, but the agent loop only recovered completed calls for stream_read_error, so the completed tool never executed. The same failure shape was observed independently on macOS and Linux sessions.

Testing

  • bun test packages/agent/test/agent-loop.test.ts packages/agent/test/agent.test.ts packages/ai/test/error-aierr.test.ts packages/ai/test/anthropic-retry.test.ts — 125 pass
  • bun check — pass
  • bun run ci:test:smoke — pass
  • deterministic source-CLI smoke in cmux on macOS — completed read, malformed middle SSE JSON frame, recovered tool result, continued to OMP_MIDSTREAM_FINAL_LOCAL_OK
  • deterministic source-CLI smoke in native tmux on Linux — same sequence, continued to OMP_MIDSTREAM_FINAL_REMOTE_OK

  • bun check passes
  • Tested locally
  • CHANGELOG updated (if user-facing)

@github-actions github-actions Bot added the vouched Passed the vouch gate label Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouched Passed the vouch gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant