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

# Agent Configuration

> TOML config reference for RL agents

Agents are configured with TOML files in `.tenet/agents/`. Each file defines one agent with its metric, eval script, scope, and constraints.

## Basic Example

```toml .tenet/agents/test-coverage.toml theme={null}
[agent]
name = "test-coverage"
scope = "tests"
metric = "coverage_percent"
direction = "maximize"
time_budget_seconds = 600
rounds = 10
target_repo = "../my-service"
description = "Add tests for uncovered files. Focus on src/ files with 0% coverage first."

[eval]
script = "eval/test-coverage.sh"
data = "eval/fixtures/test-coverage-baseline.jsonl"

[constraints]
scope_files = ["src/**/*.ts", "src/**/__tests__/*.test.ts"]
max_file_changes = 5
```

## Reference

### `[agent]` Section

| Field                 | Type   | Required | Description                                            |
| --------------------- | ------ | -------- | ------------------------------------------------------ |
| `name`                | string | ✅        | Unique agent identifier                                |
| `scope`               | string | ✅        | Category (tests, quality, performance, product)        |
| `metric`              | string | ✅        | Primary metric name (must match eval script output)    |
| `direction`           | string | ✅        | `"maximize"` or `"minimize"`                           |
| `time_budget_seconds` | number | ✅        | Max time per round                                     |
| `rounds`              | number |          | Default rounds per session (overridable via CLI)       |
| `target_repo`         | string |          | Relative path to target repo (for cross-repo agents)   |
| `description`         | string |          | Instructions for the agent — what to do, what to avoid |

### `[eval]` Section

| Field    | Type   | Required | Description                                    |
| -------- | ------ | -------- | ---------------------------------------------- |
| `script` | string | ✅        | Path to eval script (relative to project root) |
| `data`   | string | ✅        | Path to eval fixtures/baseline data            |

### `[constraints]` Section

| Field              | Type      | Description                                  |
| ------------------ | --------- | -------------------------------------------- |
| `scope_files`      | string\[] | Glob patterns for files the agent can modify |
| `files_in_scope`   | string\[] | Additional file patterns (broader scope)     |
| `files_readonly`   | string\[] | Files the agent must NOT modify              |
| `max_file_changes` | number    | Maximum files changed per round              |

### `[policy]` Section (Advanced)

| Field              | Type   | Default | Description                         |
| ------------------ | ------ | ------- | ----------------------------------- |
| `embedding_model`  | string | auto    | Model for state embeddings          |
| `exploration_rate` | number | 0.2     | Initial exploration rate (ε-greedy) |
| `decay_per_round`  | number | 0.004   | Exploration decay per round         |
| `min_exploration`  | number | 0.05    | Minimum exploration rate            |

### `[context_scope]` Section

| Field      | Type      | Description                                                    |
| ---------- | --------- | -------------------------------------------------------------- |
| `produces` | string\[] | Events this agent emits (e.g., `"perf:cli-improved"`)          |
| `consumes` | string\[] | Events this agent reacts to (e.g., `"telemetry:metric-alert"`) |

## Full Example (CLI Speed Agent)

```toml .tenet/agents/tenet-cli-speed.toml theme={null}
[agent]
name = "tenet-cli-speed"
scope = "performance"
metric = "p90_ms"
direction = "minimize"
time_budget_seconds = 180
rounds = 50
target_repo = "../tenet-cli"

[eval]
script = "eval/cli-speed.sh"
data = "eval/fixtures/cli-speed-baseline.jsonl"

[constraints]
scope_files = [
    "src/index.ts",
    "src/commands/status.ts",
    "src/commands/doctor.ts",
    "src/lib/service-detector.ts",
    "src/utils/cache.ts",
]
files_in_scope = ["src/commands/**/*.ts", "src/lib/**/*.ts"]
files_readonly = ["eval/**", "node_modules/**", "dist/**"]
max_file_changes = 3

[policy]
exploration_rate = 0.2
decay_per_round = 0.004
min_exploration = 0.05

[context_scope]
produces = ["perf:cli-improved", "perf:latency-reduced"]
consumes = ["telemetry:metric-alert", "code:refactored"]
```

## Creating an Agent Interactively

```bash theme={null}
tenet peter agent create
```

This walks you through setting up name, metric, eval script, and scope.

## Listing Agents

```bash theme={null}
tenet peter agent list
```

```
  Configured Agents

  test-coverage
    Scope: tests
    Metric: coverage_percent (maximize)
    Time budget: 600s
    Files: src/**/*.ts, src/**/__tests__/*.test.ts

  cli-speed
    Scope: performance
    Metric: p90_ms (minimize)
    Time budget: 180s
    Files: src/index.ts, src/commands/status.ts, ...
```

## Archiving Agents

Move dead agents to `.tenet/agents/_archived/`:

```bash theme={null}
mv .tenet/agents/old-agent.toml .tenet/agents/_archived/
```

Archived agents are ignored by the nightly loop and `agent list`.
