Skip to content

fix(llm): force non-stream for Anthropic thinking+tool rounds - #25

Draft
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/critical-bug-management-b8c3
Draft

fix(llm): force non-stream for Anthropic thinking+tool rounds#25
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/critical-bug-management-b8c3

Conversation

@cursor

@cursor cursor Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a critical multi-turn tool loop failure for Kimi Code / K3 providers (protocol: anthropic, thinking.type: enabled, default stream: true).

Bug and impact

  • Impact: After the first streamed tool-call round, the second LLM request could fail (400) or lose preserved thinking context, breaking agent tool loops for default Kimi Anthropic providers.
  • Root cause: AnthropicCompatProvider._make_stream_request() returns reasoning_content but not anthropic_message_content (thinking blocks + signatures). OpenAI-compat already forces non-stream for thinking+tools; Anthropic-compat did not.
  • Trigger: Use kimi_code, kimi_code_fast, or kimi_k3 with tools enabled and llm.stream: true (default). First tool round streams; second round rebuilds history without original thinking signatures.

Fix

  • Add _thinking_mode_tool_rounds_need_nonstream() to AnthropicCompatProvider.
  • In chat_with_tools, force non-stream when thinking is enabled and tools are present (mirrors OpenAICompatProvider).

Validation

  • tests/test_anthropic_compat.py (2 new tests + full file: 14 passed)
Open in Web View Automation 

Stream path drops anthropic_message_content (thinking signatures), breaking
multi-turn tool loops on Kimi Code/K3 with default stream=true.

Co-authored-by: Yuxuan Liu <Osc-7@users.noreply.github.com>
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