Skip to content

fix(channels): prevent tool_calls from being dropped during streaming#2957

Open
loafoe wants to merge 1 commit into
sipeed:mainfrom
loafoe:fix/tool-calls-filtering
Open

fix(channels): prevent tool_calls from being dropped during streaming#2957
loafoe wants to merge 1 commit into
sipeed:mainfrom
loafoe:fix/tool-calls-filtering

Conversation

@loafoe
Copy link
Copy Markdown
Contributor

@loafoe loafoe commented May 27, 2026

Summary

  • Fix tool_calls messages being incorrectly filtered as auxiliary messages during streaming
  • Add outboundMessageIsToolCalls() helper function
  • Exclude tool_calls from auxiliary message filtering in preSend()

Problem

The auxiliary message filtering introduced in #2892 incorrectly drops tool_calls messages when:

  1. There is an active stream for the chat
  2. There is a tombstone from a recently finished stream (30-second window)

This causes tool_calls to not be delivered to the pico channel UI when users make consecutive requests, as the second request's tool_calls message arrives while the first request's stream is still active or within the tombstone window.

Root Cause

outboundMessageHasAuxiliaryKind() returns true for any message with message_kind set, which includes tool_calls. The filtering logic in preSend() then drops these messages to prevent stale feedback/thoughts from leaking after streaming.

However, tool_calls messages represent new tool invocations for the current turn - they are not stale auxiliary content and must be delivered to the UI.

Fix

Exclude tool_calls from auxiliary message filtering:

isToolCalls := outboundMessageIsToolCalls(msg)
if isAuxiliaryMessage && !isToolCalls {
    // filtering logic
}

Test plan

  • Send consecutive tool-invoking requests via pico channel
  • Verify all tool_calls messages are delivered to the UI
  • Verify stale feedback/thoughts are still correctly filtered

🤖 Generated with Claude Code

The auxiliary message filtering introduced in sipeed#2892 incorrectly drops
tool_calls messages when there is an active stream or a tombstone from
a recently finished stream.

This causes tool_calls to not be delivered to the UI when users make
consecutive requests, as the second request's tool_calls message arrives
while the first request's stream is still active or within the 30-second
tombstone window.

The fix excludes tool_calls from auxiliary message filtering, since they
represent new tool invocations that must be delivered to the UI, not
stale auxiliary content like feedback or thoughts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@loafoe
Copy link
Copy Markdown
Contributor Author

loafoe commented May 27, 2026

@imguoguo please check this one, it fixes a bug in the recently merged streaming which causes tool call messages to be dropped silently!

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.

1 participant