Skip to content

Conversation

jiwon-oai
Copy link
Contributor

Update the user agent override context var to override headers generally instead of just the ua header. This allows us to pass in rich header info from other OA sdks running alongside Agents SDK.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines 10 to 15
_USER_AGENT = f"Agents/Python {__version__}"
HEADERS = {"User-Agent": _USER_AGENT}

USER_AGENT_OVERRIDE: ContextVar[str | None] = ContextVar(
"openai_chatcompletions_user_agent_override", default=None
HEADERS_OVERRIDE: ContextVar[dict[str, str] | None] = ContextVar(
"openai_chatcompletions_headers_override", default=None
)

Choose a reason for hiding this comment

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

[P1] Preserve USER_AGENT_OVERRIDE for backward compatibility

The context variable used by external callers to override the chat-completions User-Agent was renamed from USER_AGENT_OVERRIDE to HEADERS_OVERRIDE with no alias left behind. Because the original name was public (no leading underscore) and tests imported it directly, any existing client code that still does from agents.models.chatcmpl_helpers import USER_AGENT_OVERRIDE will now raise ImportError/AttributeError and lose the ability to override headers. Consider keeping the old symbol as an alias (USER_AGENT_OVERRIDE = HEADERS_OVERRIDE) or deprecating it gradually to avoid an unnecessary breaking change.

Useful? React with 👍 / 👎.

Copy link
Collaborator

@rm-openai rm-openai left a comment

Choose a reason for hiding this comment

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

lgtm - technically a breaking change but not part of public documented api so this is ok

@rm-openai rm-openai merged commit 4c4b7c2 into main Sep 23, 2025
5 checks passed
@rm-openai rm-openai deleted the jiwon/override-headers-instead-of-just-ua branch September 23, 2025 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants