-
Notifications
You must be signed in to change notification settings - Fork 187
fix: streaming tool-call argument loss in NativeToolCallParser (#695) #700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
awschmeder
wants to merge
12
commits into
Zoo-Code-Org:main
Choose a base branch
from
awschmeder:fix/695-toolcall-dropped-leading-deltas
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+456
−108
Open
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
95439a0
fix: streaming tool-call argument loss in NativeToolCallParser (#695)
awschmeder d911e98
chore: remove agent-generated changeset file per policy
awschmeder a01a838
test: add direct coverage for finalizeRawChunks() in NativeToolCallPa…
awschmeder fba6c71
fix: address PR #700 review feedback for tool-call streaming reassembly
awschmeder f2396b9
fix: handle provider-emitted tool_call_end chunks during streaming
awschmeder 8252abc
test: cover Task.finalizeStreamingToolCallById streaming finalization
awschmeder 08a8c8e
merge: sync upstream/main into fix/695-toolcall-dropped-leading-deltas
awschmeder 5e062ea
Merge branch 'main' into fix/695-toolcall-dropped-leading-deltas
awschmeder bd58c33
test(assistant-message): tighten duplicate end handling assertions
awschmeder 160fd3b
Merge branch 'main' into fix/695-toolcall-dropped-leading-deltas
awschmeder 38126df
Merge branch 'fix/695-toolcall-dropped-leading-deltas' of github.com:…
awschmeder 5bf4bbe
test(NativeToolCallParser): tighten assertion for duplicate end events
awschmeder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "zoo-code": patch | ||
| --- | ||
|
|
||
| Fix streaming tool-call arguments being dropped when argument deltas arrive before the tool-call id, which caused spurious "missing required parameter" errors (affects LiteLLM, OpenAI-compatible, and DeepSeek providers). |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| ### Related GitHub Issue | ||
|
|
||
| Closes: #695 | ||
|
|
||
| ### Description | ||
|
|
||
| When a provider streams a tool call whose first delta(s) arrive *before* the tool-call `id` is known, those leading argument bytes are silently discarded by `NativeToolCallParser.processRawChunk`. This causes downstream "missing required parameter" errors even when the model supplied the data. | ||
|
|
||
| This PR fixes the issue by centralizing the tracking of streaming tool calls in `NativeToolCallParser`. The `rawChunkTracker` is now initialized on the first sight of a stream `index`, independent of whether an `id` is present. All `arguments` deltas are buffered until both `id` and `name` are known, ensuring no data loss during streaming reassembly. | ||
|
|
||
| ### Test Procedure | ||
|
|
||
| 1. Ran the newly added unit test in `src/core/assistant-message/__tests__/NativeToolCallParser.spec.ts` which verifies that leading argument bytes arriving before the `id` are correctly preserved and finalized. | ||
| 2. Verified that existing provider tests in the same test file pass. | ||
|
|
||
| ### Pre-Submission Checklist | ||
|
|
||
| - [x] **Issue Linked**: This PR is linked to an approved GitHub Issue. | ||
| - [x] **Scope**: My changes are focused on the linked issue (one major feature/fix per PR). | ||
| - [x] **Self-Review**: I have performed a thorough self-review of my code. | ||
| - [x] **Testing**: New and/or updated tests have been added to cover my changes. | ||
| - [x] **Documentation Impact**: I have considered if my changes require documentation updates. | ||
| - [x] **Contribution Guidelines**: I have read and agree to the [Contributor Guidelines](/CONTRIBUTING.md). | ||
|
|
||
| ### Screenshots / Videos | ||
|
|
||
| N/A | ||
|
|
||
| ### Documentation Updates | ||
|
|
||
| - [x] No documentation updates are required. | ||
|
|
||
| ### Additional Notes | ||
|
|
||
| N/A | ||
|
|
||
| ### Get in Touch | ||
|
|
||
| @awschmeder |
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.