Skip to content

fix(strands): scope TOOL_CALL_START suppression to matching pending tool IDs#1371

Closed
giulio-leone wants to merge 3 commits intoag-ui-protocol:mainfrom
giulio-leone:fix/tool-call-start-suppression
Closed

fix(strands): scope TOOL_CALL_START suppression to matching pending tool IDs#1371
giulio-leone wants to merge 3 commits intoag-ui-protocol:mainfrom
giulio-leone:fix/tool-call-start-suppression

Conversation

@giulio-leone
Copy link
Copy Markdown
Contributor

Summary

Fixes #1275

TOOL_CALL_START events were incorrectly suppressed for all tool calls in a turn when the conversation history ended with a tool-role message. This broke progress indicators and real-time UI updates for multi-tool HITL workflows.

Root Cause

has_pending_tool_result was a single boolean — once set to True, it suppressed START events for every subsequent tool call in the turn, not just the one whose result was already in history.

Fix

Replace the boolean with pending_tool_result_ids: set[str] — a set of specific tool_call_ids collected from the trailing tool-role messages. Only tool calls whose ID matches a pending result are suppressed; new tool calls correctly emit TOOL_CALL_START.

Algorithm:

  • Walk input_data.messages from the end, collecting tool_call_ids while role == 'tool'
  • Stop at the first non-tool message (so stale tool results earlier in history are ignored)
  • At emit time: is_pending = tool_use_id in pending_tool_result_ids

Tests

  • Added 5 regression tests covering: trailing collection, non-trailing ignored, new call not suppressed, pending call suppressed, empty messages
  • All 15 tests pass (10 existing + 5 new)

⚠️ This reopens #1299 which was accidentally closed due to fork deletion.

giulio-leone and others added 3 commits March 21, 2026 21:16
…ool IDs

Previously, has_pending_tool_result was a boolean flag set when the last
message in conversation history had role='tool'. This caused ALL
subsequent tool calls in the same turn to have their TOOL_CALL_START
events suppressed, breaking progress indicators for multi-tool HITL
workflows.

Replace the boolean with a set of specific tool_call_ids from trailing
tool-role messages (pending_tool_result_ids). Only tool calls whose IDs
match a pending result are suppressed; new tool calls in the same turn
correctly emit TOOL_CALL_START events.

Fixes ag-ui-protocol#1275
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@giulio-leone giulio-leone requested a review from a team as a code owner March 25, 2026 19:21
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 25, 2026

@giulio-leone is attempting to deploy a commit to the CopilotKit Team on Vercel.

A member of the Team first needs to authorize it.

@ranst91
Copy link
Copy Markdown
Contributor

ranst91 commented Apr 1, 2026

Hey @giulio-leone

First and foremost, thanks for the contribution. This is a fix for an active issue brought up several times, so very valuable!
Due to conflict issues, I have incorporated this into a different fix branch, set to be available in a few minutes, therefore, I will not merge this specific PR.

Thanks against for the contribution that has also set the path to the other PR

@ranst91 ranst91 closed this Apr 1, 2026
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.

[Bug]: TOOL_CALL_START events suppressed for entire turn after tool result

2 participants