Skip to content

[codex] Use background task auth for additional backend calls#18260

Merged
adrian-openai merged 3 commits intomainfrom
dev/adrian/codex/agent-identity-background-task-more-calls
Apr 20, 2026
Merged

[codex] Use background task auth for additional backend calls#18260
adrian-openai merged 3 commits intomainfrom
dev/adrian/codex/agent-identity-background-task-more-calls

Conversation

@adrian-openai
Copy link
Copy Markdown
Contributor

@adrian-openai adrian-openai commented Apr 17, 2026

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 AuthManager for the default ChatGPT backend authorization header, and AuthManager decides bearer vs background AgentAssertion internally. Task-pinned inference auth remains separate because it needs the thread's registered task id.

Stack

What Changed

  • pass full authorization header values through backend-client and cloud-tasks-client call paths where needed
  • move ChatGPT client, cloud requirements, cloud tasks, thread-manager, and models-manager background auth usage into this downstream slice
  • make app-server remote control enrollment/websocket auth ask AuthManager for the local backend authorization header instead of threading a background auth mode through transport options
  • keep the same feature-gated bearer fallback behavior from PR4.1

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

Comment thread codex-rs/app-server/src/lib.rs Outdated
Comment on lines +595 to +597
background_agent_task_auth_mode: BackgroundAgentTaskAuthMode::from_feature_enabled(
config.features.enabled(Feature::UseAgentIdentity),
),
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.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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!

@adrian-openai adrian-openai force-pushed the dev/adrian/codex/agent-identity-background-task branch from 9bf6395 to 40b89e8 Compare April 20, 2026 00:37
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/agent-identity-background-task-more-calls branch 2 times, most recently from 367eb2b to a1d28fe Compare April 20, 2026 01:01
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/agent-identity-background-task branch from 40b89e8 to 42f625d Compare April 20, 2026 01:01
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/agent-identity-background-task-more-calls branch from a1d28fe to b014f14 Compare April 20, 2026 01:09
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/agent-identity-background-task branch from 42f625d to a722d39 Compare April 20, 2026 01:10
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/agent-identity-background-task-more-calls branch from b014f14 to 2943bc2 Compare April 20, 2026 01:28
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/agent-identity-background-task branch from a722d39 to 72acf86 Compare April 20, 2026 03:30
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/agent-identity-background-task-more-calls branch from 2943bc2 to 9008049 Compare April 20, 2026 03:30
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/agent-identity-background-task branch from 72acf86 to 797959a Compare April 20, 2026 05:18
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/agent-identity-background-task-more-calls branch 2 times, most recently from bf06eb9 to ffab686 Compare April 20, 2026 05:52
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`
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/agent-identity-background-task-more-calls branch from ffab686 to 8f3ed7b Compare April 20, 2026 06:19
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/agent-identity-background-task branch from 797959a to 44c3502 Compare April 20, 2026 06:19
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
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/agent-identity-background-task-more-calls branch from 8f3ed7b to 5171ebb Compare April 20, 2026 13:53
@adrian-openai adrian-openai merged commit 19e2f21 into main Apr 20, 2026
25 checks passed
@adrian-openai adrian-openai deleted the dev/adrian/codex/agent-identity-background-task-more-calls branch April 20, 2026 14:24
@github-actions github-actions bot locked and limited conversation to collaborators Apr 20, 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