Skip to content

feat: use run agent task auth for inference#19051

Open
adrian-openai wants to merge 1 commit into
dev/adrian/codex/hai-session-task-statefrom
dev/adrian/codex/hai-thread-inference-auth
Open

feat: use run agent task auth for inference#19051
adrian-openai wants to merge 1 commit into
dev/adrian/codex/hai-session-task-statefrom
dev/adrian/codex/hai-thread-inference-auth

Conversation

@adrian-openai

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

Copy link
Copy Markdown
Contributor

Stack

This is PR 3 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 moves Agent Identity usage into provider auth resolution. That keeps AgentAssertion auth tied to first-party OpenAI provider requests instead of applying a late session-wide override that could affect local, custom, Bedrock, API-key, or external-bearer providers.

What changed:

  • adds a small ProviderAuthScope struct carrying the run auth policy and session source needed by provider-scoped auth resolution
  • lets Session opt the existing ModelClient into ChatGptAuth policy when use_agent_identity is enabled, without adding a second model-client constructor
  • resolves Agent Identity only for first-party OpenAI provider auth paths
  • uses the persisted run task id from the AgentIdentityAuth record to build AgentAssertion auth for Responses requests
  • routes shared request setup through scoped provider auth so unary compact requests use the same run-task assertion path as inference turns
  • keeps local/custom/Bedrock/env-key/external-bearer provider auth unchanged
  • lets missing run-task state surface through the existing model-request error path instead of silently falling back to bearer auth

This PR intentionally does not create thread-scoped, target-scoped, or background-scoped task identities. The run task is the only task Codex registers in this POC shape.

Testing

  • just test -p codex-model-provider
  • just test -p codex-core client::tests::provider_auth_scope_uses
  • just test -p codex-core remote_compact_uses_agent_identity_assertion

@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 force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from a9a1b54 to 684fd95 Compare April 23, 2026 01:02
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from 3192e48 to a4a465a Compare April 23, 2026 03:48
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch 2 times, most recently from d5d5302 to 733de44 Compare April 23, 2026 03:55
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from a4a465a to 92cf11e 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: 733de4454c

ℹ️ 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/client.rs Outdated
Comment on lines +675 to +676
self.current_client_setup_with_agent_task(/*agent_task_auth*/ None)
.await

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 Pass thread task auth to compact Responses calls

ModelClient::current_client_setup always forwards agent_task_auth as None. compact_conversation_history (and other unary Responses paths) use this helper, so they never attach the thread-scoped AgentAssertion introduced for inference turns. In Agent Identity mode, compaction can run under bearer/process auth instead of the active thread task, which breaks the stated migration intent.

Useful? React with 👍 / 👎.

@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-session-task-state branch from 92cf11e to cfa9996 Compare April 24, 2026 02:57
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from 733de44 to a9fe062 Compare April 24, 2026 02:58
@adrian-openai adrian-openai changed the title feat: use thread agent task auth for inference feat: scope thread agent auth by provider Apr 24, 2026
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from a9fe062 to a3097aa Compare April 24, 2026 03:12
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from cfa9996 to c4397ce Compare April 24, 2026 04:19
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from a3097aa to c546eb2 Compare April 24, 2026 04:33
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from c4397ce to 9a439a1 Compare April 24, 2026 04:37
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from c546eb2 to c99bc2a Compare April 24, 2026 04:38
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from 9a439a1 to 44791c8 Compare April 24, 2026 04:47
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from c99bc2a to a9b1a6a Compare April 24, 2026 04:51
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from 44791c8 to ae79fa8 Compare April 24, 2026 04:59
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from a9b1a6a to 360838e Compare April 24, 2026 05:00
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from ae79fa8 to 492eec5 Compare April 24, 2026 05:10
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from 360838e to 6205dfe Compare April 24, 2026 05:11
@adrian-openai adrian-openai marked this pull request as ready for review April 24, 2026 06:07
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from 1c87e10 to aad6646 Compare May 18, 2026 19:45
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from e8f2da8 to 9809fae Compare May 18, 2026 20:39
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from aad6646 to d4cbe77 Compare May 18, 2026 20:39
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from 9809fae to ede0da1 Compare May 18, 2026 20:40
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from d4cbe77 to 6ffcd6e Compare May 18, 2026 20:40
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from ede0da1 to 1a9875e 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-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-thread-inference-auth branch from 1a9875e to ef49f07 Compare June 3, 2026 02:07
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from 994dfd3 to a07016b Compare June 9, 2026 19:43
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from ef49f07 to f272284 Compare June 9, 2026 19:43
@adrian-openai adrian-openai changed the title feat: scope thread agent auth by provider feat: use run agent task auth for inference Jun 9, 2026
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from f272284 to 264cc9f Compare June 9, 2026 20:05
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from a07016b to 70afafb Compare June 9, 2026 20:05
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from 264cc9f to efa1c37 Compare June 9, 2026 20:35
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch 2 times, most recently from 0e340c9 to d8a54ed Compare June 9, 2026 21:01
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch 2 times, most recently from 838c8d8 to 9d1b23d Compare June 9, 2026 23:37
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from d8a54ed to 2cc6695 Compare June 9, 2026 23:37
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from 9d1b23d to 892e12c Compare June 9, 2026 23:38
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-session-task-state branch from 2cc6695 to 76f7f2b Compare June 9, 2026 23:38
@adrian-openai adrian-openai force-pushed the dev/adrian/codex/hai-thread-inference-auth branch from 892e12c to c024f87 Compare June 10, 2026 01:36
@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
Comment thread codex-rs/core/src/session/session.rs Outdated
Comment thread codex-rs/core/src/session/session.rs Outdated
Comment thread codex-rs/model-provider/src/amazon_bedrock/mod.rs Outdated
Comment thread codex-rs/model-provider/src/models_endpoint.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.

2 participants