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

# Chat vs. agent runs

> Understand the difference between chats, agents, runs, and agent-run chats.

A chat is a conversation. An agent is a saved configuration. An **agent run** is one execution of that configuration—and every run has an associated chat that stores its conversation and output.

## Four terms that matter

| Term               | What it is                                                                             | How long it lives                        |
| ------------------ | -------------------------------------------------------------------------------------- | ---------------------------------------- |
| **Chat**           | An ad-hoc conversation against a knowledge base                                        | Until deleted                            |
| **Agent**          | A saved, versioned goal, instructions, model, KB, and capabilities                     | Across many runs                         |
| **Agent run**      | One execution of an agent, with status, usage, output, and a pinned core configuration | One task or continued agent conversation |
| **Agent-run chat** | The messages and partial/final output associated with a run                            | Stored with the run                      |

## Choose chat or agent

Use a **chat** to explore, ask one-off questions, or change Quick/Deep mode per turn. Use an **agent run** when the work should follow a saved goal and capability set, be attributable to an agent version, appear in run history, or run on a schedule.

<CardGroup cols={2}>
  <Card title="Use chat" icon="comments">
    Exploration, ordinary Q\&A, changing topics, or choosing Quick/Deep per message.
  </Card>

  <Card title="Use an agent run" icon="play">
    Repeatable jobs, tool use, delegation, scheduling, monitoring, and auditable execution history.
  </Card>
</CardGroup>

## What happens during an agent run

<Steps>
  <Step title="Start">
    Sending an agent message creates a run and its associated chat. The run records the agent version and trigger type.
  </Step>

  <Step title="Execute">
    The agent always uses Deep mode and can search its KB, use enabled tools and skills, query data, or delegate.
  </Step>

  <Step title="Persist">
    Messages, sources, usage, tool-aware history, and partial or final output are stored with the chat and run.
  </Step>

  <Step title="Finish">
    The run becomes `completed`, `failed`, or `cancelled`. Queued and active work use `queued` and `running`.
  </Step>
</Steps>

```text theme={null}
Agent configuration
      │
      ▼
Agent run ─────────► status + usage + output
      │
      └────────────► associated chat ─► messages + sources + context
```

## Continuing an agent run

The first agent message returns `chat_id` and `run_id`. Pass that `chat_id` on the next agent message to continue the same agent conversation and reuse its run.

<Note>
  Agent-run chats are kept with agent runs rather than mixed into the normal chat list. Open them from the agent's run history.
</Note>

## Version behavior

A run pins the agent's core goal, instructions, model, and tools when it starts. A later deploy does not rewrite an in-progress run. Skills resolve when the run begins, and delegated agents resolve when called, so a run is attributable to its pinned core configuration without promising identical model output.

## Build it with the API

Create a normal chat:

```bash theme={null}
curl -X POST "$AUTOSAGE_URL/chats" \
  -H "Authorization: Bearer $AUTOSAGE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "CHAT_UUID",
    "tenant_id": "TENANT_ID",
    "knowledge_base_id": "KB_ID",
    "model": "MODEL_ID",
    "message": "What changed in the returns policy?",
    "agent_mode": "quick"
  }'
```

Start an agent run:

```bash theme={null}
curl -X POST "$AUTOSAGE_URL/agents/AGENT_ID/messages" \
  -H "Authorization: Bearer $AUTOSAGE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "message": "Review the returns policy and identify support risks." }'
```

Continue it with the returned chat:

```bash theme={null}
curl -X POST "$AUTOSAGE_URL/agents/AGENT_ID/messages" \
  -H "Authorization: Bearer $AUTOSAGE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Turn those risks into an action list.",
    "chat_id": "AGENT_CHAT_ID"
  }'
```

## Continue the learning path

<CardGroup cols={2}>
  <Card title="Share context between KBs" icon="share-nodes" href="/guides/share-context-between-kbs">
    Let this run ask a specialist agent in another KB.
  </Card>

  <Card title="Agent lifecycle" icon="arrows-spin" href="/developers/lifecycles/agent-lifecycle">
    See versions, schedules, stopping, and terminal states in depth.
  </Card>
</CardGroup>
