Skip to content

Load cloud requirements for agent identity#19708

Merged
shijie-oai merged 2 commits into
mainfrom
shijie/agent-identity-cloud-requirements
Apr 28, 2026
Merged

Load cloud requirements for agent identity#19708
shijie-oai merged 2 commits into
mainfrom
shijie/agent-identity-cloud-requirements

Conversation

@shijie-oai
Copy link
Copy Markdown
Collaborator

@shijie-oai shijie-oai commented Apr 26, 2026

Why

Agent Identity sessions can represent Business and Enterprise ChatGPT workspaces, but cloud requirements were skipped before fetch. That meant workspace-managed requirements were not loaded for Agent Identity even when the JWT carried the same account identity and plan information that normal ChatGPT token auth exposes.

This PR now sits on top of the Agent Identity stack through #19764. Because #19763 moved task registration into Agent Identity auth loading, cloud requirements no longer needs a separate runtime-initialization step before building the backend client.

What changed

  • Stop skipping CodexAuth::AgentIdentity in the cloud requirements loader.
  • Share the cloud requirements eligibility check between startup load and background cache refresh.
  • Rely on eagerly loaded Agent Identity auth so backend requests can attach task-scoped AgentAssertion headers.
  • Decode Agent Identity JWT plan_type as the auth-layer plan type, then convert it through a shared auth::PlanType -> account::PlanType mapping.
  • Add the missing serde alias for the education plan string and add coverage for raw Agent Identity plan aliases such as hc and education.

Testing

  • cargo test -p codex-agent-identity -p codex-login -p codex-cloud-requirements -p codex-protocol

@shijie-oai shijie-oai marked this pull request as draft April 26, 2026 20:36
@shijie-oai shijie-oai force-pushed the shijie/agent-identity-cloud-requirements branch 2 times, most recently from 4f7f8ca to 202fc0d Compare April 27, 2026 19:38
Comment thread codex-rs/login/src/auth/manager.rs Outdated

pub async fn initialize_runtime(
&self,
_chatgpt_base_url: Option<String>,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not used.

Comment thread codex-rs/cloud-requirements/src/lib.rs Outdated
return Ok(None);
}
let Some(plan_type) = auth.account_plan_type() else {
let Some(auth) = self.auth_manager.auth_snapshot().await else {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The reason to auth_snapshot so that we are not getting a task identity because it is not necessary for us to use the exiting auth state to validate and apply the cloud requirements. Previously auth() failure would fail open even if the agent identity is tied to an enterprise or a business liked plan.

@shijie-oai shijie-oai marked this pull request as ready for review April 27, 2026 20:47
@shijie-oai shijie-oai force-pushed the shijie/agent-identity-cloud-requirements branch from f929847 to 0e04e40 Compare April 27, 2026 20:51
Copy link
Copy Markdown
Contributor

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

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: f929847f00

ℹ️ 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/cloud-requirements/src/lib.rs Outdated
Comment on lines +225 to +226
auth.initialize_runtime()
.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 Budget cloud fetch timeout for AgentIdentity setup

BackendRequirementsFetcher::fetch_requirements now performs auth.initialize_runtime() before the requirements request. Startup still applies a 15s overall timeout to self.fetch() (cloud-requirements/src/lib.rs), but agent task registration itself allows up to 30s (agent-identity/src/lib.rs). A registration that would succeed in 15–30s now deterministically times out and fails cloud requirements loading for eligible workspaces.

Useful? React with 👍 / 👎.

@shijie-oai shijie-oai marked this pull request as draft April 27, 2026 22:49
@shijie-oai shijie-oai force-pushed the shijie/agent-identity-cloud-requirements branch from 0e04e40 to be8ae40 Compare April 27, 2026 23:06
@shijie-oai shijie-oai changed the base branch from main to dev/efrazer/agent-identity-jwt-verify April 27, 2026 23:06
let Some(auth) = self.auth_manager.auth().await else {
return Ok(None);
};
if matches!(auth, CodexAuth::AgentIdentity(_)) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

For agent identities - we would like to fetch cloud requirements as expected.

@shijie-oai shijie-oai marked this pull request as ready for review April 27, 2026 23:13
Comment thread codex-rs/login/src/auth/auth_tests.rs Outdated
signed_agent_identity_jwt_with_plan_type(record, json!(record.plan_type))
}

fn signed_agent_identity_jwt_with_plan_type(
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.

Let's just make signed_agent_identity_jwt accept PlanType instead of helper below, otherwise lgtm

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed

@efrazer-oai efrazer-oai force-pushed the dev/efrazer/agent-identity-jwt-verify branch from da21113 to 849b6c8 Compare April 28, 2026 01:51
@efrazer-oai efrazer-oai requested a review from a team as a code owner April 28, 2026 01:51
@efrazer-oai efrazer-oai force-pushed the dev/efrazer/agent-identity-jwt-verify branch 4 times, most recently from 1dabc3a to b1c8070 Compare April 28, 2026 03:24
@shijie-oai shijie-oai force-pushed the shijie/agent-identity-cloud-requirements branch 2 times, most recently from 9ab5e95 to 15be8ae Compare April 28, 2026 03:56
@efrazer-oai efrazer-oai force-pushed the dev/efrazer/agent-identity-jwt-verify branch 2 times, most recently from 5644ec2 to 0758599 Compare April 28, 2026 05:35
@efrazer-oai efrazer-oai force-pushed the dev/efrazer/agent-identity-jwt-verify branch from 0758599 to 09a65cb Compare April 28, 2026 15:19
@shijie-oai shijie-oai force-pushed the shijie/agent-identity-cloud-requirements branch from 15be8ae to 33f9d36 Compare April 28, 2026 16:21
Base automatically changed from dev/efrazer/agent-identity-jwt-verify to main April 28, 2026 16:56
@shijie-oai shijie-oai force-pushed the shijie/agent-identity-cloud-requirements branch 3 times, most recently from b9a0661 to f1721e0 Compare April 28, 2026 18:18
@shijie-oai shijie-oai force-pushed the shijie/agent-identity-cloud-requirements branch from f1721e0 to 2a9fad3 Compare April 28, 2026 18:29
@shijie-oai shijie-oai merged commit 25ac0e4 into main Apr 28, 2026
25 checks passed
@shijie-oai shijie-oai deleted the shijie/agent-identity-cloud-requirements branch April 28, 2026 19:35
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants