Problem
The Interactions streaming converter currently attaches arguments_delta and step.stop events to state.parts[-1] instead of the function-call step identified by event.index. When multiple function-call steps are interleaved, deltas for an earlier step are appended to the most recently started call, which can swap or merge function names and arguments in the final response.
Reproduction
Start two function-call steps at indexes 0 and 1, then send arguments_delta events for index 0 and index 1 before sending step.stop for both. The current converter routes both deltas through the last function call rather than the matching step.
Proposed fix
Track function-call parts by step index and use that mapping for arguments_delta and step.stop, while retaining the existing last-part fallback for events without an index.
Verification
A focused regression covering two interleaved calls passes with the proposed change, and the full Interactions utility test file passes 143 tests on current main.
Would maintainers like this fix submitted as a pull request?
Problem
The Interactions streaming converter currently attaches arguments_delta and step.stop events to state.parts[-1] instead of the function-call step identified by event.index. When multiple function-call steps are interleaved, deltas for an earlier step are appended to the most recently started call, which can swap or merge function names and arguments in the final response.
Reproduction
Start two function-call steps at indexes 0 and 1, then send arguments_delta events for index 0 and index 1 before sending step.stop for both. The current converter routes both deltas through the last function call rather than the matching step.
Proposed fix
Track function-call parts by step index and use that mapping for arguments_delta and step.stop, while retaining the existing last-part fallback for events without an index.
Verification
A focused regression covering two interleaved calls passes with the proposed change, and the full Interactions utility test file passes 143 tests on current main.
Would maintainers like this fix submitted as a pull request?