Skip to content

Bug: request_user_input is registered in model tool definitions even when unavailable in Default mode or non-root subagent threads #64530

Backlog

Description

@zsicheng0214

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:

  1. the current collaboration mode (ModeKind::Default, including headless codex exec) is not in request_user_input_available_modes(features), or
  2. turn_context.root_capabilities_restricted is true (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)

  1. 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 RequestUserInputAsyncHandler right below at line 1281-1282 already gates on !turn_context.root_capabilities_restricted, whereas RequestUserInputHandler at line 1272 checks neither !turn_context.root_capabilities_restricted nor whether turn_context.collaboration_mode().mode is in available_modes.

  2. 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

  1. Run codex exec --json (Default collaboration mode, experimental_request_user_input_enabled = true, default feature flags where available_modes only contains ModeKind::Plan) on an underspecified prompt that encourages asking the user a clarifying question.
  2. Observe that request_user_input is exposed in the tool schema sent to the model.
  3. The model invokes request_user_input and 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_input from the registered tool definitions when turn_context.root_capabilities_restricted is true (matching RequestUserInputAsyncHandler on line 1282).
  • Omit request_user_input (or gate its visibility) when turn_context.collaboration_mode().mode is not in request_user_input_available_modes(features) — especially in non-interactive codex exec / Default mode 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

  1. added
    bug
    CLI
    tool-calls
    exec
    subagent
    on Nov 29, 2026
  2. akhil9tiet commented on Nov 29, 2026

    @akhil9tiet

    I'm interested in working on this — please assign it to me.

  3. akhil9tiet commented on Nov 29, 2026

    @akhil9tiet

    I traced the mechanism against the code on main. In codex-rs/core/src/tools/spec_plan.rs, RequestUserInputHandler is registered whenever experimental_request_user_input_enabled is true, with no check of root_capabilities_restricted or of whether the current mode is in request_user_input_available_modes(features). The sibling RequestUserInputAsyncHandler registered 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 RequestUserInputHandler registration in spec_plan.rs — skip it when turn_context.root_capabilities_restricted is true, and when the collaboration mode is not in request_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-mode codex exec --json tool schema must not contain request_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.

  4. removed
    exec
    on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIbugsubagenttool-calls

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions