Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(vibey): scope Anthropic thinking fallback to Claude (#2928)
Call Whitef92922a4fc44
diff --git a/core/agent_core/ai/anthropic.py b/core/agent_core/ai/anthropic.pyindex 47c8a1c44..97a903e1a 100644--- a/core/agent_core/ai/anthropic.py+++ b/core/agent_core/ai/anthropic.py@@ -17,7 +17,7 @@ from typing import Anyimport httpx-from core.agent_core.ai.claude_thinking import uses_adaptive_thinking+from core.agent_core.ai.claude_thinking import is_claude_model, uses_adaptive_thinkingfrom core.agent_core.ai.hosted import anthropic_hosted_block, citation, reported_countsfrom core.agent_core.ai.image_limits import LoadedImagefrom core.agent_core.ai._common import (@@ -1045,15 +1045,16 @@ def build_messages_payload(payload["tools"] = toolseffort = (request.reasoning_effort or "").lower()adaptive = uses_adaptive_thinking(request.endpoint.model_id)- if effort in {"none", "off", "disabled"} or (- effort and not adaptive and _continues_unthought_tool_loop(payload_messages)- ):- # Under manual thinking, Anthropic requires the assistant message a tool loop continues to start with its- # thinking block. One whose thinking cannot go back (another origin's, or a Session whose signatures the- # provider refused) continues with thinking off, as Anthropic's refusal itself advises; the models that take- # manual thinking all accept that. Adaptive thinking has no such rule, and several adaptive models refuse- # ``disabled``, so it stays on.+ if effort in {"none", "off", "disabled"}:payload["thinking"] = {"type": "disabled"}+ elif effort and not adaptive and _continues_unthought_tool_loop(payload_messages):+ if is_claude_model(request.endpoint.model_id):+ # Under manual thinking, Anthropic requires the assistant message a tool loop continues to start with its+ # thinking block. One whose thinking cannot go back (another origin's, or a Session whose signatures the+ # provider refused) continues with thinking off, as Anthropic's refusal itself advises; the models that+ # take manual thinking all accept that. A non-Claude Anthropic-compatible model has no verified thinking+ # shape here, so leave the field out rather than guessing.+ payload["thinking"] = {"type": "disabled"}elif effort:if adaptive:payload["thinking"] = {"type": "adaptive"}diff --git a/core/agent_core/ai/claude_thinking.py b/core/agent_core/ai/claude_thinking.pyindex 0e8fdc679..8482bc2a5 100644--- a/core/agent_core/ai/claude_thinking.py+++ b/core/agent_core/ai/claude_thinking.py@@ -23,6 +23,13 @@ _CLAUDE_VERSION: Final = re.compile(r"claude-(?:[a-z]+-)?(\d+)(?:-(\d{1,2}))?(?!_FIRST_ADAPTIVE_VERSION: Final = (4, 6)+def is_claude_model(model_id: str) -> bool:+ """Whether the model ID's final path segment names a Claude model."""++ normalized = model_id.lower().replace(".", "-")+ return normalized.rsplit("/", 1)[-1].startswith("claude-")++def uses_adaptive_thinking(model_id: str) -> bool:"""Whether this Claude model takes adaptive thinking; False for a Claude version before 4.6 and for non-Claude."""diff --git a/tests/agent_core/ai/test_claude_thinking.py b/tests/agent_core/ai/test_claude_thinking.pyindex 800592182..6449f0c5d 100644--- a/tests/agent_core/ai/test_claude_thinking.py+++ b/tests/agent_core/ai/test_claude_thinking.py@@ -4,7 +4,7 @@ from __future__ import annotationsimport pytest-from core.agent_core.ai.claude_thinking import uses_adaptive_thinking+from core.agent_core.ai.claude_thinking import is_claude_model, uses_adaptive_thinking@pytest.mark.parametrize(("model_id", "adaptive"), [@@ -30,3 +30,10 @@ from core.agent_core.ai.claude_thinking import uses_adaptive_thinking])def test_only_a_claude_version_before_4_6_takes_a_token_budget(model_id, adaptive):assert uses_adaptive_thinking(model_id) is adaptive+++def test_claude_model_detection_uses_the_model_name_not_the_protocol() -> None:+ assert is_claude_model("claude-sonnet-4-5") is True+ assert is_claude_model("anthropic/claude-sonnet-4-5") is True+ assert is_claude_model("grok-4.7") is False+ assert is_claude_model("relay-claude-opus-5-5") is Falsediff --git a/tests/agent_core/ai/test_hosted_replay.py b/tests/agent_core/ai/test_hosted_replay.pyindex 46409ba5f..40adcabc3 100644--- a/tests/agent_core/ai/test_hosted_replay.py+++ b/tests/agent_core/ai/test_hosted_replay.py@@ -680,6 +680,7 @@ _READ_CALL = ToolCallBlock(id="toolu_1", name="read", arguments={"path": "a"})# Sonnet 5.5, Fable and Mythos "reject `thinking: {type: "disabled"}`"._ADAPTIVE_MODEL = "claude-opus-5-5"_MANUAL_MODEL = "claude-sonnet-4-5"+_NON_CLAUDE_MODEL = "grok-4.7"@pytest.mark.parametrize(@@ -698,16 +699,19 @@ _MANUAL_MODEL = "claude-sonnet-4-5"(_MANUAL_MODEL, (_READ_CALL,), "result-then-user", "disabled"),# ...while a new turn after an answer keeps it on.(_MANUAL_MODEL, (TextBlock("done"),), "user", "enabled"),+ # An Anthropic-compatible non-Claude model does not receive the Claude-specific fallback...+ (_NON_CLAUDE_MODEL, (_READ_CALL,), "result", None),+ # ...but its normal non-tool-loop reasoning request remains unchanged.+ (_NON_CLAUDE_MODEL, (TextBlock("done"),), "user", "enabled"),],ids=["adaptive-thinking-as-text", "adaptive-call-first", "manual-signed-thinking-first", "manual-thinking-as-text",- "manual-call-first", "manual-user-message-after-results", "manual-new-turn"],+ "manual-call-first", "manual-user-message-after-results", "manual-new-turn", "non-claude-tool-loop",+ "non-claude-new-turn"],)-async def test_a_tool_loop_whose_assistant_message_cannot_start_with_thinking_continues_with_thinking_off(+async def test_anthropic_thinking_fallback_is_scoped_to_manual_claude_tool_loops(model, continued, after, thinking):- """Under manual thinking a request whose continued assistant message cannot start with thinking (its thinking went- as text) is sent with thinking off, as Anthropic's refusal advises; adaptive thinking has no such rule and is never- turned off, since several adaptive models refuse ``disabled``; a new turn after an answer keeps thinking on."""+ """Manual Claude uses the #2736 fallback; adaptive Claude stays on; other models omit it rather than guessing."""endpoint = replace(_endpoint("anthropic", replay=False, native=False), hosted_tools={}, model_id=model)result = ToolResultMessage("toolu_1", "read", (TextBlock("contents"),))@@ -722,7 +726,10 @@ async def test_a_tool_loop_whose_assistant_message_cannot_start_with_thinking_cowire = await build_wire_request(request, gateway=True)- assert wire.body["thinking"]["type"] == thinking+ if thinking is None:+ assert "thinking" not in wire.body+ else:+ assert wire.body["thinking"]["type"] == thinkingdef _thought_and_read() -> str:diff --git a/tests/scenarios/model_hub/catalog.yaml b/tests/scenarios/model_hub/catalog.yamlindex 2927eaf8b..a74b56ded 100644--- a/tests/scenarios/model_hub/catalog.yaml+++ b/tests/scenarios/model_hub/catalog.yaml@@ -439,7 +439,7 @@ scenarios:- tests/agent_core/ai/test_hosted_replay.py::test_an_opaque_payload_refusal_ends_the_send_as_a_refusal_of_its_source_identity- tests/agent_core/ai/test_hosted_replay.py::test_an_opaque_payload_another_account_refuses_is_sent_portably_from_then_on_in_the_session- tests/agent_core/ai/test_hosted_replay.py::test_a_refusal_of_what_the_session_already_demoted_stands_as_the_error- - tests/agent_core/ai/test_hosted_replay.py::test_a_tool_loop_whose_assistant_message_cannot_start_with_thinking_continues_with_thinking_off+ - tests/agent_core/ai/test_hosted_replay.py::test_anthropic_thinking_fallback_is_scoped_to_manual_claude_tool_loops- tests/agent_core/ai/test_hosted_replay.py::test_a_session_whose_signatures_were_refused_still_finishes_tool_loops_with_thinking_on- tests/agent_core/ai/test_hosted_replay.py::test_a_decrypt_refusal_drops_every_opaque_payload_of_that_identity_for_the_rest_of_the_turn- tests/agent_core/ai/test_hosted_replay.py::test_a_hosted_call_goes_back_verbatim_and_pinned_only_to_its_own_source_with_replay_evidence