Skip to content

Bugfix: preserve routed provider default headers#8784

Open
HiddenPuppy wants to merge 2 commits into
NousResearch:mainfrom
HiddenPuppy:codex/fix-kimi-routed-default-headers
Open

Bugfix: preserve routed provider default headers#8784
HiddenPuppy wants to merge 2 commits into
NousResearch:mainfrom
HiddenPuppy:codex/fix-kimi-routed-default-headers

Conversation

@HiddenPuppy

Copy link
Copy Markdown
Contributor

Summary

  • preserve provider headers from routed OpenAI clients when the main agent initializes
  • reuse the same header extraction path when fallback providers rebuild _client_kwargs
  • add a regression test covering Kimi-style routed clients that expose public default_headers

Root Cause

run_agent.py initialized routed OpenAI clients by checking _default_headers, but routed providers such as Kimi expose required headers on the public default_headers attribute. That mismatch dropped the provider's header set before the main client was created, which broke requests that depend on those headers.

Validation

  • source /Users/jerome.xu/Desktop/codex/hermes-agent/.codex-runtime/venv311/bin/activate && pytest -n 0 tests/run_agent/test_run_agent.py::TestRoutedClientDefaultHeaders::test_init_preserves_public_default_headers_from_routed_client tests/run_agent/test_fallback_model.py tests/run_agent/test_primary_runtime_restore.py tests/run_agent/test_context_token_tracking.py

Fixes #8779.

@HiddenPuppy HiddenPuppy force-pushed the codex/fix-kimi-routed-default-headers branch from 439e475 to a3b0954 Compare April 14, 2026 14:55
@HiddenPuppy HiddenPuppy marked this pull request as ready for review April 14, 2026 14:59
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder provider/kimi Kimi / Moonshot labels Apr 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #8799 — same fix: use public default_headers instead of private _default_headers for routed provider header preservation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists provider/kimi Kimi / Moonshot type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: run_agent.py uses _default_headers instead of default_headers, dropping routed client headers and breaking Kimi API

2 participants