> ## Documentation Index
> Fetch the complete documentation index at: https://www.truefoundry.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Ask User Questions

> Let the agent ask structured multiple-choice questions and pause until the user answers.

Agents often hit decision points where they cannot make a safe assumption — which cluster to deploy to, whether a new environment is production, what an ambiguous field on a tool schema should be set to. Without a way to ask, the agent either guesses (and gets it wrong) or stalls with a free-form question that the UI cannot render as a first-class action.

Ask User Questions lets the harness pause the agent, surface a structured multiple-choice prompt to the user, and resume the run with the chosen answer once the user responds.

## A concrete use case

Suppose a user says **"Create a new environment called `testing-1`"** to an agent backed by the TrueFoundry MCP server. The `create_or_update_environment` tool requires fields like `isProduction` (boolean) and `optimizeFor` (`AVAILABILITY` or `COST`) that the user never specified.

A naive agent would either invent values or send back a wall of text asking for clarification. With `ask_user_question`, the agent instead inspects the tool schema, identifies the fields it cannot infer, and asks the user one structured question at a time:

<Frame caption="The agent inspects the tool schema, identifies that isProduction is required, and asks the user with concrete options instead of guessing">
  <img src="https://mintcdn.com/truefoundry/sRJHwFb35bXgeP_o/docs/agent-platform/agent-harness/images/agent-harness-ask-questions-1.png?fit=max&auto=format&n=sRJHwFb35bXgeP_o&q=85&s=9b749a5368e55d051596786953eb5e24" alt="Agent Playground showing the assistant summarizing the environment manifest schema and then asking 'Should this environment be a production environment?' with three options: Yes — mark it as Production, No — keep it as Non-production, and a free-form Other input" width="3018" height="1608" data-path="docs/agent-platform/agent-harness/images/agent-harness-ask-questions-1.png" />
</Frame>

Once the user picks an option, the question is locked in as `Answered` and the agent immediately asks the next required field — `optimizeFor` — with options drawn from the schema's allowed values:

<Frame caption="After the first question is answered, the agent asks the next clarifying question with options taken directly from the tool schema">
  <img src="https://mintcdn.com/truefoundry/sRJHwFb35bXgeP_o/docs/agent-platform/agent-harness/images/agent-harness-ask-questions-2.png?fit=max&auto=format&n=sRJHwFb35bXgeP_o&q=85&s=9da7bb1da0f86999efcb4f913a3db64e" alt="Agent Playground showing the previous question answered with 'No — keep it as Non-production' and a new question 'What should this environment be optimized for?' with options AVAILABILITY — prioritize uptime and reliability, COST — prioritize cost savings, and Other" width="3010" height="1598" data-path="docs/agent-platform/agent-harness/images/agent-harness-ask-questions-2.png" />
</Frame>

The agent only proceeds to call `create_or_update_environment` after every required clarification has a concrete answer — turning an ambiguous request into a deterministic, auditable sequence of decisions.

## How it works

The AI Gateway registers `ask_user_question` as a **client-side** tool. The server never executes it; instead, the harness emits `tool.response_required` and waits for your application to collect the user's choice and resume the run.

```mermaid theme={"dark"}
sequenceDiagram
    participant User
    participant Browser
    participant Harness as Agent Harness
    participant Model

    User->>Browser: Send message
    Browser->>Harness: responses.create
    Harness->>Model: LLM call
    rect rgba(255, 237, 153, 0.45)
        Model->>Harness: Tool call: ask_user_question
        Harness-->>Browser: tool.response_required
    end
    Browser->>User: Show question + options
    User->>Browser: Pick an option
    rect rgba(255, 237, 153, 0.45)
        Browser->>Harness: tool.client_side_response
        Harness->>Model: Tool response
    end
```

The user selects **one** of the listed options or types a free-form answer into the `Other` field. The agent receives the response as a regular tool result and continues from where it paused.

<Note>
  Sub-agents cannot ask the user questions. Only the root agent can call `ask_user_question` — sub-agents must resolve ambiguity from the context the root agent provides them.
</Note>

## When to use Ask User Questions

Use `ask_user_question` when the agent genuinely cannot proceed without a user decision and the answer comes from a small, enumerable set — for example:

* Choosing a target environment, cluster, account, or workspace
* Disambiguating between multiple matches (e.g. "I found 3 services named `api`, which one?")
* Resolving required tool-call fields that the user did not specify (booleans, enums, modes)
* Picking between alternative strategies before a destructive or expensive operation

