Skip to content

feat(config): support user-defined custom HTTP headers for LLM API requests - #9454

Open
minimAluminiumalism wants to merge 1 commit into
NousResearch:mainfrom
minimAluminiumalism:feat/custom-headers-config
Open

feat(config): support user-defined custom HTTP headers for LLM API requests#9454
minimAluminiumalism wants to merge 1 commit into
NousResearch:mainfrom
minimAluminiumalism:feat/custom-headers-config

Conversation

@minimAluminiumalism

Copy link
Copy Markdown

Summary

  • Add custom_headers config field in config.yaml, merged into all outgoing LLM API requests (Anthropic + OpenAI/OpenRouter)

Closes #9398

Test plan

  • 15 new unit tests covering config loading, Anthropic client, and auxiliary client
  • No regressions in existing tests

@tevenfeng

tevenfeng commented Apr 23, 2026

Copy link
Copy Markdown

I tested this pr and found out that requests from subagents are likely not using the configured custom header.
And I have used Claude Code to fix this problem in my own fork
new pr #14314

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint area/config Config system, migrations, profiles labels Apr 23, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to open PR #9518 which addresses the same feature request #9398. One of these should be closed as duplicate.

@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to open PR #9518.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. The native Anthropic portion addresses a gap that still exists on current main, but this patch needs a focused salvage onto the established header configuration path.

Problems

  • The new top-level custom_headers config duplicates the existing model-level request-header surface. Current docs expose model.default_headers and model.extra_headers at cli-config.yaml.example:77-91; the issue itself proposed model.custom_headers.
  • The diff does not update the primary OpenAI construction path. Current primary construction is agent/agent_init.py:892-1105, so direct-agent and child-agent OpenAI requests would not consume this new setting.
  • Current native Anthropic construction still has the requested gap: agent/anthropic_adapter.py:780-829 assembles required headers and creates the SDK client without merging user configuration. The current OpenAI-only exclusion is explicit at cli-config.yaml.example:77-84.

Suggested changes

  • Extend the existing model-level header helper into build_anthropic_client, preserving required Anthropic headers across construction and rebuild paths.
  • Reuse the current model.default_headers / model.extra_headers schema instead of adding a top-level key.
  • Cover native Anthropic and rebuild behavior with a temporary HERMES_HOME regression test.

This is an automated hermes-sweeper review.

Comment thread hermes_cli/config.py

DEFAULT_CONFIG = {
"model": "",
"custom_headers": {},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a second global header schema, while current main documents model.default_headers / model.extra_headers for request headers (cli-config.yaml.example:77-91). Please extend that existing model-level contract instead of adding a top-level custom_headers key; the PR also needs to wire the setting into the primary client path, not only the auxiliary and Anthropic constructors.

@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support custom HTTP headers via config.yaml

4 participants