Skip to content

Conversation

@koxudaxi
Copy link
Collaborator

@koxudaxi koxudaxi commented Oct 28, 2025

TL;DR

Added support for parallel tool calls in streaming responses by tracking tool calls by ID.

What changed?

  • Added an id field to ToolCallChunk and ToolCallEndChunk classes to uniquely identify tool calls
  • Modified the stream response handler to track tool calls by ID in a dictionary (_current_tool_calls_by_id)
  • Updated the tool call handling logic to support processing multiple tool calls in parallel
  • Updated error messages to be more specific about which tool call ID is causing issues
  • Updated all test cases to include the required ID field in tool call chunks

How to test?

  • Run the existing test suite to verify that all tool call functionality works correctly
  • Test scenarios with multiple concurrent tool calls to ensure they are properly tracked and processed
  • Verify error handling by testing with unknown tool call IDs

Why make this change?

This change enables proper handling of parallel tool calls in streaming responses. By tracking tool calls by their unique IDs rather than using a single _current_content reference, the system can now process multiple tool calls simultaneously without losing track of their state. This is particularly important for complex interactions where multiple tools might be called in parallel by the LLM.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 28, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
v2-docs baa82ae Oct 29 2025, 02:38 PM

@koxudaxi koxudaxi changed the base branch from MIR-293 to graphite-base/1468 October 28, 2025 08:00
@koxudaxi koxudaxi force-pushed the 10-28-support_concurrent_tool_call_streaming_with_id-based_tracking branch from 3ba3761 to 7c91809 Compare October 28, 2025 08:00
@koxudaxi koxudaxi changed the base branch from graphite-base/1468 to 10-24-add_unittest_for_mirrored_provider_clients_anthropicvertex_ October 28, 2025 08:00
@koxudaxi koxudaxi marked this pull request as ready for review October 28, 2025 08:07
@koxudaxi koxudaxi requested a review from willbakst as a code owner October 28, 2025 08:07
@koxudaxi koxudaxi force-pushed the 10-28-support_concurrent_tool_call_streaming_with_id-based_tracking branch from 7c91809 to f0426a6 Compare October 28, 2025 08:18
@koxudaxi koxudaxi changed the base branch from 10-24-add_unittest_for_mirrored_provider_clients_anthropicvertex_ to graphite-base/1468 October 28, 2025 12:21
@koxudaxi koxudaxi force-pushed the 10-28-support_concurrent_tool_call_streaming_with_id-based_tracking branch from f0426a6 to baa82ae Compare October 29, 2025 14:36
@koxudaxi koxudaxi changed the base branch from graphite-base/1468 to 10-24-add_unittest_for_mirrored_provider_clients_anthropicvertex_ October 29, 2025 14:36
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.

2 participants