Skip to content

fix(proxy): fall back to buffered deltas when Read tool done event carries empty arguments - #6481

Merged
farion1231 merged 2 commits into
farion1231:mainfrom
ashel-wang:fix/read-tool-empty-done-arguments
Nov 29, 2026
Merged

farion1231 merged 2 commits into
farion1231:mainfrom
ashel-wang:fix/read-tool-empty-done-arguments

Conversation

@ashel-wang

Copy link
Copy Markdown
Contributor

Summary / 概述

The streaming Responses bridge buffers function_call_arguments.delta chunks for tools named Read (for pages sanitization) and emits them at the done event. Some OpenAI-Responses-compatible gateways (e.g. recent claude-code-router builds) send response.function_call_arguments.done with an empty-string arguments field while the complete arguments only exist in the deltas and the later output_item.done item.

The done handler only fell back to the buffered chunks when the arguments field was missing — not when present-but-empty. Result: every Read tool_use reached the Anthropic client with empty input, permanently breaking the tool on that route (tools with other names stream through unaffected).

Fix: treat empty-string arguments on the done event as absent (one-line .filter), 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.

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):

Probe Result before Result after
CC Switch 15721 → openai_responses → CCR, Read tool call tool_use input: {} parameters intact
Same route, other tool names unaffected unaffected
apiFormat=anthropic pass-through working working
cd src-tauri && cargo test --lib streaming_responses
# 22 passed; 0 failed (includes new regression test)

Screenshots / 截图

N/A (protocol-level fix, covered by unit test)

Checklist / 检查清单

  • cargo clippy --lib -- -D warnings passes / 通过 Clippy 检查
  • Rust unit tests pass (cargo test --lib streaming_responses — 22/22) / 单测通过
  • pnpm typecheck / pnpm format:check — no TS/frontend change / 未改动前端代码

…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.
@ashel-wang
ashel-wang requested a review from farion1231 as a code owner August 15, 2026 13:54
@github-actions github-actions Bot added backend Backend (Rust/Tauri) proxy Related to proxy/API forwarding labels Aug 15, 2026
@farion1231

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 724a586e51

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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 farion1231 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T04:17:43.092447Z cc66769 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@farion1231

Copy link
Copy Markdown
Owner

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 on_function_call_arguments_done, with your regression test moved into the split-out streaming_responses/tests.rs. An empty arguments on the done event now falls back to the buffered deltas, so Read keeps its input on those gateways. Merged — it will ship in the next release.

@farion1231
farion1231 merged commit de730a6 into farion1231:main Nov 29, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend (Rust/Tauri) proxy Related to proxy/API forwarding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants