Skip to content

fix(app-server): set originator header from initialize JSON-RPC request - #8873

Merged
owenlin0 merged 5 commits into
mainfrom
owen/set_originator_via_client_info
Jan 9, 2026
Merged

owenlin0 merged 5 commits into
mainfrom
owen/set_originator_via_client_info

Conversation

@owenlin0

@owenlin0 owenlin0 commented Jan 8, 2026 •

Copy link
Copy Markdown
Contributor

Motivation
The originator header is important for codex-backend’s Responses API proxy because it identifies the real end client (codex cli, codex vscode extension, codex exec, future IDEs) and is used to categorize requests by client for our enterprise compliance API.

Today the originator header is set by either:

  • the CODEX_INTERNAL_ORIGINATOR_OVERRIDE env var (our VSCode extension does this)
  • calling set_default_originator() which sets a global immutable singleton (codex exec does this)

For codex app-server, we want the initialize JSON-RPC request to set that header because it is a natural place to do so. Example:

{
  "method": "initialize",
  "id": 0,
  "params": {
    "clientInfo": {
      "name": "codex_vscode",
      "title": "Codex VS Code Extension",
      "version": "0.1.0"
    }
  }
}

and when app-server receives that request, it can call set_default_originator(). This is a much more natural interface than asking third party developers to set an env var.

One hiccup is that originator() reads the global singleton and locks in the value, preventing a later set_default_originator() call from setting it. This would be fine but is brittle, since any codepath that calls originator() before app-server can process an initialize JSON-RPC call would prevent app-server from setting it. This was actually the case with OTEL initialization which runs on boot, but I also saw this behavior in certain tests.

Instead, what we now do is:

  • [unchanged] If CODEX_INTERNAL_ORIGINATOR_OVERRIDE env var is set, originator() would return that value and set_default_originator() with some other value does NOT override it.
  • [new] If no env var is set, originator() would return the default value which is codex_cli_rs UNTIL set_default_originator() is called once, in which case it is set to the new value and becomes immutable. Later calls to set_default_originator() returns SetOriginatorError::AlreadyInitialized.

Other notes

  • I updated codex_core::otel_init::build_provider to accepts a service name override, and app-server sends a hardcoded codex_app_server service name to distinguish it from codex_cli_rs used by default (e.g. TUI).

Next steps

  • Update VSCE to set the proper value for clientInfo.name on initialize and drop the CODEX_INTERNAL_ORIGINATOR_OVERRIDE env var.
  • Delete support for CODEX_INTERNAL_ORIGINATOR_OVERRIDE in codex-rs.

@owenlin0
owenlin0 force-pushed the owen/set_originator_via_client_info branch from 7613105 to c2a6605 Compare January 8, 2026 00:47
@owenlin0
owenlin0 force-pushed the owen/set_originator_via_client_info branch from 47b424b to 818699b Compare January 8, 2026 01:43
@owenlin0
owenlin0 marked this pull request as ready for review January 8, 2026 17:21
@owenlin0 owenlin0 changed the title fix(app-server): set originator header from clientInfo.name fix(app-server): set originator header from initialize JSON-RPC request Jan 8, 2026
@gpeal
gpeal requested a review from bolinfest January 8, 2026 17:32
@owenlin0

owenlin0 commented Jan 8, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

@owenlin0

owenlin0 commented Jan 8, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

@bolinfest bolinfest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the detailed explanation!

@owenlin0
owenlin0 merged commit ea56186 into main Jan 9, 2026
26 checks passed
@owenlin0
owenlin0 deleted the owen/set_originator_via_client_info branch January 9, 2026 16:17
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants