feat(codex): surface non-blocking asks from request_user_input_async - #536
Merged
Merged
Conversation
Codex's app-server exposes a request_user_input_async tool to models whose catalog advertises it (the Codex desktop app's non-blocking ask). It does not send a server request. It completes an agentMessage item carrying `questions` and `delivery: "async"`, and the turn keeps running. The answer goes back as ordinary user input wrapped in Codex's <send_user_message_question_reply> envelope, keyed by the desktop app's question id JSON.stringify(["request_user_input_async", itemId, index]). - UserInputRequested gains `delivery` (Blocking by default, so existing logs and other providers are unchanged). - The Codex client turns such messages into an Async request. Open questions of the turn accumulate under the latest message id. Answers steer the running turn with the envelope, and the timeline shows the same plain "> question / answer" rendering the Codex TUI uses. The turn's end discards unanswered questions. - The timeline's pending request becomes a PendingUserInput struct that carries the delivery. - The composer keeps sending and steering while an async question is open. The panel explains that the agent keeps working and can be hidden on this client.
The request_user_input_async item's text only lists the questions the input panel already shows, so rendering it as an assistant message duplicated them in the timeline. The item now maps to a request_user_input_async tool call carrying the questions. Tool rows summarize a question tool by its first question, which covers Claude AskUserQuestion input as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
Codex's app-server (checked against codex-cli 0.156.1) exposes
request_user_input_asyncto models whose catalog advertises it. This is the non-blocking ask in the Codex desktop app. It is not a server request. The tool completes anagentMessageitem withquestions: [{title, options?}]anddelivery: "async", and the turn keeps running. The desktop app and the TUI answer with ordinary user input wrapped in<send_user_message_question_reply>[{answer, question, questionItemId}]</send_user_message_question_reply>. ThequestionItemIdisJSON.stringify(["request_user_input_async", itemId, index]).Tcode now surfaces it natively:
AgentEvent::UserInputRequestedgainsdelivery: UserInputDelivery(BlockingorAsync). It defaults toBlockingand is omitted when blocking, so persisted logs and the other providers are unchanged.agentMessagewithquestionsbecomes anAsyncrequest. The item itself is recorded as arequest_user_input_asynctool call, not assistant text, because its text only repeats the questions the panel shows. Tool rows summarize question tools by their first question. Open questions of a turn accumulate under the latest message id, so a second ask does not hide an unanswered first one.RespondUserInputsends aturn/steercarrying Codex's envelope. It emitsSteerRequestedwith the TUI's plain> question/ answer rendering, and the existing userMessage echo matching emitsSteerAccepted.turn/completeddiscards unanswered questions, as the TUI does.PendingUserInputstruct with the delivery, replacing the tuple.Tests
async_question_answers_steer_the_running_turn_with_codex_reply_envelopeuses the recorded item shape. It asserts the tool-call item, the question ids, the literalturn/steerenvelope, steer acceptance on the echo, and rejection once the turn has ended.user_input_delivery_is_async_only_when_recordedasserts that a legacy persisted event decodes as blocking and checks the literal async encoding.Checks run
cargo fmt --all --check,cargo clippy --workspace --all-targets --locked -- -D warnings,cargo nextest run --workspace --locked: all pass locally on macOS (941 tests).sleepruns, answering closes it and steers, and the close button hides it without stopping the turn.