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

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Run agent

> Starts a session and resumes after its first turn idles or terminates.

`anthropic.runAgent` starts a session and resumes after its first turn idles or terminates.

## Example

```ts automations/anthropic-run-agent.automation.ts theme={null}
import { automation, onInvocation, withPrerequisites } from "automate.ax"
import { anthropic } from "automate.ax/anthropic"

export default automation("Run agent", () => {
  withPrerequisites(onInvocation(), () => {
    anthropic.runAgent({
      agent: "agent-id",
      environmentId: "environment-id",
      initialEvents: [
        {
          type: "user.message",
          content: [{ type: "text", text: "Review the repository." }],
        },
      ],
    })
  })
})
```

## Inputs

Accepts the same input as `startSession`, but requires 1–50 `initialEvents` items so the session starts work. The optional `account` must be a static connection name or account reference because the action and callback subscriptions share it. Configure the Anthropic Console webhook before deploying. Inputs use public camelCase names and accept signals.

## Output and behavior

Returns a durable signal classified as `completed`, `requiresAction`, `budgetReached`, `retriesExhausted`, or `terminated`. The callback is an independent root correlated by session ID.

Anthropic requests time out before the action lease and provider mutations are not retried after an uncertain response unless stated otherwise.
