# How the agent works

> One agent for the whole household. Its parts, a turn step by step, its tools, and how its instructions are built.

Source: https://nestorhome.dev/docs/agent/

## The parts

The **core** depends on no vendor; everything else is an **adapter** behind a contract. A restart
rebuilds open conversations, tasks, reminders and undelivered messages from the
[journal](https://nestorhome.dev/docs/agent/journal/).

## A turn

A **conversation** groups turns close in time. Once it ends, the model no longer rereads it;
memories stay. Messages sent together are answered in order.

Aloud, Nestor speaks while the model still writes. Any word stops it, or 1.2 s of speech, except an
acknowledgement ("mm-hmm", "yeah", "ouais", "ok", in English or French). When the model or a voice service fails, Nestor says so
(`conversation.fallback`).

## Tools

A tool slower than the turn's wait goes on in the background, and Nestor tells the result later. A
long result is stored aside, read with `read_result` and `search_result`. Work of minutes goes to an [executor](https://nestorhome.dev/docs/executors/).

| Setting                                  | Default                     | What it does                            |
| ---------------------------------------- | --------------------------- | --------------------------------------- |
| `agent.spoken_tool_wait_s`               | 3                           | seconds a spoken turn waits for a tool  |
| `agent.written_tool_wait_s`              | 20                          | seconds a written turn waits for a tool |
| `agent.tool_result_chars`                | 8000                        | longer results are stored aside         |
| `conversation_ends_after_s`, per channel | 5 min aloud, 4 h in writing | silence that ends a conversation        |

## The instructions

The household layer also says how the agent runs right now (a web search on free tiers, say), from
each component's `notes()`. The agent mentions it when it bears on the request.

## Models by role

Point roles at profiles in `models`. A single model needs nothing more.

```yaml
models:
  quick:
    type: language
    provider: openai-compatible
    base_url: https://openrouter.ai/api/v1
    api_key: ${MODEL_API_KEY}
    model: anthropic/claude-haiku-5.5
  careful:
    type: language
    provider: openai-compatible
    base_url: https://openrouter.ai/api/v1
    api_key: ${MODEL_API_KEY}
    model: anthropic/claude-sonnet-5.5

agent:
  spoken: quick
  written: careful
```

| Role                   | Does                                     | When left out   |
| ---------------------- | ---------------------------------------- | --------------- |
| `agent.spoken`         | answers aloud                            | `agent.written` |
| `agent.written`        | answers in writing                       | `agent.spoken`  |
| `agent.titles`         | titles each chat                         | `agent.written` |
| `watches.model`        | sorts incoming items against the watches | `agent.written` |
| `memory.consolidation` | summarises each finished conversation    | `agent.written` |

All roles: [Models](https://nestorhome.dev/docs/models/).
