> For the complete documentation index, see [llms.txt](https://docs.visdom.virtuslab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.visdom.virtuslab.com/visdom-tracing/getting-started/how-it-works.md). Agents can also search and read this documentation through its [MCP server](https://docs.visdom.virtuslab.com/~gitbook/mcp).

# How it works

The three ways activity reaches Visdom AI Tracing, what the server does with it, and where each piece runs.

Visdom AI Tracing is a server with a web app and a command-line tool. Agent activity reaches the server by up to three paths, ends up in one ledger of sessions, model calls and commits, and is shown, checked and — with signing turned on — sealed there.

```mermaid
flowchart LR
  subgraph dev["Developer machine or CI runner"]
    agent["Coding agent<br/>Claude Code, Codex, GSD, OpenCode"]
    cli["tracevault CLI<br/>agent hooks + git hooks"]
    agent -- "hook events" --> cli
  end
  gw["Visdom AI Gateway"]
  subgraph server["Visdom AI Tracing"]
    api["Server<br/>ingest, policies, analytics, sealing"]
    proxy["LLM proxy<br/>/proxy/anthropic, /proxy/openai"]
    web["Web app"]
    db[("PostgreSQL")]
    api --- db
    proxy --- db
    web --> api
  end
  cli -- "sessions, commits, policy checks" --> api
  agent -. "model calls (optional)" .-> proxy
  proxy -. "forwarded" .-> llm["Model provider"]
  gw -- "signed records of model and tool calls" --> api
```

## Three capture paths

| Path                  | What sends                                                                 | What it records                                                                                                                     | Set up with                                                                                                                                                                     |
| --------------------- | -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Hooks**             | The `tracevault` CLI, called by the agent's own hooks and by two git hooks | Sessions: transcript, tool calls, file changes, tokens and cost derived from the transcript; commits with their diff                | `tracevault init` in a repository, or `tracevault init --global` — see [Capturing agent work](https://docs.visdom.virtuslab.com/visdom-tracing/capturing-agent-work/capture.md) |
| **LLM proxy**         | The agent itself, pointed at AI Tracing instead of the provider            | One ledger row per model call with tokens and cost; optionally the transcript                                                       | A base URL and a credential in the agent's settings — see [LLM proxy](https://docs.visdom.virtuslab.com/visdom-tracing/llm-proxy/llm-proxy.md)                                  |
| **AI Gateway ingest** | Visdom AI Gateway, for every call routed through it                        | The gateway's signed records; model calls become ledger rows with the gateway's cost, and with content capture, session transcripts | Server settings on both sides — see [AI Gateway](https://docs.visdom.virtuslab.com/visdom-tracing/visdom-platform/ai-gateway.md)                                                |

Hooks are the primary path: they see what the agent did in the repository, not only what it asked the model. The proxy and the gateway add a per-call view of spend that does not depend on the agent's transcript. All three can run at once; `AI_TRACING_USAGE_SOURCE` decides whether the analytics count hook data, proxy data or both (with duplicates removed).

## What the server does with it

* **Stores and attributes.** Every session belongs to a repository and, through it, to a project; proxy and gateway calls can carry a project of their own. Commits are matched to the sessions that produced their lines.
* **Prices.** Tokens are priced from a table synced daily from LiteLLM's public price list, with manual overrides — see [Pricing](https://docs.visdom.virtuslab.com/visdom-tracing/operations/pricing.md). Gateway calls keep the cost the gateway computed.
* **Evaluates policies.** Rules set per repository are injected into the agent's context, checked before a push and checked again in CI — see [Policies and verification](https://docs.visdom.virtuslab.com/visdom-tracing/policies-and-verification/policies.md).
* **Seals.** With signing turned on, commits are hash-chained and signed with Ed25519, sessions are signed when they end, and gateway records are chained in order — see [Signing and the chain](https://docs.visdom.virtuslab.com/visdom-tracing/evidence-and-compliance/signing-and-the-chain.md).
* **Answers questions.** Analytics, the dashboard, a line-level attribution view, and a Chat that searches past sessions in plain language.

## Where it runs

| Component     | What it is                                                                                                               | Default port |
| ------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------ |
| Server        | One Rust binary: the API, the LLM proxy, ingest, background jobs (pricing sync, session sealing sweep, repository fetch) | 3000         |
| Web app       | SvelteKit app that talks to the server through its own `/api` path                                                       | 4000         |
| PostgreSQL    | All state; the `pgvector` extension, when present, enables Chat's search index                                           | 5432         |
| Keycloak      | Signs people and services in (OIDC); usually the Visdom platform's realm                                                 | —            |
| Control Plane | Optional, inside the Visdom platform: people's grants, projects and repositories                                         | —            |
| CLI           | `tracevault` on each developer machine and CI runner                                                                     | —            |

The server clones the registered repositories it needs for the code browser and attribution, into a directory of its own. Details are in [Deployment](https://docs.visdom.virtuslab.com/visdom-tracing/operations/deployment.md).
