Skip to main content
Human-in-the-loop tools pauses agent execution to request clarification or additional information from users. This enables interactive conversations where agents gather the specific details they need to complete tasks effectively.

Ask User for Input

The ask_user_for_input tool pauses agents to request clarification during a conversation. Agents decide when they need more information and ask users directly.

Enable the Tool

Add enable_ask_for_user_input=True when starting your agent:
images/main/main.py
images/main/Dockerfile
autonomy.yaml

How It Works

When an agent invokes ask_user_for_input:
  1. Agent pauses - The agent’s state transitions to "waiting_for_input"
  2. Question is returned - The streaming response completes with the agent’s question
  3. Conversation waits - The conversation remains paused until the user responds
  4. User responds - The next message from the user resumes the conversation
  5. Agent continues - The agent processes the response and continues its task

Example Flow

Initial request - User asks to book a flight:
Response includes waiting state:
User provides answer:
Agent continues the conversation:

Best Practices

Write Clear Instructions

Guide your agent when to ask for input:

Handle Multi-Step Workflows

Agents ask multiple questions to gather all necessary information:

Combine with Other Tools

Use ask_user_for_input alongside other tools for powerful workflows:

Client Integration

Streaming Responses

When using stream=true, check the phase field to detect when the agent waits:

Non-Streaming Responses

Without streaming, check the response status:

Conversation State

Waiting State

When an agent invokes ask_user_for_input:
  • Phase: "waiting_for_input"
  • Message: The agent’s question
  • Turn: The conversation remains on the same turn
  • Memory: The tool call and question are saved

Resume State

When the user responds:
  • Phase: "completed" (or other non-waiting state)
  • Message: The agent’s continued response
  • Turn: Advances to next turn
  • Memory: The user’s answer and agent’s continuation are saved

Example State Transition