Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

fix(vibey): send Anthropic's xhigh natively where the hop declares it; one sent_effort for the wire and the effort menu (#2575)

Call White5815d18ae4d4
diff --git a/core/agent_core/ai/anthropic.py b/core/agent_core/ai/anthropic.py
index aa83a474d..4ff642822 100644
--- a/core/agent_core/ai/anthropic.py
+++ b/core/agent_core/ai/anthropic.py
@@ -918,7 +918,7 @@ def build_messages_payload(
elif effort:
if _uses_adaptive_thinking(request.endpoint.model_id):
payload["thinking"] = {"type": "adaptive"}
- payload["output_config"] = {"effort": _anthropic_effort(effort)}
+ payload["output_config"] = {"effort": sent_effort(request.endpoint.model_id, effort)}
else:
# Pi's Anthropic adapter uses legacy budget thinking for Claude
# 4.5 and older families. The API requires room for the thinking
@@ -1171,8 +1171,19 @@ def _normalize_stop_reason(value: Any) -> str:
return normalized or "error"
-def _anthropic_effort(effort: str) -> str:
- return {"minimal": "low", "xhigh": "max"}.get(effort, effort)
+def sent_effort(model_id: str, effort: str) -> str | None:
+ """The token an Anthropic request carries at ``output_config.effort`` for ``effort`` on ``model_id``; None when it
+ carries none, for an off effort or a model that thinks on a legacy token budget.
+
+ The effort goes as given: the hop declares only the levels its model takes (Model Hub bounds them by the model's
+ catalog row), so ``xhigh`` reaches Opus 4.7 and later natively and never Opus 4.6, which has no such level.
+ ``minimal`` has no Anthropic level and goes as ``low``.
+ """
+
+ value = effort.lower()
+ if not value or value in {"none", "off", "disabled"} or not _uses_adaptive_thinking(model_id):
+ return None
+ return "low" if value == "minimal" else value
def _uses_adaptive_thinking(model_id: str) -> bool:
@@ -1188,6 +1199,7 @@ def _uses_adaptive_thinking(model_id: str) -> bool:
"claude-opus-5",
"claude-fable-5",
"claude-mythos-5",
+ "claude-haiku-5",
)
)
diff --git a/core/agent_core/ai/openai_chat.py b/core/agent_core/ai/openai_chat.py
index 8d8c0ed18..8762433c5 100644
--- a/core/agent_core/ai/openai_chat.py
+++ b/core/agent_core/ai/openai_chat.py
@@ -745,8 +745,9 @@ def build_chat_payload(
payload["tool_choice"] = (
required_only_tool(tools) if route is not None else {"type": "function", "function": {"name": name}}
)
- if request.reasoning_effort and request.reasoning_effort.lower() not in {"off", "disabled"}:
- payload["reasoning_effort"] = _openai_effort(request.reasoning_effort)
+ effort = sent_effort(request.reasoning_effort or "")
+ if effort is not None:
+ payload["reasoning_effort"] = effort
return payload
@@ -911,11 +912,12 @@ def _signature_details(signature: str) -> Any:
return value if isinstance(value, (list, dict)) else None
-def _openai_effort(value: str) -> str:
- # Pi preserves extended tiers when the resolved model advertises them;
- # the loop has already filtered ``reasoning_effort`` through
- # ModelCapabilities.reasoning_efforts.
- return value.lower()
+def sent_effort(effort: str) -> str | None:
+ """The token a Chat Completions request carries at ``reasoning_effort``: the effort as given, lower-cased, since the
+ loop sends only an effort the hop declares; None when it is off."""
+
+ value = effort.lower()
+ return None if not value or value in {"off", "disabled"} else value
def _uses_completion_tokens(model: str, effort: str | None) -> bool:
diff --git a/core/agent_core/ai/openai_responses.py b/core/agent_core/ai/openai_responses.py
index ce19d0c0a..c82b1b332 100644
--- a/core/agent_core/ai/openai_responses.py
+++ b/core/agent_core/ai/openai_responses.py
@@ -1373,9 +1373,10 @@ def build_responses_payload(
if tools:
payload["tools"] = tools
include: list[str] = []
- if request.reasoning_effort and request.reasoning_effort.lower() not in {"off", "disabled"}:
- payload["reasoning"] = {"effort": _openai_effort(request.reasoning_effort), "summary": "auto"}
- if request.reasoning_effort.lower() != "none":
+ effort = sent_effort(request.reasoning_effort or "")
+ if effort is not None:
+ payload["reasoning"] = {"effort": effort, "summary": "auto"}
+ if effort != "none":
include.append("reasoning.encrypted_content")
# A native hosted tool's own include values, e.g. OpenAI's web_search_call.action.sources (§4.1).
for route in native.values():
@@ -1762,11 +1763,12 @@ def _reasoning_summary_text(item: Mapping[str, Any]) -> str | None:
return "\n\n".join(parts) if parts else None
-def _openai_effort(value: str) -> str:
- # Pi preserves extended tiers when the resolved model advertises them;
- # the loop has already filtered ``reasoning_effort`` through
- # ModelCapabilities.reasoning_efforts.
- return value.lower()
+def sent_effort(effort: str) -> str | None:
+ """The token a Responses request carries at ``reasoning.effort``: the effort as given, lower-cased, since the loop
+ sends only an effort the hop declares (Pi preserves extended tiers the same way); None when it is off."""
+
+ value = effort.lower()
+ return None if not value or value in {"off", "disabled"} else value
def _string(value: Any) -> str:
diff --git a/core/agent_core/ai/registry.py b/core/agent_core/ai/registry.py
index 81f95cb71..3110625eb 100644
--- a/core/agent_core/ai/registry.py
+++ b/core/agent_core/ai/registry.py
@@ -26,6 +26,21 @@ _WIRE_REQUESTS: dict[ProtocolName, Callable[..., WireRequest]] = {
}
+def sent_effort(protocol: str, model_id: str, effort: str) -> str | None:
+ """The effort token a request on ``protocol`` to ``model_id`` carries for ``effort``, exactly as the adapter sends
+ it: at ``output_config.effort`` (Anthropic), ``reasoning.effort`` (Responses) or ``reasoning_effort`` (Chat; a
+ ``google`` hop is reached over Chat). None when the request carries no effort token. Model Hub's effort menu reads
+ the same answer, so the menu and the wire cannot drift."""
+
+ if protocol == "anthropic":
+ return anthropic.sent_effort(model_id, effort)
+ if protocol == "openai_responses":
+ return openai_responses.sent_effort(effort)
+ if protocol in ("openai_chat", "google"):
+ return openai_chat.sent_effort(effort)
+ raise ValueError(f"unsupported provider protocol: {protocol}")
+
+
def adapter_class(protocol: ProtocolName) -> type[ProviderAdapter]:
try:
return ADAPTERS[protocol]
diff --git a/tests/agent_core/ai/test_provider_adapters.py b/tests/agent_core/ai/test_provider_adapters.py
index e47d5c290..7dbfa01f6 100644
--- a/tests/agent_core/ai/test_provider_adapters.py
+++ b/tests/agent_core/ai/test_provider_adapters.py
@@ -30,7 +30,7 @@ from core.agent_core.ai.provider import (
ToolCallDelta,
ToolCallStart,
)
-from core.agent_core.ai.registry import ADAPTERS, adapter_class
+from core.agent_core.ai.registry import ADAPTERS, adapter_class, build_wire_request, sent_effort
from core.agent_core.cancel import CancelToken
from core.agent_core.messages import (
AssistantMessage,
@@ -2560,14 +2560,47 @@ def test_openai_payloads_forward_explicit_none_reasoning_effort(
assert "include" not in payload
-def test_anthropic_adaptive_xhigh_maps_to_max_effort() -> None:
- payload = build_messages_payload(
- _request("anthropic", model_id="claude-opus-5", reasoning_effort="xhigh"),
- (),
- )
+ ("model_id", "effort", "sent"),
+ [
+ # Native on Opus 4.7 and later (Anthropic's effort docs): the hop declares it, so it goes as given.
+ ("claude-opus-5", "xhigh", "xhigh"),
+ ("claude-opus-4-7", "xhigh", "xhigh"),
+ ("claude-haiku-5-5", "xhigh", "xhigh"),
+ ("claude-opus-4-6", "max", "max"),
+ # Anthropic has no minimal level.
+ ("claude-opus-5", "minimal", "low"),
+ ],
+)
+def test_anthropic_sends_the_declared_effort_as_given(model_id: str, effort: str, sent: str) -> None:
+ payload = build_messages_payload(_request("anthropic", model_id=model_id, reasoning_effort=effort), ())
assert payload["thinking"] == {"type": "adaptive"}
- assert payload["output_config"] == {"effort": "max"}
+ assert payload["output_config"] == {"effort": sent}
+
+
+ ("protocol", "model_id"),
+ [
+ ("anthropic", "claude-opus-5-5"),
+ ("anthropic", "claude-opus-4-5"),
+ ("openai_responses", "gpt-6-sol"),
+ ("openai_chat", "deepseek-v4"),
+ ],
+)
[email protected]("effort", ["minimal", "low", "high", "xhigh", "max", "none", "off", "XHIGH"])
+async def test_sent_effort_is_the_token_each_adapter_puts_on_the_wire(protocol: str, model_id: str, effort: str) -> None:
+ """Model Hub's effort menu reads ``sent_effort``; it must name exactly the token the request carries."""
+
+ wire = await build_wire_request(_request(protocol, model_id=model_id, reasoning_effort=effort), gateway=True)
+
+ carried = {
+ "anthropic": (wire.body.get("output_config") or {}).get("effort"),
+ "openai_responses": (wire.body.get("reasoning") or {}).get("effort"),
+ "openai_chat": wire.body.get("reasoning_effort"),
+ }[protocol]
+ assert carried == sent_effort(protocol, model_id, effort)
@pytest.mark.asyncio
diff --git a/tests/test_model_hub_reasoning_tiers.py b/tests/test_model_hub_reasoning_tiers.py
index 50626ffb7..5dc1e482e 100644
--- a/tests/test_model_hub_reasoning_tiers.py
+++ b/tests/test_model_hub_reasoning_tiers.py
@@ -91,6 +91,25 @@ def test_codex_only_ultra_does_not_become_an_api_reasoning_tier(
assert api.source == "catalog"
+ ("model_id", "tiers"),
+ [
+ # Anthropic's effort documentation: every level on Claude Haiku 5.5, no xhigh on Claude Sonnet 4.6.
+ ("claude-haiku-5-5", ("low", "medium", "high", "xhigh", "max")),
+ ("claude-sonnet-4-6", ("low", "medium", "high", "max")),
+ ],
+)
+def test_an_anthropic_model_that_reports_no_parameters_gets_its_documented_tiers(
+ model_id: str, tiers: tuple[str, ...]
+) -> None:
+ """Without upstream parameters, the bundled row is the only source of a hop's efforts: a model missing from it
+ would declare none, and the loop would never send the effort the user picked."""
+ resolution = resolve_reasoning_tiers(protocol="anthropic", model_id=model_id, supported_parameters=())
+
+ assert resolution.efforts == tiers
+ assert resolution.source == "catalog"
+
+
def test_catalog_row_is_not_filtered_through_the_vocabulary(
monkeypatch: pytest.MonkeyPatch,
) -> None:
diff --git a/vibe/data/backend_models.json b/vibe/data/backend_models.json
index 7873c1c52..ec45f39c3 100644
--- a/vibe/data/backend_models.json
+++ b/vibe/data/backend_models.json
@@ -13,6 +13,7 @@
{"id": "claude-sonnet-5-5", "label": "claude-sonnet-5-5 [1M]", "reasoning_efforts": ["low", "medium", "high", "xhigh", "max"]},
{"id": "claude-sonnet-5", "label": "claude-sonnet-5 [1M]", "reasoning_efforts": ["low", "medium", "high", "xhigh", "max"]},
{"id": "claude-sonnet-4-6", "label": "claude-sonnet-4-6 [1M]", "reasoning_efforts": ["low", "medium", "high", "max"]},
+ {"id": "claude-haiku-5-5", "reasoning_efforts": ["low", "medium", "high", "xhigh", "max"]},
{"id": "claude-haiku-4-5", "reasoning_efforts": ["low", "medium", "high"]},
{"id": "claude-opus-4-5", "reasoning_efforts": ["low", "medium", "high"]},
{"id": "claude-sonnet-4-5", "reasoning_efforts": ["low", "medium", "high"]},