Skip to content

Load cloud requirements for agent identity#19708

Open
shijie-oai wants to merge 3 commits intodev/efrazer/agent-identity-jwt-verifyfrom
shijie/agent-identity-cloud-requirements
Open

Load cloud requirements for agent identity#19708
shijie-oai wants to merge 3 commits intodev/efrazer/agent-identity-jwt-verifyfrom
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
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants