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

> ## Agent Instructions
> Phaseo Gateway base URL: https://api.phaseo.app/v1. Send `Authorization: Bearer $PHASEO_API_KEY` with every request.
> Model IDs look like `provider/model`, for example `openai/gpt-6-astra`. Do not guess IDs: list them with `GET /v1/models` or check https://phaseo.app/models. `phaseo/free` routes to an available free model and needs no wallet balance.
> For new text integrations prefer `POST /v1/responses`. `POST /v1/chat/completions` (OpenAI format) and `POST /v1/messages` (Anthropic format) suit existing code.
> The full API contract is https://phaseo.app/docs/openapi/v1/openapi.yaml. Official SDKs: `@phaseo/sdk` (TypeScript) and `phaseo` (Python), plus Go, C#, PHP, Ruby and Rust.
> Search these docs over MCP at https://phaseo.app/docs/mcp, and install Phaseo skills with `npx skills add https://phaseo.app/docs`. If a page is wrong or out of date, report it with the MCP `submit_feedback` tool.
> Manage Phaseo accounts with the `phaseo` CLI (`npm install -g @phaseo/cli`, then `phaseo login` or `phaseo login --device-code`), the `/v1` Management API or the MCP server at `https://mcp.phaseo.app/mcp?access=manage`. Do not send users to the dashboard for account tasks. A person is still needed for sign-up, approving a sign-in, paying the first top-up on the checkout link that `phaseo credits add` returns when no card is saved, confirming each saved-card top-up from the emailed link, and account security (password, MFA, passkeys). Create API keys with `phaseo keys create --name <name> --json`; never guess one. Credit top-ups need `phaseo login --scopes billing:write` first. Task map: https://phaseo.app/docs/v1/developers/manage-from-an-agent.md.

# State and approval

> Persist run state, approve tool calls, and continue paused agents.

Use continuation when an agent must wait for a person, external job, or application-owned tool before proceeding. The Agent SDK returns the complete run state required to continue later.

> [!NOTE]
>
> Phaseo does not persist Agent SDK runs in a hosted agent service. Store resumable run state in your own application when it must survive a request or process restart.

## Approve a tool call

Require approval only for calls that need it:

```typescript theme={null}
const deploy = defineTool({
  id: "deploy",
  requireApproval: ({ environment }) => environment === "production",
  async execute(input: { environment: string }) {
    return deployRelease(input.environment);
  },
});
```

The run pauses with pending calls in `run.pause.pendingToolCalls`. Resume by exact call ID so concurrent calls cannot be confused:

```typescript theme={null}
const resumed = await agent.continueRun({
  run: paused,
  client,
  approvals: [{ toolCallId: "call_deploy_42" }],
  rejections: [
    { toolCallId: "call_delete_17", reason: "Not authorized" },
  ],
});
```

## Pause for human review

Use `humanReview` when the completed model response should be checked before another turn begins:

```typescript theme={null}
const agent = createAgent({
  id: "support-agent",
  humanReview: ({ response }) =>
    response.message.content.includes("needs approval")
      ? {
          reason: "approval_required",
          payload: { draft: response.message.content },
        }
      : null,
});
```

Continue with explicit human input:

```typescript theme={null}
const continued = await agent.continueRun({
  run: pausedResult,
  client,
  humanInput: "Approved. Continue and return the final answer.",
});
```

## Persist run state

Persist the returned `AgentRunResult` directly, or provide a `state` accessor with asynchronous `load(runId)` and `save(result)` methods. A continued run can then use `runId` instead of passing the serialized record through every layer.

The SDK does not ship persistence adapters or a hosted state backend. Your application can keep one-shot runs in process and save only paused or incomplete runs.

## Related guides

* [Define and run tools](https://phaseo.app/docs/v1/sdk-reference/typescript/agent-sdk-tools.md)
* [Control agent runs](https://phaseo.app/docs/v1/sdk-reference/typescript/agent-sdk-run-controls.md)
* [Build a durable agent loop](https://phaseo.app/docs/v1/cookbook/agent-sdk-durable-loop.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.