Agent wait tool (agent_wait)

Canonical URL: /docs/07_ai-agents-and-mcp/17_agent_wait_tool

MCP-backed chat agents (Support Agent, Platform Engineer Agent, Trace AI) can call the agent_wait tool to pause inside an active tool loop without ending the chat turn. Users see a live progress message (and optional countdown fields) while the agent waits for external work to settle.

Document information
FieldValue
Version (published date)2026-05-25
Tagsai, mcp, agents, tool-loop

What it does

BehaviorDescription
In-loop pauseThe agent calls agent_wait, the platform sleeps for a bounded number of seconds, then returns a tool result so the model can continue with more tools in the same user message.
User feedbackParameter user_message is shown in the chat progress panel. During streaming, the UI may receive periodic tool_progress updates with remaining time.
Policy capsDeployments enforce per-call max seconds, per-turn total wait, max calls per turn, and a per-user rate limit (see operations below).

When agents should use it

Use agent_waitUse something else
Short gap between arbitrary tool steps (rate limits, queue drain, “let external system catch up”)execute_tenant_integration when waiting for a configured integration run to finish
Bounded delay before the next lookup or writeEnding the turn with “I’ll check back later” (stops the tool loop)
Transparent pause with a clear user-facing messageShell sleep or ad-hoc command-runner delays

Tool parameters

ParameterRequiredDescription
secondsYesInteger seconds to wait (capped by deployment policy, typically 1–60 per call).
user_messageYesPlain-language status shown to the user while waiting (present tense).
reasonNoOptional internal note for audit logs.

Models may also set progress_indicator on any tool call (including agent_wait); the chat runtime uses it for progress text when present.

Example (conceptual)

{
  "action": "agent_wait",
  "progress_indicator": "Waiting for the webhook queue to drain before fetching results.",
  "parameters": {
    "seconds": 20,
    "user_message": "Waiting for the webhook queue to drain before fetching results."
  }
}

After the wait completes, the tool result includes waited_seconds and resume_at. The agent should then call the next tool or give a final answer.

Streaming events

When chat streaming is enabled, the client may receive:

SSE typeWhen
tool_callWait starts
tool_progressInitial message and ~1s heartbeats with optional remaining_seconds, wait_until
tool_resultWait finished
chunk / completeFinal assistant reply

See Platform Agent SSE contract for field details.

Operations and configuration

Requires TOOL_CALL_LOOP_ENABLED=1 on the API deployment and the agent_wait row active in mcp_resources (migration 122_add_agent_wait_mcp_tool.sql).

Environment variableTypical defaultPurpose
AGENT_WAIT_ENABLEDtrueKill switch for the handler
AGENT_WAIT_MAX_SECONDS_PER_CALL7200 (2h)Max seconds per invocation (capped by chat turn budget)
AGENT_WAIT_MAX_SECONDS_PER_TURN14400 (4h)Max total wait per user message / tool loop
CHAT_AGENT_TURN_TIMEOUT_MS14400000 (4h)Overall turn wall clock (parent budget for waits and tools)
AGENT_WAIT_MAX_CALLS_PER_TURN5Max agent_wait calls per loop
AGENT_WAIT_HEARTBEAT_INTERVAL_MS1000Progress heartbeat interval
AGENT_WAIT_RATE_LIMIT_PER_USER_PER_MINUTE30Abuse guard per user

Full list: backend-next configuration guide.

Limitations

  • Waits are synchronous inside the HTTP request handling the chat turn. Multi-hour waits are supported when CHAT_AGENT_TURN_TIMEOUT_MS and your reverse proxy allow it; use async integrations when work should continue after the HTTP connection closes.
  • Per-user rate limiting uses an in-process counter on each API instance (sufficient for typical single-node or low fan-out; not a global cluster quota).
  • Each agent_wait consumes one tool-loop iteration toward TOOL_CALL_MAX_ITERATIONS.

See also