Skip to main content
Clarify enables agents to pause mid-task and ask focused questions instead of guessing, improving decision accuracy and user control.
The user gives a vague request; the agent uses clarify before acting.
Interactive CLI users get this automatically. Running praison "prompt" or praisonai tui launch now includes clarify in the default toolset (the new clarify group in Interactive Tools). No manual tools=[clarify] needed. The tool is auto-gated on a live interactive TTY, and withheld in headless / non-TTY / CI / JSON runs so scripted runs never block — the core best-judgment fallback then handles ambiguity. Set PRAISON_TOOLS_DISABLE=clarify, PRAISON_NO_CLARIFY=1, or ToolConfig(enable_clarify=False) to opt out.

Behavior by Surface

clarify behaves differently on each surface.

Quick Start

1

Enable Clarify

2

With Custom Handler


How It Works


Channel Integration

CLI Usage

Bot Usage

On a bot turn clarify is already wired. The bot session binds a turn-scoped handler automatically, so no handler setup is needed. When the agent calls clarify(...):
  1. The question and choices are recorded for this turn’s reply.
  2. The agent is told to end its turn by restating the question instead of guessing.
  3. If the agent did not emit its own MessagePresentation, the choices are attached as MessagePresentation.question(question, choices) and render as native reply buttons.
  4. The user’s tap or typed reply arrives as the next turn’s input.
create_bot_clarify_handler(send_message_fn, wait_for_reply_fn) is not what bot sessions use. BotSessionManager.chat holds the per-user turn lock for the whole turn, and the user’s reply arrives as another chat() for the same user, so a blocking “send and wait” deadlocks. Keep the factory for callers that have their own lock-free send-and-wait mechanism.

Custom Surfaces: set_clarify_handler

Bind a handler for one turn on any surface you own, such as a web UI or a custom chat adapter.
  • The binding is turn-scoped (a ContextVar), so concurrent asyncio tasks never see each other’s handlers.
  • An explicitly configured handler (ClarifyTool(handler=...) or ctx["clarify_handler"]) still wins. The bound handler is used only by the shared default clarify instance.
  • Always call reset_clarify_handler(token) in a finally block.

Custom Context Handler


Handler Resolution

The tool resolves the handler in this order:
  1. Context handler: kwargs["ctx"]["clarify_handler"] (highest priority)
  2. Explicit tool handler: ClarifyTool(handler=...)
  3. Bound handler: set with set_clarify_handler(...), used only when the tool has no explicit handler
  4. Default: ClarifyHandler() returns the best-judgment fallback string

Configuration Options

Tool Schema

Bot Auto-Approval

The clarify tool is included in the bot’s default auto-approve list, so it won’t require manual approval in bot environments.

Common Patterns

Progressive Clarification

Context-Aware Questions

Fallback Behavior

The "No interactive channel" string is returned only when no handler is configured and none is bound, which means a truly headless run.
On a bot turn the fallback string never appears, so a branch that keys off "no interactive channel" does not fire there. Use it as a headless-only default.

Best Practices

Only call clarify when you genuinely cannot proceed without user input. Don’t ask for preferences that have reasonable defaults.Good: “Which API endpoint format?” when building an API Bad: “Should I use descriptive variable names?” (obvious default)
When possible, offer specific choices rather than open-ended questions.Good: choices=["fastapi", "flask", "django"] Bad: "What Python web framework should I use?" (no choices)
For headless runs, check if the response indicates no interactive channel and proceed with a sensible default.
Frame questions with enough context for users to make informed decisions.Good: “Which authentication method for your user API?” Bad: “Which auth?” (unclear context)

Ask Conversation

Ask another chat (not the current user) and wait for its reply

Tools Overview

Core tool system and custom tools

Agent Configuration

Agent setup and tool integration

Bot Default Tools

Tools every messaging bot gets out of the box

Gateway Status Tool

Report gateway health from inside a bot turn
How clarify plugs into the default praison "..." / TUI toolset and its TTY gating.