Bridge RequestUserInput events to ACP permission prompts#199
Bridge RequestUserInput events to ACP permission prompts#199c0st1nus wants to merge 1 commit intozed-industries:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a deadlock in codex-acp by handling EventMsg::RequestUserInput events, translating option-based user-input prompts into ACP request_permission(...) prompts, and mapping the selected option back into Op::UserInputAnswer so codex_core can resume MCP approval flow.
Changes:
- Added a new pending-interaction variant to track user-input requests and resolve them through the existing async permission-request flow.
- Implemented
RequestUserInputevent handling that converts option-based prompts into ACP permission requests and submitsOp::UserInputAnsweron resolution. - Added unit tests for the supported option-based path and the fail-closed unsupported-shape fallback.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Manual verification update: I tested this patch in Zed against the original failing scenario using a locally built Before this change, Codex ACP would accept the prompt, emit After this change, the same flow now proceeds correctly:
I verified it with the original repro shape: Result: Playwright now runs successfully in Zed and returns the expected output instead of hanging before tool invocation. |
Summary
This fixes a deadlock in
codex-acpwhencodex_corerequests pre-tool user input for MCP approvals.Previously,
EventMsg::RequestUserInputwas treated as an unexpected event in the ACP bridge. When that happened, core would wait indefinitely forOp::UserInputAnswer, so the turn could stall before anyMcpToolCallBeginevent was emitted.This change bridges option-based
RequestUserInputevents into ACPrequest_permission(...)prompts, then maps the selected ACP option back into theRequestUserInputResponseshape expected by core.What changed
EventMsg::RequestUserInputinsrc/thread.rs.RequestUserInputprompts into ACPrequest_permission(...)requests.codex_core, then submittedOp::UserInputAnswer.RequestUserInputshapes:if the request cannot be represented through ACP permission options,
codex-acpnow returns an empty response instead of hanging indefinitely.Op::UserInputAnswer.Why this fixes the issue
For MCP approvals,
codex_coremay request user input before it emitsMcpToolCallBegin. If the ACP bridge drops that request, core waits forever and the client only sees early events such asusage_update.With this patch:
RequestUserInputis surfaced to the ACP client as a permission prompt.Op::UserInputAnswer.Verification
test_request_user_input_uses_permission_requesttest_request_user_input_without_options_cancels_without_permission_promptcargo test test_request_user_input_cargo fmt --checkNotes
RequestUserInputshape used by the MCP approval flow.StreamErrorsilent-hang path.