Skip to content

fix: assemble Anthropic streamed tool_use blocks before replay - #6683

Closed
LHMQ878 wants to merge 1 commit into
1Panel-dev:v2from
LHMQ878:fix/anthropic-tool-use-streaming
Closed

LHMQ878 wants to merge 1 commit into
1Panel-dev:v2from
LHMQ878:fix/anthropic-tool-use-streaming

Conversation

@LHMQ878

@LHMQ878 LHMQ878 commented Aug 14, 2026

Copy link
Copy Markdown

Summary

  • Anthropic streams tool arguments as input_json_delta events. MaxKB was replaying those raw deltas on the next turn, which Anthropic rejects with Input tag 'input_json_delta' does not match any of the expected tags (and empty text blocks with text content blocks must be non-empty).
  • Assemble completed tool_use.input from streamed fragments, drop input_json_delta / empty text blocks, and treat stop_reason=tool_use as a finish chunk.
  • Adds regression tests that do not require an Anthropic account.

Fixes #6480

Test plan

  • python -m unittest apps.application.flow.tests.test_anthropic_tool_content -v
  • SIMPLE agent + custom tool + Anthropic model, stream: true: tool call completes and the follow-up turn is not a 400

Made with Cursor

Co-authored-by: Cursor <cursoragent@cursor.com>
@liuruibin

Copy link
Copy Markdown
Member

no plan

@liuruibin liuruibin closed this Sep 2, 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

2 participants