Skip to main content

Agent Run Workflows

The agent analyzes user input and automatically selects tools for execution. Some tools (plan / report / matrix) include Human-in-the-Loop (HITL) checkpoints that require human confirmation before proceeding. This page describes all execution patterns, their event flows, and the API operations needed at each state.

Common Flow

All executions start with the same pattern:

Tool Selection

The agent analyzes input via chat-routing and automatically selects from these tools:

Pattern 1: Direct Answer

The agent responds with text without using any tools.
API operation: None needed
API operation: None (fully automatic)

Pattern 3: browse (Browser Automation)

API operation: None. Use maxBrowsingSteps parameter to control the step limit.

When browse needs human input

Browse is usually fully automatic, but it can ask a human for help on login pages, cookie prompts, or pages where a decision is needed. This is different from the plan/report/matrix HITL flow.
Do not use /agent/run/{runId}/plan/answer or the other run HITL endpoints for this state. Use the websocketInfo.session_id from the browse-start event and answer through the browser control API.
Use /browser/answer-question-with-files when the answer needs files.
If the browser is active but not waiting for a question, use /browser/spontaneous-input to steer it. Examples: “Open the pricing page next” or “Do not submit that form.”
GET /agent/run/{runId}/status can show browseState.askHumanQuestion, so you can detect that the browser is waiting. The answer still requires sessionId; API clients should store browse-start.payload.websocketInfo.session_id when it appears in the SSE stream.

Pattern 4: skill (Sandbox Execution)

API operation: None (fully automatic)

Pattern 5: plan (Research Plan) — HITL

Step 1: Check status

Step 2: Confirmation action (choose one)

Answer questions to revise the draft:
→ A regenerated_plan event is returned, and the draft is pending review again. Confirm the plan:
plan_confirmed is returned. Skip questions and confirm:

Step 3: Resume execution

→ Research begins with search/browse/etc. tool events streaming.

Pattern 6: report (Report Generation) — HITL

Step 1: Check status

Step 2: Confirmation action

Answer questions:
Confirm:

Step 3: Resume → Automatic section generation


Pattern 7: matrix (Matrix Generation) — HITL

Step 1: Check status

Step 2: Confirmation action

Answer questions:
Confirm:

Step 3: Resume → Automatic data extraction


Compound Pattern: plan → report

A single execution may trigger multiple HITL checkpoints:
In this case, follow the resume → check pendingReportDraft → confirm → resume loop.

Status Quick Reference

Skill secret requests

When a skill needs external API keys or other secrets, the SSE stream emits skill-ask-secret, and GET /agent/run/{runId}/status exposes the missing keys in skillState.pendingSecretKeys.
Register each missing key through /secret.
Secret registration notifies the waiting skill, so you usually do not call /agent/run/stream/{runId} again. Keep reading the same SSE stream, or poll GET /agent/run/{runId}/status until pendingSecretKeys is empty.

Answering plan / report / matrix drafts

pendingPlanDraft, pendingReportDraft, and pendingMatrixDraft all mean that a draft is waiting for review. If you want changes, send feedback to /answer and review the regenerated draft. When the draft is acceptable, call /confirm, then resume execution with /agent/run/stream/{runId}.

/answer request body

Plan, Report, and Matrix /answer endpoints use the same body shape.
Example:

/confirm and /skip request body

Confirmation endpoints only need runId.
plan/skip means “confirm the plan without additional feedback.” Report and Matrix do not have skip endpoints.

Basic API Loop

plan, report, and matrix pause the whole agent run, so you resume with /agent/run/stream/{runId} after confirming. A browse question pauses the browser session, so answer with /browser/answer-question and let the same run continue.

Implementation Examples

Below are complete client implementations showing how to combine the API endpoints for the full agent lifecycle.

Simple Execution (No HITL)

For cases without HITL — direct answers, search, browse, or skill tools.

Full HITL Loop

Handles plan → report → matrix with multiple HITL confirmations.

Human-in-the-Loop Confirmation

Instead of auto-confirming, show questions to a human for decision.

Non-Streaming Polling Approach

Use non-streaming API with polling instead of SSE.

TypeScript Example