diff --git a/internal/gateway/claude_code_headers_test.go b/internal/gateway/claude_code_headers_test.go index 3bbb5820a..b0ef67463 100644 --- a/internal/gateway/claude_code_headers_test.go +++ b/internal/gateway/claude_code_headers_test.go @@ -81,9 +81,11 @@ func TestClaudeCodeHeadersReachAnthropicRelay(t *testing.T) { t.Errorf("x-app: %v", f.head) } - // another agent's request goes as magpie's + // another agent's request goes with its own User-Agent (a key+URL + // provider is sent the agent's, nb5p on Discord) and none of Claude + // Code's headers send("/v1/messages?beta=true", http.Header{"User-Agent": {"opencode/1.0"}, "X-App": {"other"}, "X-Stainless-Lang": {"js"}}) - if ua := f.head.Get("User-Agent"); !strings.HasPrefix(ua, "magpie/") || f.head.Get("X-App") != "" || f.head.Get("X-Stainless-Lang") != "" || query != "" { + if ua := f.head.Get("User-Agent"); ua != "opencode/1.0" || f.head.Get("X-App") != "" || f.head.Get("X-Stainless-Lang") != "" || query != "" { t.Errorf("other agent: %q %v %q", ua, f.head, query) } } diff --git a/internal/gateway/codex_client_headers_test.go b/internal/gateway/codex_client_headers_test.go index 2476deb15..8375e5753 100644 --- a/internal/gateway/codex_client_headers_test.go +++ b/internal/gateway/codex_client_headers_test.go @@ -117,9 +117,11 @@ func TestCodexHeadersReachKeyedRelay(t *testing.T) { t.Errorf("%s: desktop: %v", c.proto, f.head) } - // another agent's request goes as magpie's + // another agent's request goes with its own User-Agent (a key+URL + // provider is sent the agent's, nb5p on Discord) and none of + // Codex's headers send(http.Header{"User-Agent": {"opencode/1.0"}, "X-Codex-Window-Id": {"w"}, "Session-Id": {"s"}}) - if ua := f.head.Get("User-Agent"); !strings.HasPrefix(ua, "magpie/") || f.head.Get("X-Codex-Window-Id") != "" || f.head.Get("Session-Id") != "" { + if ua := f.head.Get("User-Agent"); ua != "opencode/1.0" || f.head.Get("X-Codex-Window-Id") != "" || f.head.Get("Session-Id") != "" { t.Errorf("%s: other agent: %q %v", c.proto, ua, f.head) } }