Skip to content

Conversation

@owenlin0
Copy link
Contributor

@owenlin0 owenlin0 commented Nov 10, 2025

Define the API v2 interface for the server making a request to the client. This only happens when codex is requesting the user's approval for executing a command or writing a file.

In API v2, a single item/requestApproval RPC replaces both applyPatchApproval and execCommandApproval.

This PR only defines the interface. Implementation to follow.

@etraut-openai etraut-openai added the oai-pr PRs posted by Codex team members label Nov 10, 2025
@owenlin0 owenlin0 force-pushed the owen/v2_approval_request branch 2 times, most recently from d97e340 to 9a9fb99 Compare November 10, 2025 22:56
@owenlin0 owenlin0 marked this pull request as ready for review November 10, 2025 23:00
ExecCommandApproval {
params: v1::ExecCommandApprovalParams,
response: v1::ExecCommandApprovalResponse,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made some updates to the server_request_definitions macro - I like the explicitness of referencing the params and response structs, and it now mirrors client_request_definitions which does the same thing.

@owenlin0
Copy link
Contributor Author

@codex review this

@owenlin0 owenlin0 requested a review from pakrym-oai November 10, 2025 23:05
@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@owenlin0 owenlin0 force-pushed the owen/v2_approval_request branch from d4d19d3 to 94d51cc Compare November 10, 2025 23:18
#[serde(tag = "type", rename_all = "camelCase")]
#[ts(tag = "type")]
#[ts(export_to = "v2/")]
pub enum ItemApprovalRequest {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can this purely reference the item?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If not I think there is no point in having 1 event than has to have internal dispatch for each item type.

Copy link
Contributor Author

@owenlin0 owenlin0 Nov 10, 2025

Choose a reason for hiding this comment

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

So you're saying if we can do something like:

pub struct ItemRequestApprovalParams {
    pub thread_id: String,
    pub turn_id: String,
    pub item: ThreadItem,
}

then it's worth consolidating. If not, then we should have two methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The unfortunate thing about pub item: ThreadItem is that the type is too broad, in reality we only send approval requests for ThreadItem::CommandExecution and ThreadItem::FileChange.

This makes me lean towards having two separate methods actually

Copy link
Collaborator

Choose a reason for hiding this comment

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

then it's worth consolidating. If not, then we should have two methods?

Yeah, my initial goal was to have something like:

pub struct ItemRequestApprovalParams {
    pub thread_id: String,
    pub turn_id: String,
    pub item_id: String ,
}

and have all relevant information be on the item.

But having item_id + item type specific payload makes this annoying.

two separate methods actually

Then we'll have approvals for web searches, maybe mcp calls and who knows what. I don't think we'll stop on just two.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm yeah, neither seems ideal. Perhaps I'll go deeper on implementation to see if there's something clever we can do, I'm not super familiar with the underlying core event msgs yet and how they map to Items

#[ts(export_to = "v2/")]
pub struct FileEditRequest {
pub call_id: String,
pub file_changes: HashMap<PathBuf, FileChange>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

can this be inferred from the item?

pub file_changes: HashMap<PathBuf, FileChange>,
/// Optional explanatory reason (e.g. request for extra write access).
pub reason: Option<String>,
pub grant_root: Option<PathBuf>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this actually used in UI?

@owenlin0 owenlin0 force-pushed the owen/v2_approval_request branch from b140bf2 to 2c23e9d Compare November 12, 2025 23:34
@owenlin0 owenlin0 force-pushed the owen/v2_approval_request branch from 0c25da4 to 6ff6d9f Compare November 13, 2025 21:56
@owenlin0 owenlin0 force-pushed the owen/v2_approval_request branch from 0c5fa07 to 617d52b Compare November 14, 2025 05:15
@owenlin0 owenlin0 force-pushed the owen/v2_approval_request branch from 48ea385 to b379e86 Compare November 14, 2025 05:29
@owenlin0 owenlin0 closed this Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oai-pr PRs posted by Codex team members

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants