Skip to content

feat: opt ChatGPT auth into agent identity#19049

Open
adrian-openai wants to merge 1 commit into
dev/adrian/codex/hai-task-primitivesfrom
dev/adrian/codex/hai-session-task-state
Open

feat: opt ChatGPT auth into agent identity#19049
adrian-openai wants to merge 1 commit into
dev/adrian/codex/hai-task-primitivesfrom
dev/adrian/codex/hai-session-task-state

Conversation

@adrian-openai

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

Copy link
Copy Markdown
Contributor

Stack

This is PR 2 of the simplified HAI single-run-task stack:

  • #19047 Agent Identity assertion and task-registration primitives, including the shared run-task helper used by existing Agent Identity JWT auth.
  • #19049 Disabled-by-default ChatGPT auth opt-in that provisions/reuses persisted Agent Identity runtime auth and its single run task.
  • #19051 Run-scoped provider auth that uses one backend-owned task id for first-party inference and compaction requests.

#19054 collapsed out of the active stack because the simplified design no longer needs a separate background/control-plane task helper.

Summary

This PR adds the disabled-by-default path for normal ChatGPT-login Codex sessions to obtain Agent Identity runtime auth through the Codex backend. Existing Agent Identity JWT startup mode remains a separate path and does not require the feature flag.

What changed:

  • adds the experimental use_agent_identity feature flag and config schema entry
  • adds an explicit AgentIdentityAuthPolicy so call sites choose JwtOnly or ChatGptAuth instead of passing a bare boolean
  • stores standalone Agent Identity JWT credentials separately from backend-registered Agent Identity records
  • persists the registered Agent Identity record, private key, and single run task id in auth.json so process restarts reuse the same identity
  • derives the agent/task registration base URL from ChatGPT/Codex auth config while keeping JWT JWKS lookup separate
  • provisions and caches ChatGPT-derived Agent Identity runtime auth when use_agent_identity is enabled
  • reuses the shared run-task registration helper from PR1 rather than adding a second task-registration path

This PR intentionally does not switch model inference over to AgentAssertion auth. The provider-auth integration lands in the next PR.

Testing

  • just test -p codex-login

@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-task-primitives branch from 3254ce5 to 0324e8a Compare April 23, 2026 01:02
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from 42e2d28 to 3192e48 Compare April 23, 2026 01:02
@adrian-openai adrian-openai changed the title feat: persist agent task session state feat: opt ChatGPT auth into agent task state Apr 23, 2026
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch 2 times, most recently from a4a465a to 92cf11e Compare April 23, 2026 03:55
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-task-primitives branch from 0324e8a to 2685c9e Compare April 23, 2026 03:55
@adrian-openai adrian-openai marked this pull request as ready for review April 23, 2026 04:27
@adrian-openai adrian-openai requested a review from a team as a code owner April 23, 2026 04:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92cf11ed3b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/agent/control.rs Outdated
RolloutItem::Compacted(_)
| RolloutItem::EventMsg(_)
| RolloutItem::SessionMeta(_)
| RolloutItem::SessionState(_) => true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Exclude SessionState from forked rollout history

keep_forked_rollout_item retains RolloutItem::SessionState, so a fork copies parent task-state lines into the child rollout. On a later resume, restore_persisted_agent_task replays the latest session-state entry and can restore the parent task_id into the forked thread, defeating independent task identity for forks.

Useful? React with 👍 / 👎.

@efrazer-oai

efrazer-oai commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

High level not sure we want to persist the task id in rollout state. Ik in initial reviews of the old stack i flagged this as problematic due to the deeper problem (having different tasks for same session id), but idt this is the solution we'd want long term.

Reasoning

It seems orthogonal/like a (potentially unstable) implementation detail that our deeper auth logic shouldn't care about, and we can't gate rollout item changes on feature flag. Rollout data really matters & we'd want to keep very good hygiene.

If we can, let's default to making task id ephemeral and shield it as much as possible from core session code.

Solution Musing

As a related note, it'd be so awesome if we could actually choose the task id name or establish some link between a session id and a task id. That way we get consistency backend-side rather than having to concern a lot of our app-server code with this stuff.

Suggestion

So in the AuthEnum stack, we have pretty much everything related to auth abstracted into the 'Auth' provider. Almost every call basically only has to say 'hey give me an auth provider and have that inject headers'.

So I think what we can do when enabling agent-identity feature is adding a different auth provider. What'd be amazing as an abstraction is if we could store some of this ephemeral stuff in-memory on the auth object (e.g. hashmap of session ids to task ids) and basically have the provider take our 'auth' and potentially a session id hint.

@adrian-openai adrian-openai marked this pull request as draft April 24, 2026 00:05
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-task-primitives branch from 2685c9e to 55dced3 Compare April 24, 2026 02:57
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from 92cf11e to cfa9996 Compare April 24, 2026 02:57
@adrian-openai adrian-openai changed the title feat: opt ChatGPT auth into agent task state feat: opt ChatGPT auth into agent identity Apr 24, 2026
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch 5 times, most recently from ae79fa8 to 492eec5 Compare April 24, 2026 05:10
@adrian-openai adrian-openai marked this pull request as ready for review April 24, 2026 06:07
@adrian-openai adrian-openai requested review from efrazer-oai and pakrym-oai and removed request for efrazer-oai and pakrym-oai April 24, 2026 06:08
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-task-primitives branch from 03963fc to 8810088 Compare May 26, 2026 19:00
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from 6ffcd6e to 228cb99 Compare May 26, 2026 19:00
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-task-primitives branch from 8810088 to ef4a89f Compare June 3, 2026 02:07
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from 228cb99 to 994dfd3 Compare June 3, 2026 02:07
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-task-primitives branch from ef4a89f to 6b3e08d Compare June 9, 2026 19:43
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch 2 times, most recently from a07016b to 70afafb Compare June 9, 2026 20:05
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-task-primitives branch 2 times, most recently from 363df7e to 1d62ce5 Compare June 9, 2026 20:35
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from 70afafb to 0e340c9 Compare June 9, 2026 20:35
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-task-primitives branch from 1d62ce5 to f220d79 Compare June 9, 2026 21:01
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from 0e340c9 to d8a54ed Compare June 9, 2026 21:01
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-task-primitives branch from f220d79 to 134085f Compare June 9, 2026 23:37
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch 2 times, most recently from 2cc6695 to 76f7f2b Compare June 9, 2026 23:38
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-task-primitives branch from 134085f to d13cbcc Compare June 9, 2026 23:38
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from 76f7f2b to 82ac2e2 Compare June 10, 2026 01:36
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-task-primitives branch 3 times, most recently from 7026cbc to d7289e0 Compare June 10, 2026 03:16
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from 82ac2e2 to b280037 Compare June 10, 2026 03:16
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-task-primitives branch from d7289e0 to a83dc38 Compare June 10, 2026 04:07
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch 2 times, most recently from 54e0629 to a79c53b Compare June 10, 2026 04:15
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-task-primitives branch 2 times, most recently from 2b9ca9a to 7f15c05 Compare June 10, 2026 06:05
Comment thread codex-rs/login/src/auth/manager.rs Outdated
Comment thread codex-rs/login/src/auth/manager.rs Outdated
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.

4 participants