Skip to content

fix(custom): apply compat User-Agent in main agent path - #11302

Closed
KeaneYan wants to merge 1 commit into
NousResearch:mainfrom
KeaneYan:fix/main-custom-ua-compat
Closed

fix(custom): apply compat User-Agent in main agent path#11302
KeaneYan wants to merge 1 commit into
NousResearch:mainfrom
KeaneYan:fix/main-custom-ua-compat

Conversation

@KeaneYan

Copy link
Copy Markdown

Summary

  • add a neutral compatibility User-Agent helper for custom OpenAI-compatible endpoints in the main agent path
  • apply it when the resolved provider starts with custom
  • cover both initial client construction and later _client_kwargs refresh

Root Cause

The auxiliary client already uses a compatibility User-Agent strategy for custom endpoints, but the main agent path in run_agent.py still allowed custom-provider requests to go out with the default OpenAI SDK UA.

That leaves relays/proxies that block SDK-default UAs in a split-brain state where auxiliary requests work but main agent requests fail.

Testing

  • No direct targeted test existed for this header path in the current suite.
  • Verified the PR only changes run_agent.py and isolates the custom-provider header behavior.

Fixes #11301

@KeaneYan
KeaneYan force-pushed the fix/main-custom-ua-compat branch from 3c119e9 to 51f29e7 Compare April 24, 2026 08:54
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels Apr 24, 2026
@KeaneYan
KeaneYan force-pushed the fix/main-custom-ua-compat branch from 51f29e7 to 2a72b99 Compare May 9, 2026 02:02
@KeaneYan
KeaneYan force-pushed the fix/main-custom-ua-compat branch from 2a72b99 to 4fe8fb8 Compare May 20, 2026 08:23
@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Closing as superseded by #41096, which adds model.default_headers support for custom OpenAI-compatible providers across both the main and auxiliary client paths (overriding the OpenAI SDK's User-Agent/X-Stainless-* headers that some gateways/WAFs reject — #40033). Thanks for the contribution! 🙏

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

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(custom): apply compatibility User-Agent on main agent requests

3 participants