Repository navigation
fix(proxy): fall back to buffered deltas when Read tool done event carries empty arguments - #6481
Conversation
…rries empty arguments Some OpenAI-Responses-compatible gateways (e.g. recent claude-code-router builds) emit response.function_call_arguments.done with an empty-string arguments field while the complete arguments only appear in the deltas and the later output_item.done item. The streaming bridge buffers delta chunks for tools named Read (for pages sanitization) and planned to emit them at the done event, but the done handler only fell back to the buffered chunks when the arguments field was missing - not when it was present but empty. The empty string survived sanitization, the non-empty guard suppressed the delta, and the block was closed, so every Read tool_use reached Claude Code with empty input. Treat an empty-string arguments on the done event as absent, mirroring the existing output_item.done handler which already filters empty strings. Added a regression test reproducing the exact event sequence captured from such a gateway.
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
farion1231
left a comment
There was a problem hiding this comment.
LGTM, thanks for your contribution!
Resolve the conflict with main's refactored Responses-to-Anthropic stream converter: apply the empty-arguments fallback in on_function_call_arguments_done, and move the regression test into the split-out streaming_responses/tests.rs.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Thanks @ashel-wang for the fix and the captured event sequence, and sorry for the long wait! The stream converter had been refactored on main, so I merged main into your branch and applied the same one-line fallback in |
Summary / 概述
The streaming Responses bridge buffers
function_call_arguments.deltachunks for tools namedRead(forpagessanitization) and emits them at thedoneevent. Some OpenAI-Responses-compatible gateways (e.g. recent claude-code-router builds) sendresponse.function_call_arguments.donewith an empty-stringargumentsfield while the complete arguments only exist in the deltas and the lateroutput_item.doneitem.The
donehandler only fell back to the buffered chunks when theargumentsfield was missing — not when present-but-empty. Result: everyReadtool_use reached the Anthropic client with emptyinput, permanently breaking the tool on that route (tools with other names stream through unaffected).Fix: treat empty-string
argumentson the done event as absent (one-line.filter), mirroring the existingoutput_item.donehandler which already filters empty strings. Added a regression test reproducing the exact event sequence captured from such a gateway.Related Issue / 关联 Issue
Related (same bridge, different symptom): #6473
Steps to verify / 验证方式
Captured from a live claude-code-router container (podman,
/v1/responses, GLM-5.3):Readtool callinput: {}apiFormat=anthropicpass-throughScreenshots / 截图
N/A (protocol-level fix, covered by unit test)
Checklist / 检查清单
cargo clippy --lib -- -D warningspasses / 通过 Clippy 检查cargo test --lib streaming_responses— 22/22) / 单测通过pnpm typecheck/pnpm format:check— no TS/frontend change / 未改动前端代码