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

# avatar.context

ContextBuilder — the compact per-turn working packet (§9).

Assembles only what the model needs *this* turn: goal, phase, recent evidence
(summaries, most-recent-first-budgeted), and the tools allowed for the current
phase. The model discovers the repo incrementally through tools; it never
receives the whole repository by default.

## Classes

### `ContextBuilder`

Builds the per-turn `ContextPacket` from `TaskState` under a fixed budget (§9).

Evidence is compacted *less-lossily* (Phase 2.5): recent items keep full detail
until a char budget is spent, older items degrade to their summary line (not
dropped), the last N verifier outputs are pinned verbatim, and adjacent duplicates
collapse to one `... (xN)` line. Action history is cheap (one line each) so it is
kept on a longer horizon than evidence.

Args:
detail\_char\_budget: Total chars of evidence *detail* shown verbatim before
older items degrade to summary-only.
max\_detail\_chars: Per-item detail truncation budget.
max\_evidence\_lines: Hard cap on rendered evidence lines (newest kept).
max\_actions: Max prior-action lines to surface.
verifier\_pin\_count: How many recent verifier outputs keep detail verbatim
regardless of budget — a repair loop needs its recent failure history,
not just the latest verdict.

```python theme={null}
ContextBuilder(detail_char_budget: int = 48000, max_detail_chars: int = 16000, max_evidence_lines: int = 40, max_actions: int = 25, verifier_pin_count: int = 2) -> None
```

#### `ContextBuilder.build(self, state: TaskState, ws: Workspace, registry: ToolRegistry) -> ContextPacket`

Assemble the working packet for the current turn from `state` (§9).

Args:
state: The task state, source of truth for the packet.
ws: The run-scoped `Workspace` handle.
registry: The `ToolRegistry`, for phase-active tools.

Returns:
The `ContextPacket` for this turn.

### `ContextPacket`

The compact, per-turn working set assembled for one model decision (§9).

```python theme={null}
ContextPacket(*, goal: str, constraints: list[str] = <factory>, conversation: list[ConversationTurn] = <factory>, phase: str, task_kind: str = 'investigate', plan: list[str] = <factory>, files_read: list[str] = <factory>, files_modified: list[str] = <factory>, prior_actions: list[str] = <factory>, recent_evidence: list[str] = <factory>, allowed_tools: list[ToolSummary] = <factory>, latest_error: str | None = None, has_uncommitted_changes: bool = False) -> None
```

**Fields**

| Field                     | Type                     | Required |    |
| ------------------------- | ------------------------ | -------- | -- |
| `goal`                    | `str`                    | yes      |    |
| `constraints`             | `list[str]`              | no       |    |
| `conversation`            | `list[ConversationTurn]` | no       |    |
| `phase`                   | `str`                    | yes      |    |
| `task_kind`               | `str`                    | no       |    |
| `plan`                    | `list[str]`              | no       |    |
| `files_read`              | `list[str]`              | no       |    |
| `files_modified`          | `list[str]`              | no       |    |
| `prior_actions`           | `list[str]`              | no       |    |
| `recent_evidence`         | `list[str]`              | no       |    |
| `allowed_tools`           | `list[ToolSummary]`      | no       |    |
| `latest_error`            | \`str                    | None\`   | no |
| `has_uncommitted_changes` | `bool`                   | no       |    |

### `ToolSummary`

A tool's name, description, and input schema, as shown to the model.

```python theme={null}
ToolSummary(*, name: str, description: str, input_schema: dict = <factory>) -> None
```

**Fields**

| Field          | Type   | Required |
| -------------- | ------ | -------- |
| `name`         | `str`  | yes      |
| `description`  | `str`  | yes      |
| `input_schema` | `dict` | no       |
