Skip to main content
Dynamic User Input lets the agent decide at runtime which fields it needs from the user by calling the get_user_input tool from UserControlFlowTools. The run pauses so the user can fill those fields; you then resume with continue_run_async(). Unlike static @tool(requires_user_input=True), the set of fields is not fixed at tool definition time—the agent constructs the request based on context (e.g. “I need the recipient email to send this”).

Quick Start

Core Concepts

Static vs Dynamic User Input

UserControlFlowTools

Register the toolkit so the agent can call get_user_input:
The agent will call get_user_input with a list of field names (and optional types/descriptions); the framework pauses and exposes user_input_schema on the requirement. Fill each field’s value and set requirement.tool_execution.answered = True, then resume.

Filling Dynamic Fields

Same pattern as static user input: iterate requirement.user_input_schema, set value, then set answered = True:

Multi-Round Behavior

The agent may request user input more than once in a single run (e.g. first recipient, then confirm subject). Use a while-loop until output is no longer paused or has no active requirements:

Continuation Methods

Resume with run_id (Same Agent) – While-Loop

Resume with task (Same Agent) – While-Loop

Resume with run_id (New Agent - Cross-Process)

Use a while-loop when resuming with a new agent; the agent may trigger multiple user-input pauses:

Using hitl_handler

Resolve the first pause manually, then pass hitl_handler so subsequent dynamic user-input pauses are filled automatically. If the agent only requests input once, a single continuation may be enough; for multi-round flows, you may still need a loop or multiple continuations with the handler:

Cross-Process Dynamic User Input

One process runs the agent and pauses; another (or same) fills the dynamically requested fields and resumes with a new agent:

Important Notes

  • Direct Call Mode Only: HITL continuation only supports direct call mode. Streaming is not supported for continuation.
  • Multi-Round: Prefer a while-loop (while output.is_paused and output.active_requirements) because the agent may call get_user_input multiple times in one run.
  • Requirements Parameter: When resuming with a new agent, always pass requirements=output.requirements so the filled schema is applied.
  • answered Flag: Set requirement.tool_execution.answered = True after filling all fields in user_input_schema.
  • Persistent Storage: For cross-process scenarios, use persistent storage (e.g. SqliteDatabase).
  • UserControlFlowTools: Must be included in the task’s tools list for the agent to have access to get_user_input.