Repository navigation
fix(core): route id-less continuation chunks to a colliding tool-call opener's slot #6981
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
Changes from 1 commit
d02834c
62bce69
001a710
ef62d64
6b62711
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,8 +110,14 @@ export class StreamingToolCallParser { | |
| if (this.idToIndexMap.has(id)) { | ||
| // We've seen this ID before, use the existing mapped index | ||
| actualIndex = this.idToIndexMap.get(id)!; | ||
| } else if (this.pendingIndexRemaps.has(index)) { | ||
| // Some providers stream name or arguments before the stable ID. | ||
| } else if ( | ||
| this.pendingIndexRemaps.has(index) && | ||
| !this.toolCallMeta.get(this.pendingIndexRemaps.get(index)!)?.id | ||
| ) { | ||
| // Some providers stream name or arguments before the stable ID. Only | ||
| // adopt the remapped slot while it has not yet been claimed by an id: | ||
| // once it has one, the remap only exists to route later id-less | ||
| // continuation chunks, so a brand-new id must not hijack that slot. | ||
| actualIndex = this.pendingIndexRemaps.get(index)!; | ||
| this.pendingIndexRemaps.delete(index); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed — removed in ef62d64. You're right that the common-path re-registration re-creates the mapping on the adoption path ( |
||
| this.idToIndexMap.set(id, actualIndex); | ||
|
|
@@ -206,7 +212,7 @@ export class StreamingToolCallParser { | |
| } else { | ||
| this.namelessToolCallIndices.delete(actualIndex); | ||
| } | ||
| if (!meta.id && actualIndex !== index) { | ||
| if (actualIndex !== index) { | ||
| this.pendingIndexRemaps.set(index, actualIndex); | ||
| } | ||
| return { actualIndex, complete: false }; | ||
|
|
@@ -236,7 +242,7 @@ export class StreamingToolCallParser { | |
| meta.name = validName; | ||
| } | ||
| } | ||
| if (!meta.id && actualIndex !== index) { | ||
| if (actualIndex !== index) { | ||
| this.pendingIndexRemaps.set(index, actualIndex); | ||
| } | ||
|
Comment on lines
249
to
254
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks — I looked at this closely and verified it empirically, and I'm going to keep the unconditional overwrite. The suggested guard ( I added a regression test for exactly the well-formed three-call case (6b62711): |
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The added guard's block direction is covered by the third test,
does not let a brand-new tool-call id adopt a remap slot that already has an id: aftercall_2claims the 0->1 remap with its own id, a third call reusing index 0 with a fresh id assertsthird.actualIndex !== 1, which fails if the!toolCallMeta.get(remap)?.idguard is removed. This first test intentionally covers the record path; the third covers the adopt-guard path.