<Note>
  Skip `ask_user_question` for decisions the agent can confidently infer from context, conversation history, or sensible defaults. Asking too often turns the agent into a form and breaks autonomy.
</Note>

## Example

<Steps>
  <Step title="User" icon={<svg viewBox="0 0 28 28"><rect width="28" height="28" rx="6" fill="#4f46e5"/><circle cx="14" cy="10" r="3.5" fill="#fff"/><path d="M7 23c0-3.3 3.1-6 7-6s7 2.7 7 6" fill="#fff"/></svg>} noAnchor>
    Create a new environment called `chirag-testing-1`.
  </Step>

  <Step title="Assistant" icon={<svg viewBox="0 0 28 28"><rect width="28" height="28" rx="6" fill="#10b981"/><rect x="8" y="11" width="12" height="10" rx="2" fill="#fff"/><circle cx="12" cy="15" r="1.5" fill="#10b981"/><circle cx="16" cy="15" r="1.5" fill="#10b981"/><rect x="13" y="5" width="2" height="6" rx="1" fill="#fff"/><circle cx="14" cy="4.5" r="1.5" fill="#fff"/></svg>} noAnchor>
    I need a couple of answers before creating it.

    <AccordionGroup>
      <Accordion title="ask_user_question" icon="wrench" defaultOpen>
        **Tool Call**

        ```json lines theme={"dark"}
        {
          "question": "Should this environment be a production environment?",
          "options": [
            "Yes — mark it as Production",
            "No — keep it as Non-production"
          ]
        }
        ```

        **Tool Response** — execution paused; answer required from client
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="User" icon={<svg viewBox="0 0 28 28"><rect width="28" height="28" rx="6" fill="#4f46e5"/><circle cx="14" cy="10" r="3.5" fill="#fff"/><path d="M7 23c0-3.3 3.1-6 7-6s7 2.7 7 6" fill="#fff"/></svg>} noAnchor>
    No — keep it as Non-production
  </Step>

  <Step title="Assistant" icon={<svg viewBox="0 0 28 28"><rect width="28" height="28" rx="6" fill="#10b981"/><rect x="8" y="11" width="12" height="10" rx="2" fill="#fff"/><circle cx="12" cy="15" r="1.5" fill="#10b981"/><circle cx="16" cy="15" r="1.5" fill="#10b981"/><rect x="13" y="5" width="2" height="6" rx="1" fill="#fff"/><circle cx="14" cy="4.5" r="1.5" fill="#fff"/></svg>} noAnchor>
    <AccordionGroup>
      <Accordion title="ask_user_question" icon="wrench" defaultOpen>
        **Tool Call**

        ```json lines theme={"dark"}
        {
          "question": "What should this environment be optimized for?",
          "options": [
            "AVAILABILITY — prioritize uptime and reliability",
            "COST — prioritize cost savings"
          ]
        }
        ```

        **Tool Response** — execution paused; answer required from client
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="User" icon={<svg viewBox="0 0 28 28"><rect width="28" height="28" rx="6" fill="#4f46e5"/><circle cx="14" cy="10" r="3.5" fill="#fff"/><path d="M7 23c0-3.3 3.1-6 7-6s7 2.7 7 6" fill="#fff"/></svg>} noAnchor>
    COST — prioritize cost savings
  </Step>

  <Step title="Assistant" icon={<svg viewBox="0 0 28 28"><rect width="28" height="28" rx="6" fill="#10b981"/><rect x="8" y="11" width="12" height="10" rx="2" fill="#fff"/><circle cx="12" cy="15" r="1.5" fill="#10b981"/><circle cx="16" cy="15" r="1.5" fill="#10b981"/><rect x="13" y="5" width="2" height="6" rx="1" fill="#fff"/><circle cx="14" cy="4.5" r="1.5" fill="#fff"/></svg>} noAnchor>
    Creating environment **chirag-testing-1** (non-production, optimized for COST) …
  </Step>
</Steps>

## Handling questions from the API

Handle `tool.response_required`, send `tool.client_side_response` with the user's choice, and continue the run with `previous_response_id`.

For the streaming events, JSON payloads, and a full client implementation, see [Turn events — ToolResponseRequiredEvent](/docs/agent-platform/agent-harness/sdk/turn-events-reference#toolresponserequiredevent).
