Enable agent identity for tokenless startup auth#18177
Open
efrazer-oai wants to merge 1 commit intoefrazer/codex/agent-identity-jwtfrom
Open
Enable agent identity for tokenless startup auth#18177efrazer-oai wants to merge 1 commit intoefrazer/codex/agent-identity-jwtfrom
efrazer-oai wants to merge 1 commit intoefrazer/codex/agent-identity-jwtfrom
Conversation
This was referenced Apr 16, 2026
ae82643 to
90f493c
Compare
cf52e2b to
bf44dee
Compare
90f493c to
4f088d5
Compare
Contributor
adrian-openai
left a comment
There was a problem hiding this comment.
I got these reviews from Codex:
[High] Identity-only auth still tries to build Bearer-token request auth before AgentAssertion can happen
Location: [codex-rs/login/src/api_bridge.rs#L26-L30](https://github.com/openai/codex/blob/4f088d5c7391fe467a75e9743dacacbff4d6d65e/codex-rs/login/src/api_bridge.rs#L26-L30)
Additional context: [codex-rs/core/src/client.rs#L653-L663](https://github.com/openai/codex/blob/4f088d5c7391fe467a75e9743dacacbff4d6d65e/codex-rs/core/src/client.rs#L653-L663), [codex-rs/codex-api/src/api_bridge.rs#L205-L211](https://github.com/openai/codex/blob/4f088d5c7391fe467a75e9743dacacbff4d6d65e/codex-rs/codex-api/src/api_bridge.rs#L205-L211)
Why: With tokenless ChatGPT auth, CodexAuth::is_agent_identity_only() is true, but auth_provider_from_auth() still calls auth.get_token()?. Since tokens is None, this fails with token data unavailable while constructing CoreAuthProvider. In the exact PR head, CoreAuthProvider only emits Authorization: Bearer ...; there is no Authorization: AgentAssertion ... request-auth path.
Suggested fix: Add a narrow request-auth path for identity-only auth that can emit AgentAssertion without first requiring auth.get_token(). Ideally test this by capturing a /responses request from tokenless auth and asserting the auth scheme is AgentAssertion.
[High] Tokenless task registration/reuse still depends on token-backed ChatGPT binding
Location: [codex-rs/core/src/agent_identity/task_registration.rs#L39-L48](https://github.com/openai/codex/blob/4f088d5c7391fe467a75e9743dacacbff4d6d65e/codex-rs/core/src/agent_identity/task_registration.rs#L39-L48)
Additional context: [codex-rs/core/src/agent_identity.rs#L184-L192](https://github.com/openai/codex/blob/4f088d5c7391fe467a75e9743dacacbff4d6d65e/codex-rs/core/src/agent_identity.rs#L184-L192), [codex-rs/core/src/agent_identity.rs#L466-L488](https://github.com/openai/codex/blob/4f088d5c7391fe467a75e9743dacacbff4d6d65e/codex-rs/core/src/agent_identity.rs#L466-L488), [codex-rs/core/src/codex.rs#L1537-L1565](https://github.com/openai/codex/blob/4f088d5c7391fe467a75e9743dacacbff4d6d65e/codex-rs/core/src/codex.rs#L1537-L1565)
Why: PR 18177 updates startup identity loading, but the task path still uses the old assumptions. register_task() returns Ok(None) when feature_enabled is false. Even when the feature is true, current_auth_binding() goes through AgentIdentityBinding::from_auth(), which calls auth.get_token_data().ok()?; tokenless auth cannot produce that. task_matches_current_binding() has the same problem and may treat a valid cached/persisted task as stale.
Suggested fix: Add an identity-only binding path derived from AgentIdentityAuthRecord instead of token data. If tokenless auth is expected to carry a pre-registered task id, make task matching/reuse validate against that stored identity. If tokenless auth cannot register a task, fail explicitly instead of silently returning None.
Medium] Forced workspace enforcement logs out matching identity-only auth
Location: [codex-rs/login/src/auth/manager.rs#L596-L610](https://github.com/openai/codex/blob/4f088d5c7391fe467a75e9743dacacbff4d6d65e/codex-rs/login/src/auth/manager.rs#L596-L610)
Additional context: [codex-rs/exec/src/lib.rs#L420-L425](https://github.com/openai/codex/blob/4f088d5c7391fe467a75e9743dacacbff4d6d65e/codex-rs/exec/src/lib.rs#L420-L425)
Why: codex exec runs login restriction enforcement on startup. If forced_chatgpt_workspace_id is set, identity-only ChatGPT auth enters the workspace restriction branch, then calls auth.get_token_data(). With no tokens, that errors and logs out, even if agent_identity.workspace_id matches the forced workspace. Our smoke config used a forced workspace, so this matters for the devbox scenario.
Suggested fix: Before calling get_token_data(), handle auth.is_agent_identity_only() by comparing auth.agent_identity_record().workspace_id against the forced workspace. Add matching and mismatching tests.
I think that's what is left to get agent assertion only auth to work (my smoke test, in getting working got through all of these changes too). Doesn't need to be changed here, but I think needs to happen first.
bf44dee to
27ac8b7
Compare
3e92738 to
4783c5f
Compare
27ac8b7 to
bae7e87
Compare
4783c5f to
e8cde66
Compare
bae7e87 to
6c7bf25
Compare
e8cde66 to
ee7a12a
Compare
ee7a12a to
5512954
Compare
6c7bf25 to
2e0af35
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stack
CODEX_AGENT_IDENTITYWhat changed
Codex now treats agent identity as enabled when ChatGPT auth has
agent_identityand no user OAuth tokens.The small shape change is that
AgentIdentityBindingcan carryaccess_token: None. Token-backed auth still mints the human biscuit before registration. Tokenless auth reuses the stored agent identity, signs the task registration payload with the agent private key, and then uses the task id to buildAgentAssertionauth.This also handles two startup checks for tokenless auth:
agent_identity.workspace_idValidation
cd codex-rs && just fmtcd codex-rs && cargo check -p codex-login -p codex-corecd codex-rs && cargo test -p codex-login agent_identitycd codex-rs && cargo test -p codex-core agent_identitycd codex-rs && cargo test -p codex-login enforce_login_restrictionscd codex-rs && just fix -p codex-logincd codex-rs && just fix -p codex-core