Implementation:0xranx OpenContext codex permission response
| Knowledge Sources | |
|---|---|
| Domains | AI_Agents, Security |
| Last Updated | 2026-10-24 12:00 GMT |
Overview
Concrete tool for sending user permission decisions back to Codex and ACP agents, enabling interactive tool call approval workflows.
Description
The codex_permission_response and acp_permission_response functions are Tauri commands that send the user's permission decision back to the agent process when it requests approval for a tool call (e.g., applying a patch, running a command).
codex_permission_response
Handles Codex MCP protocol permission requests. Two types:
- apply_patch_approval_request: The agent wants to apply code changes. The function retrieves stored patch changes from `codex_patch_changes`, sends an `apply_patch_approval_response` RPC request with the approval decision and changes.
- Other permission types: Uses the elicitation response mechanism to send "approved" or "denied" decisions.
acp_permission_response
Handles Claude and OpenCode ACP protocol permission requests. The function retrieves the stored request ID from `acp_permission_map`, then sends an RPC response with either a "selected" outcome (with option ID) or a "cancelled" outcome.
Usage
- Desktop Agent Chat: Called by the frontend when the user approves or denies a tool call permission dialog.
- Interactive workflow: Enables the "human-in-the-loop" pattern where agents ask for approval before executing potentially destructive actions.
Code Reference
Source Location
- Repository: OpenContext
- File: src-tauri/src/commands/agent.rs
Signature
#[derive(Deserialize)]
pub(crate) struct CodexPermissionResponseOptions {
#[serde(rename = "sessionId")]
session_id: String,
#[serde(rename = "callId")]
call_id: String,
#[serde(rename = "type")]
permission_type: String,
approved: bool,
}
#[tauri::command]
pub(crate) fn codex_permission_response(
state: State<AppState>,
options: CodexPermissionResponseOptions,
) -> CmdResult<()>;
#[derive(Deserialize)]
pub(crate) struct AcpPermissionResponseOptions {
#[serde(rename = "sessionId")]
session_id: String,
#[serde(rename = "callId")]
call_id: String,
#[serde(rename = "optionId")]
option_id: Option<String>,
}
#[tauri::command]
pub(crate) fn acp_permission_response(
state: State<AppState>,
options: AcpPermissionResponseOptions,
) -> CmdResult<()>;
Import (Tauri registration)
// Registered in src-tauri/src/main.rs:
tauri::generate_handler![
agent::codex_permission_response,
agent::acp_permission_response,
// ...
]
I/O Contract
Inputs (codex_permission_response)
| Name | Type | Required | Description |
|---|---|---|---|
| options.sessionId | String | Yes | Agent session ID |
| options.callId | String | Yes | Permission request call ID |
| options.type | String | Yes | Permission type (e.g., "apply_patch_approval_request") |
| options.approved | bool | Yes | Whether the user approved the action |
Inputs (acp_permission_response)
| Name | Type | Required | Description |
|---|---|---|---|
| options.sessionId | String | Yes | Agent session ID |
| options.callId | String | Yes | Permission request call ID |
| options.optionId | Option<String> | No | Selected option ID (None = cancelled) |
Outputs
| Name | Type | Description |
|---|---|---|
| returns | CmdResult<()> | Success or error |
Usage Examples
Approve a Codex Patch (Frontend)
import { invoke } from '@tauri-apps/api/core';
// User clicks "Approve" on the permission dialog
await invoke('codex_permission_response', {
options: {
sessionId: 'session-1',
callId: 'patch_001',
type: 'apply_patch_approval_request',
approved: true
}
});
Deny a Codex Permission
await invoke('codex_permission_response', {
options: {
sessionId: 'session-1',
callId: 'cmd_002',
type: 'command_approval',
approved: false
}
});
ACP Permission Response (Claude/OpenCode)
// Approve with selected option
await invoke('acp_permission_response', {
options: {
sessionId: 'session-1',
callId: 'call_003',
optionId: 'allow'
}
});
// Cancel
await invoke('acp_permission_response', {
options: {
sessionId: 'session-1',
callId: 'call_003',
optionId: null
}
});