Skip to content

test: SSE coverage for empty and chunked tool arguments - #166

Merged
yuanhao merged 1 commit into
mainfrom
test/162-sse-tool-call-coverage
Aug 25, 2026
Merged

test: SSE coverage for empty and chunked tool arguments#166
yuanhao merged 1 commit into
mainfrom
test/162-sse-tool-call-coverage

Conversation

@yuanhao

@yuanhao yuanhao commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Closes #162. Four tests on the layer that shipped a bug.

Anthropic: the missing sibling

malformed_tool_arguments_fail_the_turn_instead_of_defaulting was already pinned. The empty-argument case was not — and that asymmetry is exactly how the bug escaped: a zero-parameter tool streams input_json_delta carrying "", from_str("") fails with "EOF while parsing a value", and empty got treated as malformed.

Reverting the 0.18.1 fix reproduces the production error byte-for-byte:

tool call(s) with unusable arguments, not executed: `list_files` ()

0.18.1 unit-tested resolve_tool_arguments, but that's the pure decision. This drives an empty stream through the actual parser.

openai_compat: 3 tests, none touching tool calls

For a module backing OpenAI, Groq, Together, DeepSeek, Fireworks, Mistral, xAI. Added three: arguments reassembling across chunks, a zero-argument call, and truncated arguments.

A provider divergence, documented rather than fixed

The truncated-arguments test found something worth knowing:

on unparseable tool arguments
Anthropic fails the turn — "a tool handed {"__partial_json": ...} runs on its defaults instead of what the model asked for"
openai_compat falls back to {} and warns — so the tool does run on its defaults

That's the exact hazard Anthropic's path guards against, happening by default on 15+ providers.

I pinned it rather than changed it. Closing the gap is a behavioural decision with a wide blast radius, not a test fix — and it should be made deliberately, not as a side effect of adding coverage. If that assertion ever changes, it will be on purpose.

Verification

mutation result
revert the 0.18.1 empty-args fix reproduces the production error exactly
take only the first argument chunk arguments split across chunks must reassemble
make the parse fallback fail catches the divergence test

cargo test --all-features: 633 passed, 0 failed. Clippy clean under -Dwarnings.

Tests only — no library change.

🤖 Generated with Claude Code

Four tests on the layer that shipped a bug.

Anthropic: a zero-argument tool call. Its sibling —
malformed_tool_arguments_fail_the_turn_instead_of_defaulting — was
already pinned, and that asymmetry is exactly how the bug got out: a tool
with no parameters streams input_json_delta carrying "", from_str("")
fails with "EOF while parsing a value", and empty was treated as
malformed. Reverting the 0.18.1 fix reproduces the production error
byte-for-byte: "tool call(s) with unusable arguments, not executed:
`list_files` ()".

openai_compat had three tests and none touched tool calls, for a module
backing 15+ providers. Added: arguments reassembling across chunks, a
zero-argument call, and truncated arguments.

That last one documents a provider divergence rather than fixing it.
Anthropic fails the turn on unparseable arguments and says why — "a tool
handed {"__partial_json": ...} runs on its defaults instead of what the
model asked for". openai_compat does the opposite: falls back to {} and
warns, so the tool does run on its defaults. Pinned, because closing that
gap is a behavioural decision across 15+ providers, not a test fix. If
the assertion ever changes, it should be on purpose.

Each mutation-verified: dropping chunk accumulation fails the reassembly
test, and making the parse fallback fail catches the divergence test.

633 passed, clippy clean under -Dwarnings.

Closes #162
@yuanhao
yuanhao merged commit f939842 into main Aug 25, 2026
8 checks passed
@yuanhao
yuanhao deleted the test/162-sse-tool-call-coverage branch August 25, 2026 21:31
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.

SSE coverage is uneven: empty tool arguments untested, and openai_compat has 3 tests to Anthropic's 23

1 participant