The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(agent): keyless OpenCode placeholder blanks Authorization under the paid profile too
teknium1e77060e081fb
diff --git a/agent/agent_runtime_helpers.py b/agent/agent_runtime_helpers.pyindex cd3e768e191..8e6021d32da 100644--- a/agent/agent_runtime_helpers.py+++ b/agent/agent_runtime_helpers.py@@ -1774,9 +1774,12 @@ def create_openai_client(agent, client_kwargs: dict, *, reason: str, shared: booclient_kwargs.setdefault("max_retries", 0)_ensure_copilot_headers(client_kwargs)# OpenCode Free is served anonymously: any unrecognized bearer is a 401, so an empty- # Authorization default_header overrides the SDK's "Bearer <api_key>".- if agent.provider == "opencode-free":- from hermes_cli.models import opencode_zen_free_headers+ # Authorization default_header overrides the SDK's "Bearer <api_key>". Key on the keyless+ # placeholder as well as the provider: a free slug picked under the paid ``opencode`` profile+ # resolves to the placeholder too, and shipping it as a bearer 401s every request with an+ # empty pool to rotate (#110831).+ from hermes_cli.models import OPENCODE_ZEN_FREE_KEYLESS_PLACEHOLDER, opencode_zen_free_headers+ if agent.provider == "opencode-free" or client_kwargs.get("api_key") == OPENCODE_ZEN_FREE_KEYLESS_PLACEHOLDER:client_kwargs["default_headers"] = {**(client_kwargs.get("default_headers") or {}), **opencode_zen_free_headers()}# All primary construction and recovery paths must identify Hermes to the official Codex# endpoint, including snapshots with custom header overrides.diff --git a/tests/agent/test_opencode_free_client_headers.py b/tests/agent/test_opencode_free_client_headers.pyindex 3123abcebb7..84c702c4e1b 100644--- a/tests/agent/test_opencode_free_client_headers.py+++ b/tests/agent/test_opencode_free_client_headers.py@@ -94,3 +94,20 @@ def test_other_providers_unaffected(mock_openai):assert "Authorization" not in headers, ("opencode-zen (keyed) must not have its Authorization header blanked")+++@patch("agent.process_bootstrap.OpenAI")+def test_keyless_placeholder_blanks_authorization_under_paid_opencode_profile(mock_openai):+ """A free slug selected under the paid ``opencode`` profile resolves to the keyless+ placeholder; it must be blanked exactly like under ``opencode-free``, or every request+ 401s with nothing in the pool to rotate (#110831)."""+ mock_openai.return_value = MagicMock()+ agent = _FakeAgent(api_key="opencode-zen-free-keyless")+ agent.provider = "opencode"+ create_openai_client(+ agent,+ {"api_key": "opencode-zen-free-keyless", "base_url": ZEN_V1},+ reason="test",+ shared=False,+ )+ assert _zen_call_headers(mock_openai).get("Authorization") == ""