Skip to content

Conversation

@motonari728
Copy link

@motonari728 motonari728 commented Nov 15, 2025

Problem

When executing commands like ls in Codex, approval requests are displayed on the mobile app, but selecting YES does not work. The command execution hangs waiting for approval, even though the user has approved the request.

Root Cause

The issue was an ID mismatch between the permission request registration and the permission response handling. This likely appeared after codex-cli version updates (verified with codex-cli 0.58.0):

  1. The elicitation handler in codexMcpClient.ts registered permission requests using codex_call_id
  2. The exec_approval_request event uses codex_mcp_tool_call_id as its call_id
  3. The mobile app sends permission responses using the callId from the tool-call message, which corresponds to codex_mcp_tool_call_id
  4. The permission handler looked up requests by the response ID, but couldn't find them because they were registered with a different ID (codex_call_id)

Solution

Changed the permission request registration to use codex_mcp_tool_call_id (with fallback to codex_call_id for backward compatibility) to match the ID that will be used in:

  • The exec_approval_request event's call_id
  • The tool-call message sent to the mobile app
  • The permission response from the mobile app

This ensures the permission response ID matches the registered permission request ID.

Changes

  • src/codex/codexMcpClient.ts: Use codex_mcp_tool_call_id instead of codex_call_id when registering permission requests
  • src/codex/__tests__/permissionApprovalFlow.test.ts: Added comprehensive tests for the permission approval flow

Testing

Test Results

$ yarn test src/codex/__tests__/permissionApprovalFlow.test.ts
✓ src/codex/__tests__/permissionApprovalFlow.test.ts (4 tests) 166ms
  ✓ should register permission request with correct ID and resolve when permission response matches
  ✓ should not resolve permission request when response ID does not match
  ✓ should handle permission denial correctly
  ✓ should handle multiple permission requests with different IDs

Type Check

$ yarn typecheck
✓ Type check passed

Manual Testing Steps

  1. Start daemon: happy daemon start
  2. Launch Codex from mobile app
  3. Select a folder and start Codex session
  4. Execute a command like ls that requires approval
  5. Approve the request on mobile app
  6. Verify the command executes successfully

Real Device Testing

Verified on real device: Approval flow (OK/NG) works correctly after this fix

  • Tested approval requests with YES/NO responses
  • Commands execute successfully when approved
  • Commands are properly denied when rejected

Note: This issue likely appeared after codex-cli version updates. Verified working with codex-cli 0.58.0.

Backward Compatibility

The fix includes a fallback to codex_call_id if codex_mcp_tool_call_id is not available, ensuring compatibility with older Codex versions or different deployment configurations.

Test Results

All tests related to this change pass:

  • permissionApprovalFlow.test.ts - All 4 tests pass
  • ✅ Type check passes

When executing commands like `ls` in Codex, approval requests were sent
but selecting YES didn't work because the permission response ID didn't
match the registered permission request ID.

The issue was that the elicitation handler registered permission requests
using `codex_call_id`, but the mobile app sends permission responses using
the `call_id` from `exec_approval_request` events, which corresponds to
`codex_mcp_tool_call_id`.

This fix changes the permission request registration to use
`codex_mcp_tool_call_id` (with fallback to `codex_call_id` for
compatibility) to match the ID that will be used in the tool-call message
and permission response.

Also adds comprehensive tests for the permission approval flow.
@motonari728 motonari728 marked this pull request as ready for review November 15, 2025 15:09
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.

1 participant