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

# How it works

> Visceral only optimizes what it can prove is safe — and never makes anything worse.

Visceral sits beside your agent's LLM traffic. It does three things: **observe**,
**prove**, and **optimize** — strictly in that order.

## Observe

The SDK records each LLM call as an **event** — hashes, token counts, costs, model
names, and timing. Events are metadata only: no prompt or response text, no PII.
See [Privacy & data](/concepts/privacy) for exactly what leaves your process.

From this traffic Visceral reconstructs how your agent actually runs — which calls
depend on which, and where the same work happens over and over.

## Prove (the gate)

Before Visceral changes anything, a proposed optimization has to pass **the gate**:
Visceral must be able to demonstrate that the cheaper call produces an
output-equivalent result for the task at hand. An optimization that can't clear the
gate is never applied. This is what makes Visceral a performance engine rather than
a router — it doesn't gamble on "probably fine."

## Optimize

Only optimizations that clear the gate ship. And because Visceral **fails open**, a
backend outage or a degraded path doesn't stall or break your agent — it simply runs
as if Visceral weren't there.

<Note>
  The two invariants — **never change the agent's output** and **fail open** — are
  contracts, not aspirations. Everything else in the system is built to keep them true.
</Note>
