> ## 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.

# 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.
</Note>

## 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](./agent-sdk-tools)
* [Control agent runs](./agent-sdk-run-controls)
* [Build a durable agent loop](../../cookbook/agent-sdk-durable-loop.mdx)
