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

# How Belvedir Works

> The six-stage pipeline Belvedir uses: instrument, collect, segment, group, clean, and optimize.

1. **Instrument** — The SDK hooks into your LLM client libraries and captures every call, tool call, input, and output as an OpenTelemetry span.
2. **Collect** — Spans are batched and sent to the Belvedir platform via the OTLP HTTP protocol, tagged with the session id from `withSession`.
3. **Segment** — Once a session goes quiet, Claude reads the full transcript and splits it into the discrete tasks the agent performed — each with a title, summary, tool calls, and outcome.
4. **Group** — Each task is embedded and grouped with other tasks of the same type, so you can see how often each kind of task runs and how it performs over time.
5. **Clean** — A periodic pass keeps your groups clean: it merges duplicates, splits overbroad ones, and renames unclear labels. Every operation it considers is recorded on the platform's Cleaning log.
6. **Optimize** — Each loop you enabled on the project improves a different layer: prompt evolution runs GEPA over your system prompts, the memory harness improves the scaffolding and what the agent knows going into each call, and LoRA finetuning trains adapters on your traces (see [Model Training](/training/overview)). Run Analysis on a project evolves your agent's code against its own production traces. By default the proposed changes wait on the project page for your review — inspect the per-file diff, then approve to open a GitHub PR or reject. Switch the project's optimizer autonomy to Auto-PR to skip the review step. Connect the Belvedir GitHub App under Settings so the optimizer can open PRs on your repos.
