fix(llm): force non-stream for Anthropic thinking+tool rounds - #25
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(llm): force non-stream for Anthropic thinking+tool rounds#25cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a critical multi-turn tool loop failure for Kimi Code / K3 providers (
protocol: anthropic,thinking.type: enabled, defaultstream: true).Bug and impact
AnthropicCompatProvider._make_stream_request()returnsreasoning_contentbut notanthropic_message_content(thinking blocks + signatures). OpenAI-compat already forces non-stream for thinking+tools; Anthropic-compat did not.kimi_code,kimi_code_fast, orkimi_k3with tools enabled andllm.stream: true(default). First tool round streams; second round rebuilds history without original thinking signatures.Fix
_thinking_mode_tool_rounds_need_nonstream()toAnthropicCompatProvider.chat_with_tools, force non-stream when thinking is enabled and tools are present (mirrorsOpenAICompatProvider).Validation
tests/test_anthropic_compat.py(2 new tests + full file: 14 passed)