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

# Refinement

> How /refine improves the agent from its own trajectory without rewriting the base prompt.

Fleet Prime Agent gets better over time by refining its **supplemental harness state** — a layer of guidance stored alongside the immutable base prompt. `/refine` is how you trigger a refinement pass.

## What a refinement pass does

When you run `/refine` inside a session, the harness:

1. **Reads the trajectory** — the messages, tool calls, and outcomes of the current run.
2. **Extracts evidence** — what worked, what didn't, and what patterns the model reached for repeatedly.
3. **Proposes updates** to supplemental state, backed by concrete evidence pointers.
4. **Snapshots the previous state** so any change can be rolled back.
5. **Applies the update** to supplemental state only. The base system prompt is never touched.

## Why the base prompt is immutable

The base prompt is the contract: it defines what the agent is, what tools it has, what invariants it must uphold. Rewriting it makes behavior drift unrecoverably. Refinement adds layered guidance on top instead — you can inspect it, roll it back, or throw it away.

## Rollback

Every `/refine` pass writes a snapshot. If a refinement made things worse, roll back to the previous snapshot and try again.

## Compaction is the sibling mechanism

Refinement updates guidance. **Compaction** trims context. When a session grows too long for the model's context window, the compaction pipeline (`compact`, `calculateContextTokens`, `prepareBranchEntries`) produces a shorter transcript that keeps the important entries. See [Sessions](/fleet-prime-agent/concepts/sessions) for the storage side and [Refinement guide](/fleet-prime-agent/guides/refinement) for how to use `/refine` in practice.
