fix(run_agent): use public default_headers attr when preserving routed client headers

The OpenAI Python SDK stores default headers on the public
 attribute, not the private .
Because the code checked for the private attribute, provider-specific
headers (e.g. Kimi's User-Agent) were silently dropped, causing 403
errors for Kimi Coding API users.

Fixes #8779
This commit is contained in:
Andrew Smith 2026-04-12 21:58:44 -07:00
parent 83ca0844f7
commit 0c376841dc

View file

@ -886,8 +886,8 @@ class AIAgent:
"base_url": str(_routed_client.base_url),
}
# Preserve any default_headers the router set
if hasattr(_routed_client, '_default_headers') and _routed_client._default_headers:
client_kwargs["default_headers"] = dict(_routed_client._default_headers)
if hasattr(_routed_client, 'default_headers') and _routed_client.default_headers:
client_kwargs["default_headers"] = dict(_routed_client.default_headers)
else:
# When the user explicitly chose a non-OpenRouter provider
# but no credentials were found, fail fast with a clear