Skip to content

Scope app-server client identity per connection#22548

Draft
owenlin0 wants to merge 2 commits into
mainfrom
owen/connection_scoped_originator
Draft

Scope app-server client identity per connection#22548
owenlin0 wants to merge 2 commits into
mainfrom
owen/connection_scoped_originator

Conversation

@owenlin0
Copy link
Copy Markdown
Collaborator

@owenlin0 owenlin0 commented May 13, 2026

Why

The app-server can host multiple clients in the same long-lived process, but client identity was still largely process-global. That made attribution fragile: one initialized client could influence outbound originator and User-Agent headers for later app-server work, while infrastructure clients such as codex_app_server_daemon and codex-backend were excluded from global mutation even when they initiated session work.

Model/realtime requests, telemetry, and connector filtering should use the client identity for the connection that owns the request, not whatever process-global identity happens to be set.

What Changed

  • Added a scoped ClientIdentity path in codex-login that can build originator, User-Agent, default headers, and reqwest clients from an explicit identity while preserving existing process-default behavior outside the scope.
  • Changed app-server initialize to validate and store a concrete identity for every initialized connection, including daemon/backend clients, without mutating process-global originator or user-agent suffix.
  • Wrapped initialized app-server request handling, including background thread-start work, in the connection's scoped identity so async downstream work sees the right client.
  • Updated ModelClient and realtime paths to use the scoped/session identity for HTTP requests, Responses websocket handshakes, realtime call creation, and sideband/default headers.
  • Threaded the per-turn originator through telemetry, connector/app-tool filtering, MCP skill dependency checks, and plugin-install discovery paths so those decisions no longer depend on process-global identity.

Verification

  • Added codex-login coverage for scoped identity overriding process-default headers.
  • Added app-server coverage for a multi-connection websocket regression where codex-backend initializes first and a later codex_ios thread still sends model requests with codex_ios headers.
  • Updated initialize coverage so daemon/backend-style clients receive explicit connection-scoped user agents and explicit initialize identity ignores CODEX_INTERNAL_ORIGINATOR_OVERRIDE.

@owenlin0 owenlin0 force-pushed the owen/connection_scoped_originator branch from 49d34f7 to 87f1c39 Compare May 18, 2026 19:34
@owenlin0 owenlin0 changed the title wip connection-scoped originator Scope app-server client identity per connection May 18, 2026
@owenlin0 owenlin0 force-pushed the owen/connection_scoped_originator branch from 9c2a57b to 0d9e848 Compare May 19, 2026 18:03
@owenlin0 owenlin0 force-pushed the owen/connection_scoped_originator branch from 0d9e848 to 94a78f4 Compare May 19, 2026 18:13
@owenlin0 owenlin0 force-pushed the owen/connection_scoped_originator branch from e102964 to 8eadd52 Compare May 19, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant