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

# Agents

> Create and manage workspace automations that run tasks and pause for human approval.

export const ErrorTable = ({errors}) => <div className="gv-error-table" role="table" aria-label="Errors and fixes">
    <div className="gv-error-table__head" role="row">
      <span className="gv-error-table__col-head" role="columnheader">Error</span>
      <span className="gv-error-table__col-head" role="columnheader">Cause</span>
      <span className="gv-error-table__col-head" role="columnheader">Fix</span>
    </div>
    {errors.map((err, i) => <div className="gv-error-table__row" role="row" key={i}>
        <code className="gv-error-table__code" role="cell">{err.code}</code>
        <div className="gv-error-table__cause" role="cell">{err.cause}</div>
        <div className="gv-error-table__fix" role="cell">{err.fix}</div>
      </div>)}
  </div>;

export const Def = ({term, type, defaultValue, required, children}) => <>
    <dt className="gv-def-list__term">
      <span className="gv-def-list__name">{term}</span>
      {type && <span className="gv-def-list__type">{type}</span>}
      {required && <span className="gv-def-list__required">required</span>}
      {defaultValue !== undefined && <span className="gv-def-list__default">
          default <code>{defaultValue}</code>
        </span>}
    </dt>
    <dd className="gv-def-list__description">{children}</dd>
  </>;

export const DefList = ({children}) => <dl className="gv-def-list">{children}</dl>;

export const ExpectedOutput = ({caption = "Expected output", children}) => <div className="gv-output">
    <div className="gv-output__label">
      <svg className="gv-output__icon" viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
        <polyline points="15 10 20 15 15 20" />
        <path d="M4 4v7a4 4 0 0 0 4 4h12" />
      </svg>
      <span>{caption}</span>
    </div>
    <div className="gv-output__body">{children}</div>
  </div>;

export const APIBadge = ({method = "GET", path, scope}) => {
  const m = method.toUpperCase();
  return <span className="gv-api-badge">
      <span className={`gv-api-badge__method gv-api-badge__method--${m.toLowerCase()}`}>
        {m}
      </span>
      <code className="gv-api-badge__path">{path}</code>
      {scope && <span className="gv-api-badge__scope">
          <span className="gv-api-badge__scope-label">scope</span>
          <code>{scope}</code>
        </span>}
    </span>;
};

export const Eyebrow = ({label, tone = "default"}) => <div className={`gv-eyebrow gv-eyebrow--${tone}`}>
    <span className="gv-eyebrow__bar" aria-hidden="true" />
    <span className="gv-eyebrow__label">{label}</span>
  </div>;

<Eyebrow label="RESOURCE" />

Agents are workspace-defined automations. Each agent runs a task on a schedule or on demand, and may pause mid-run to request human sign-off before continuing. Approval requests surface in the [Approvals](/api-reference/resources/approvals) queue. By the end of this page you will know which endpoints exist, the agent lifecycle, and what run statuses you can observe.

## An agent in shape

<ExpectedOutput>
  ```json theme={null}
  {
    "id":         "agt_01H...",
    "name":       "Nightly report",
    "status":     "active",
    "created_at": "2025-11-01T00:00:00Z"
  }
  ```
</ExpectedOutput>

## Endpoints

<APIBadge method="GET" path="/v1/workspaces/{slug}/agents" scope="agents:read" />

List all agents in a workspace.

<APIBadge method="POST" path="/v1/workspaces/{slug}/agents" scope="agents:write" />

Create a new agent (starts inactive).

<APIBadge method="GET" path="/v1/workspaces/{slug}/agents/{id}" scope="agents:read" />

Fetch a single agent by id.

<APIBadge method="POST" path="/v1/workspaces/{slug}/agents/{id}/activate" scope="agents:write" />

Activate the agent so it begins runs.

<APIBadge method="POST" path="/v1/workspaces/{slug}/agents/{id}/deactivate" scope="agents:write" />

Deactivate the agent — no new runs are started.

<APIBadge method="GET" path="/v1/workspaces/{slug}/agents/{id}/runs" scope="agents:read" />

Paginated run history for the agent.

## Lifecycle

<DefList>
  <Def term="inactive">The state every newly created agent starts in. No runs are scheduled.</Def>
  <Def term="active">The agent executes on its configured schedule or trigger.</Def>
</DefList>

Deactivating an agent stops new runs but lets in-flight runs complete. Pending approval records remain actionable.

## Run statuses

<DefList>
  <Def term="pending">Run scheduled but not yet started.</Def>
  <Def term="running">Currently executing.</Def>
  <Def term="awaiting_approval">Paused — an approval record is open in the [Approvals](/api-reference/resources/approvals) queue.</Def>
  <Def term="completed">Finished successfully.</Def>
  <Def term="failed">Terminated with an error.</Def>
  <Def term="denied">An approval request was denied; the run was stopped.</Def>
</DefList>

Run history is paginated newest-first: `GET /agents/{id}/runs` accepts `limit` (default 20, max 100) and `cursor`. See [Pagination](/api-reference/pagination) for the cursor protocol.

## Common errors

<ErrorTable
  errors={[
{ code: "404 not_found", cause: "No agent with that id exists in this workspace.", fix: "Verify the id and that the token can see the workspace." },
{ code: "403 insufficient_scope", cause: "Token lacks `agents:read` or `agents:write`.", fix: "Mint a token with the scope you need." },
]}
/>

## Related

<Card title="Approvals" icon="circle-check" href="/api-reference/resources/approvals">
  Review and action approval requests that agents surface during a run.
</Card>
