-
Notifications
You must be signed in to change notification settings - Fork 703
fix anthropic streaming tool index increment #1284
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
base: main
Are you sure you want to change the base?
Conversation
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.
Good fix for tool index initialization, but the increment logic could be more explicit and consistent.
685e4e5
to
0169749
Compare
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
0169749
to
ba7e393
Compare
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
Co-authored-by: lucgagan <[email protected]>
ba7e393
to
7cb9360
Compare
DescriptionSummary By MatterAI
🔄 What ChangedThis pull request addresses an issue where the 🔍 Impact of the ChangeThis ensures accurate and consistent indexing of tool calls during streaming, preventing off-by-one errors and improving the reliability of applications that process multiple tool calls from these streaming APIs. 📁 Total Files Changed
🧪 Test AddedN/A 🔒Security VulnerabilitiesN/A MotivationThis change is needed to correctly handle the Type of Change
How Has This Been Tested?
Screenshots (if applicable)N/A Checklist
Related Issuescloses #1275 Tip Quality Recommendations
Tanka Poem ♫
Sequence DiagramsequenceDiagram
participant T as StreamTransformer
participant RC as ResponseChunk
participant PC as ParsedChunk
participant SS as StreamState
RC->>T: processChunk(responseChunk, streamState)
Note over T: AnthropicChatCompleteStreamChunkTransform / VertexAnthropicChatCompleteStreamChunkTransform
alt streamState.toolIndex is undefined
T->>SS: streamState.toolIndex = -1
end
T->>PC: parseChunk(responseChunk)
Note over T: Check for 'content_block_start' and 'tool_use'
alt isToolBlockStart (parsedChunk.type === 'content_block_start' && parsedChunk.content_block?.type === 'tool_use')
T->>SS: streamState.toolIndex = streamState.toolIndex + 1
end
T-->>RC: transformedChunk
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
closes #1275
For multiple tool calls, the tool index was not getting updated