feat: add custom header support for provider requests - #14314
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolved conflicts in: - agent/auxiliary_client.py: adopt upstream's get_nous_recommended_aux_model while preserving _headers_with_config() propagation; update Kimi User-Agent - tools/delegate_tool.py: keep both override_default_headers and role params - tui_gateway/server.py: adopt upstream's runtime-based AIAgent construction while preserving default_headers resolution Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…und 2) Resolved conflicts in: - agent/auxiliary_client.py: adopt upstream's _extract_url_query_params while preserving _headers_with_config() propagation; use _clean_base for URL params - cron/scheduler.py: keep default_headers + adopt upstream's skip_context_files logic - run_agent.py: adopt upstream's _rebuild_anthropic_client() refactoring, add default_headers param to that method; keep default_headers in __init__ - tests/agent/test_auxiliary_client.py: keep both custom header tests and upstream's new auth refresh retry tests - tui_gateway/server.py: adopt upstream's _resolve_startup_runtime() while preserving default_headers resolution Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Nice! Tested it - this PR works :) Thanks.. |
|
Btw, you seemed to have worked on 0.12. The code has conflicts with Hermes Agent v0.13.0 (2026.5.7) . You may wish to make a new PR update? Also, you check that |
Well i'm pretty sure that we still don't support Also I find out that the provider-level 'headers' config may not work, I'll fix that(meanwhile we should rename that config to 'custom_headers' to avoid confusion) |
…edential pool check + custom provider lookup)
# Conflicts: # run_agent.py # tests/run_agent/test_switch_model_context.py
# Conflicts: # agent/context_compressor.py
# Conflicts: # agent/agent_init.py # agent/auxiliary_client.py # run_agent.py # tests/agent/test_turn_context.py # tools/delegate_tool.py
# Conflicts: # tools/delegate_tool.py
# Conflicts: # agent/anthropic_adapter.py # agent/auxiliary_client.py
# Conflicts: # tools/transcription_tools.py
Related: #9518, #56244, and #50796 are the active custom-header cluster. Current #14314 carries both provider-level extra-header handling and backward-compatible model custom headers across more runtime paths, so it is related rather than a duplicate. A maintainer should select the canonical contract after the required rebase. |
# Conflicts: # agent/background_review.py # tests/agent/test_auxiliary_named_custom_providers.py # tests/agent/test_context_compressor.py # tests/agent/test_context_engine.py # tests/agent/test_prompt_caching.py # tests/agent/test_turn_context.py # tests/cli/test_cli_provider_resolution.py # tests/hermes_cli/test_config.py # tests/hermes_cli/test_runtime_provider_resolution.py # tests/hermes_cli/test_tui_resume_flow.py # tests/tools/test_transcription_tools.py
# Conflicts: # agent/auxiliary_client.py # hermes_cli/runtime_provider.py # tests/agent/test_context_compressor.py
# Conflicts: # agent/auxiliary_client.py # agent/turn_context.py
# Conflicts: # acp_adapter/server.py # agent/auxiliary_client.py # tests/agent/test_turn_context.py # tests/test_tui_gateway_server.py # tui_gateway/server.py
# Conflicts: # agent/auxiliary_client.py
# Conflicts: # agent/anthropic_adapter.py
# Conflicts: # agent/background_review.py # agent/context_compressor.py # hermes_cli/config.py # hermes_cli/model_switch.py # tools/delegate_tool.py
Summary
model.custom_headersconfig option to attach arbitrary HTTP headers to provider requestscustom_providers[].custom_headers/providers.<name>.custom_headersfor provider-specific headers; this is the only provider-level field, whileheadersis intentionally not supported to avoid ambiguityagent/client_headers.pymodule withget_model_custom_headers()andmerge_default_headers()helpers for header sanitization and ordered mergingdefault_headersthrough the request chain:run_agent→auxiliary_client→anthropic_adapter→ SDK client, including subagents viadelegate_toolcustomresolution, and Anthropic-compatible endpointsConfig Example
Global headers for all provider requests:
Provider-specific headers:
The same field is supported after migration in the
providers:map:Closes #9398
Test Plan
scripts/run_tests.sh tests/hermes_cli/test_runtime_provider_resolution.py tests/hermes_cli/test_config.py tests/cli/test_cli_provider_resolution.py tests/hermes_cli/test_tui_resume_flow.py tests/agent/test_auxiliary_named_custom_providers.pytests/agent/test_client_headers.py— sanitization, merge semantics, empty/None inputstests/agent/test_anthropic_adapter.py— header merge with Anthropic defaults, provider-override-wins-on-conflicttests/agent/test_auxiliary_client.py—_normalize_main_runtimeheader handling,_try_anthropicheader propagation, explicit vs context prioritycustom_providers[].custom_headers,providers.<name>.custom_headers, credential-pool propagation, bare-custom/direct-alias lookup, and migration preservation