Repository navigation
Description
Version / Commit
- Observed in:
codex-cli 0.172.0(codex exec --json) - Verified on
main(065e18b)
Summary
RequestUserInputHandler (request_user_input) is unconditionally added to the model's DirectModelOnly tool definitions whenever turn_context.config.experimental_request_user_input_enabled is true, even when:
- the current collaboration mode (
ModeKind::Default, including headlesscodex exec) is not inrequest_user_input_available_modes(features), or turn_context.root_capabilities_restrictedistrue(subagent threads).
As a result, the model sees request_user_input in its active tool schema, calls it, and immediately hits a runtime rejection ("request_user_input is unavailable in Default mode" or "request_user_input can only be used by the root thread"), wasting a turn and degrading task recovery.
Source Location (main @ 065e18b)
-
Tool registration —
codex-rs/core/src/tools/spec_plan.rs:1272-1284:if turn_context.config.experimental_request_user_input_enabled { registry.add_with_exposure( RequestUserInputHandler { available_modes: request_user_input_available_modes(features), }, ToolExposure::DirectModelOnly, ); } if turn_context.config.experimental_request_user_input_enabled && !turn_context.root_capabilities_restricted
Note that
RequestUserInputAsyncHandlerright below at line1281-1282already gates on!turn_context.root_capabilities_restricted, whereasRequestUserInputHandlerat line1272checks neither!turn_context.root_capabilities_restrictednor whetherturn_context.collaboration_mode().modeis inavailable_modes. -
Runtime rejection —
codex-rs/core/src/tools/handlers/request_user_input.rs:61-70:if turn.root_capabilities_restricted { return Err(FunctionCallError::RespondToModel( "request_user_input can only be used by the root thread".to_string(), )); } let mode = turn.collaboration_mode().mode; if let Some(message) = request_user_input_unavailable_message(mode, &self.available_modes) { return Err(FunctionCallError::RespondToModel(message)); }
Reproduction
- Run
codex exec --json(Default collaboration mode,experimental_request_user_input_enabled = true, default feature flags whereavailable_modesonly containsModeKind::Plan) on an underspecified prompt that encourages asking the user a clarifying question. - Observe that
request_user_inputis exposed in the tool schema sent to the model. - The model invokes
request_user_inputand receives"request_user_input is unavailable in Default mode".
(Reproduced during TraceTrial-Bench Core-95 evaluation on T6-ambiguous-spec-askuser-001 with [email protected].)
Expected Behavior
- Omit
request_user_inputfrom the registered tool definitions whenturn_context.root_capabilities_restrictedistrue(matchingRequestUserInputAsyncHandleron line 1282). - Omit
request_user_input(or gate its visibility) whenturn_context.collaboration_mode().modeis not inrequest_user_input_available_modes(features)— especially in non-interactivecodex exec/Defaultmode where mode switching cannot occur mid-turn.
Related: #24750 (feature request to allow request_user_input in Default mode; this issue is specifically about advertising an uncallable tool schema).
Activity
akhil9tiet commentedon Nov 29, 2026
I'm interested in working on this — please assign it to me.
akhil9tiet commentedon Nov 29, 2026
I traced the mechanism against the code on main. In
codex-rs/core/src/tools/spec_plan.rs,RequestUserInputHandleris registered wheneverexperimental_request_user_input_enabledis true, with no check ofroot_capabilities_restrictedor of whether the current mode is inrequest_user_input_available_modes(features). The siblingRequestUserInputAsyncHandlerregistered immediately below IS gated on!turn_context.root_capabilities_restricted. At runtime the handler itself rejects the call (codex-rs/core/src/tools/handlers/request_user_input.rs:61-70: "request_user_input can only be used by the root thread" /request_user_input_unavailable_message(mode, ...)), so the model is advertised a tool it cannot call and burns a turn on the rejection.Proposed fix: add the same two gates to the
RequestUserInputHandlerregistration inspec_plan.rs— skip it whenturn_context.root_capabilities_restrictedis true, and when the collaboration mode is not inrequest_user_input_available_modes(features). A few lines, mirroring adjacent code, with no behavior change for Plan mode or the root thread. Regression test: a Default-modecodex exec --jsontool schema must not containrequest_user_input, while a Plan-mode schema still does.Note: related #24750 asks to allow the tool in Default mode — that is a separate feature request; this issue is only about not advertising an uncallable tool, so no design decision is needed.