[codex] Use background task auth for additional backend calls#18260
Merged
adrian-openai merged 3 commits intomainfrom Apr 20, 2026
Merged
Conversation
This was referenced Apr 17, 2026
shijie-oai
reviewed
Apr 17, 2026
Comment on lines
+595
to
+597
| background_agent_task_auth_mode: BackgroundAgentTaskAuthMode::from_feature_enabled( | ||
| config.features.enabled(Feature::UseAgentIdentity), | ||
| ), |
Collaborator
There was a problem hiding this comment.
I don't think we should be worried about if the remote control should be using anget identity or not? The app server on the remote device should have its own feature enabled?
Contributor
Author
There was a problem hiding this comment.
The added mode applies to the local app-server process opening the remote-control websocket to the ChatGPT/control-plane backend. It is not a setting sent across the websocket to tell the other end what to do.
The flow is:
- run_main_with_transport has the app-server Config.
- That config knows whether Feature::UseAgentIdentity is enabled.
- The remote-control transport needs to build the Authorization header for enrollment/websocket connection.
- The low-level websocket connector does not have Config, so the feature-derived BackgroundAgentTaskAuthMode gets threaded down.
- If enabled, it may use a background AgentAssertion authorization header.
- If disabled or unsupported, it falls back to bearer.
- So the remote side cannot “respect its own config” for this decision because this decision happens before the request is sent. The remote side can validate the auth it receives, but it does not choose whether this client process sends bearer vs AgentAssertion.
Let me know if that makes sense. I was wrong about this being part of slingshot!
9bf6395 to
40b89e8
Compare
367eb2b to
a1d28fe
Compare
40b89e8 to
42f625d
Compare
a1d28fe to
b014f14
Compare
42f625d to
a722d39
Compare
b014f14 to
2943bc2
Compare
a722d39 to
72acf86
Compare
2943bc2 to
9008049
Compare
shijie-oai
approved these changes
Apr 20, 2026
72acf86 to
797959a
Compare
bf06eb9 to
ffab686
Compare
adrian-openai
added a commit
that referenced
this pull request
Apr 20, 2026
## Summary This is the AgentAssertion downstream slice for feature-gated agent identity support, replacing the oversized AgentAssertion slice from PR #17807. It isolates task-scoped downstream AgentAssertion wiring on top of the merged PR3.1 work without re-carrying the earlier agent registration, task registration, or task-state history. This PR includes the task-scoped bug-fix call sites from the review: generic file upload auth, MCP OpenAI file upload auth, and ARC monitor auth. Broader user/control-plane calls move to PR4.1 and PR4.2. ## Stack - PR1: #17385 - add `features.use_agent_identity` - PR2: #17386 - register agent identities when enabled - PR3: #17387 - register agent tasks when enabled - PR3.1: #17978 - persist and prewarm registered tasks per thread - PR4: this PR - use task-scoped `AgentAssertion` downstream when enabled - PR4.1: #18094 - introduce AuthManager-owned background/control-plane `AgentAssertion` auth - PR4.2: #18260 - use background task auth for additional backend/control-plane calls ## What Changed - add AgentAssertion envelope generation in `codex-core` - route downstream HTTP and websocket auth through AgentAssertion when an agent task is present - extend the model-provider auth provider so non-bearer authorization schemes can be passed through cleanly - make generic file uploads attach the full authorization header value - make MCP OpenAI file uploads use the cached thread agent task assertion when present - make ARC monitor calls use the cached thread agent task assertion when present ## Why The original PR had drifted ancestry and showed a much larger diff than the semantic change actually required. Restacking it onto PR3.1 keeps the reviewable surface down to the downstream assertion slice. ## Validation - `just fmt` - `cargo check -p codex-core -p codex-login -p codex-analytics -p codex-app-server -p codex-cloud-requirements -p codex-cloud-tasks -p codex-models-manager -p codex-chatgpt -p codex-model-provider -p codex-mcp -p codex-core-skills` - `cargo test -p codex-model-provider bearer_auth_provider` - `cargo test -p codex-core agent_assertion` - `cargo test -p codex-app-server remote_control` - `cargo test -p codex-cloud-requirements fetch_cloud_requirements` - `cargo test -p codex-models-manager manager::tests` - `cargo test -p codex-chatgpt` - `cargo test -p codex-cloud-tasks` - `cargo test -p codex-login agent_identity` - `just fix -p codex-core -p codex-login -p codex-analytics -p codex-app-server -p codex-cloud-requirements -p codex-cloud-tasks -p codex-models-manager -p codex-chatgpt -p codex-model-provider -p codex-mcp -p codex-core-skills` - `just fix -p codex-app-server` - `git diff --check`
ffab686 to
8f3ed7b
Compare
797959a to
44c3502
Compare
adrian-openai
added a commit
that referenced
this pull request
Apr 20, 2026
## Summary Introduces a single background/control-plane agent task for ChatGPT backend requests that do not have a thread-scoped task, with `AuthManager` owning the default ChatGPT backend authorization decision. Callers now ask `AuthManager` for the default ChatGPT backend authorization header. `AuthManager` decides whether that is bearer or background AgentAssertion based on config/internal state, while low-level bootstrap paths can explicitly request bearer-only auth. This PR is stacked on PR4 and focuses on the shared background task auth plumbing plus the first tranche of backend/control-plane consumers. The remaining callsite wiring is split into PR4.2 to keep review size down. ## Stack - PR1: #17385 - add `features.use_agent_identity` - PR2: #17386 - register agent identities when enabled - PR3: #17387 - register agent tasks when enabled - PR3.1: #17978 - persist and prewarm registered tasks per thread - PR4: #17980 - use task-scoped `AgentAssertion` for downstream calls - PR4.1: this PR - introduce AuthManager-owned background/control-plane `AgentAssertion` auth - PR4.2: #18260 - use background task auth for additional backend/control-plane calls ## What Changed - add background task registration and assertion minting inside `codex-login` - persist `agent_identity.background_task_id` separately from per-session task state - make `BackgroundAgentTaskManager` private to `codex-login`; call sites do not instantiate or pass it around - teach `AuthManager` the ChatGPT backend base URL and feature-derived background auth mode from resolved config - expose bearer-only helpers for bootstrap/registration/refresh-style paths that must not use AgentAssertion - wire `AuthManager` default ChatGPT authorization through app listing, connector directory listing, remote plugins, MCP status/listing, analytics, and core-skills remote calls - preserve bearer fallback when the feature is disabled, the backend host is unsupported, or background task registration is not available ## Validation - `just fmt` - `cargo check -p codex-core -p codex-login -p codex-analytics -p codex-app-server -p codex-cloud-requirements -p codex-cloud-tasks -p codex-models-manager -p codex-chatgpt -p codex-model-provider -p codex-mcp -p codex-core-skills` - `cargo test -p codex-login agent_identity` - `cargo test -p codex-model-provider bearer_auth_provider` - `cargo test -p codex-core agent_assertion` - `cargo test -p codex-app-server remote_control` - `cargo test -p codex-cloud-requirements fetch_cloud_requirements` - `cargo test -p codex-models-manager manager::tests` - `cargo test -p codex-chatgpt` - `cargo test -p codex-cloud-tasks` - `just fix -p codex-core -p codex-login -p codex-analytics -p codex-app-server -p codex-cloud-requirements -p codex-cloud-tasks -p codex-models-manager -p codex-chatgpt -p codex-model-provider -p codex-mcp -p codex-core-skills` - `just fix -p codex-app-server` - `git diff --check`
Base automatically changed from
dev/adrian/codex/agent-identity-background-task
to
main
April 20, 2026 13:50
8f3ed7b to
5171ebb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Splits the larger PR4.1 background task auth rollout by moving additional backend/control-plane call sites into this downstream PR.
This PR keeps callers on the same design as PR4.1: most code asks
AuthManagerfor the default ChatGPT backend authorization header, andAuthManagerdecides bearer vs background AgentAssertion internally. Task-pinned inference auth remains separate because it needs the thread's registered task id.Stack
features.use_agent_identityAgentAssertionfor downstream callsAgentAssertionauthWhat Changed
AuthManagerfor the local backend authorization header instead of threading a background auth mode through transport optionsValidation
just fmtcargo check -p codex-core -p codex-login -p codex-analytics -p codex-app-server -p codex-cloud-requirements -p codex-cloud-tasks -p codex-models-manager -p codex-chatgpt -p codex-model-provider -p codex-mcp -p codex-core-skillscargo test -p codex-login agent_identitycargo test -p codex-model-provider bearer_auth_providercargo test -p codex-core agent_assertioncargo test -p codex-app-server remote_controlcargo test -p codex-cloud-requirements fetch_cloud_requirementscargo test -p codex-models-manager manager::testscargo test -p codex-chatgptcargo test -p codex-cloud-tasksjust fix -p codex-core -p codex-login -p codex-analytics -p codex-app-server -p codex-cloud-requirements -p codex-cloud-tasks -p codex-models-manager -p codex-chatgpt -p codex-model-provider -p codex-mcp -p codex-core-skillsjust fix -p codex-app-servergit diff --check