test: SSE coverage for empty and chunked tool arguments - #166
Merged
Conversation
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
Open
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #162. Four tests on the layer that shipped a bug.
Anthropic: the missing sibling
malformed_tool_arguments_fail_the_turn_instead_of_defaultingwas already pinned. The empty-argument case was not — and that asymmetry is exactly how the bug escaped: a zero-parameter tool streamsinput_json_deltacarrying"",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:
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:
{"__partial_json": ...}runs on its defaults instead of what the model asked for"{}and warns — so the tool does run on its defaultsThat'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
arguments split across chunks must reassemblecargo test --all-features: 633 passed, 0 failed. Clippy clean under-Dwarnings.Tests only — no library change.
🤖 Generated with Claude Code