# gvn

gvn ("governor") is a Python framework for building **agent harnesses**. An *agent* is a
program that puts a language model in a loop: ask the model what to do next, do it, report
back, until the job is done. The *harness* is the code around the model that runs that loop:
it decides when to call the model, which tools (functions of yours) it may use, when a person
must approve, and what happens when something fails.

gvn builds complex workflows from verified parts. Each **actor**, such as an agent or a
workflow, owns its state and follows a **state machine**. A parent workflow can host an
actor and route its outcomes, while the actor keeps its internal states. gvn checks the
machine for gaps and checks how the workflow's stages connect before it runs.

## What makes it different

- **Verify each machine and its composition.** Every non-final state needs a route
  or fallback for every declared input. gvn refuses to build an incomplete machine and names
  the gap. A workflow plan also checks that its stages' outcomes have declared routes.
  [Workflow plan checks](concepts/workflows.md#deeper-what-a-plan-checks).
- **Encapsulate state.** A child keeps its own transcript, retries, and internal stages. The
  parent coordinates it using an agreed starting input and result.
  [Who owns what](concepts/workflows.md#who-owns-what).
- **Reuse tested actors.** A workflow can host an agent, an approval, or another workflow.
  The repository's release-desk example replaces a build workflow while keeping the parent
  routing and the public build contract. [Tested workflow replacement](guides/large-harnesses.md#the-repositorys-change-exercise).
- **Branch on declared outcomes.** A Decision can classify a model reply into one of a
  finite set of symbols. The verifier checks that the machine has a route for every symbol.
  [Decisions](concepts/decisions.md).
- **A run survives a crash and can wait days for a person.** Another process can replay its
  recorded history and resume pending work. A tool must deduplicate effects that might be
  reissued after a crash. [Runtime guarantees](reference/runtime-guarantees.md),
  [Durability](tutorials/durability.md), [Forking a run](guides/forking-a-run.md).
- **Set policy per tool call.** The policy judges calls individually. The agent can park
  on one approval request that covers several calls, and a person can approve or deny them.
  [An agent that asks first](tutorials/agent-with-approval.md).
- **Carry exposure and authenticated identity into decisions.** An agent records which
  untrusted tool sources entered its transcript and shares that record with policy and
  approval requests. The journal records the answering principal when the application
  supplies one.
  [Trust](concepts/trust.md).
- **Track model spending per run.** An allowance sets a journal-based interruption threshold
  for tokens, model calls, or cost. The reference agent suspends when interrupted and can
  resume under a larger allowance.
  [Spending and rate limits](guides/spending-and-rate-limits.md).
- **Verify compensation paths.** Declare which stages undo effects and which endings mean
  they were undone. gvn checks the routes to those endings. The application implements the
  undo operation itself.
  [Compensation](guides/compensation.md).
- **Tests run offline in milliseconds.** Every outside dependency has a stand-in, and a
  recorded run can be replayed against changed code. [Testing](tutorials/testing.md).

## gvn at a glance

One picture holds the whole design. An **actor** (an agent, a workflow, a conversation) is a
checked state machine that only decides. The **governor** drives it, hands the work it asks
for to **fulfillers** (the model, your tools, your policy), and records every event in the
**journal**.

```mermaid
flowchart LR
    you(["You, or your application"])
    person(["A person who approves"])
    subgraph run ["One run"]
        direction TB
        governor["<b>Governor</b><br/>drives the run"]
        actor["<b>Actor</b><br/>a verified state machine"]
        governor -- "event" --> actor
        actor -- "request" --> governor
    end
    fulfillers["<b>Fulfillers</b><br/>model · tools · policy"]
    journal[("<b>Journal</b><br/>every event, in order")]
    you -- "event: started" --> governor
    governor -- "request" --> fulfillers
    fulfillers -- "event" --> governor
    governor -- "records" --> journal
    governor -- "asks" --> person
    person -- "event: approved or denied" --> governor
```

The [quickstart](quickstart.md#the-big-picture) walks through this picture and then builds
each part.

## Find your way

1. [Install gvn](install.md#install-gvn) with `pip install gvn`.
2. [Run the order lookup](start.md#run-the-example) with one read-only tool and a scripted model.
3. [Take the quickstart](quickstart.md) to build a verified machine and run an agent on a real model.

| You want to | Go to | Time |
|---|---|---|
| Build a first checked machine | [Quickstart](quickstart.md) | 10 minutes |
| Learn it step by step, one idea at a time | [Tutorials](tutorials/index.md) | 10 to 20 minutes each |
| Understand the design behind the code | [Concepts](concepts/index.md) | read in order |
| Do a specific job: a real model, structured answers, running as a service | [Guides](guides/index.md) | as needed |
| Measure how well a version of your harness does its job, and compare two versions | [Evals](evals/index.md) | 10 minutes to start |
| See a harness drawn, step through its recorded runs, fork and answer them, and edit it, on a local page | [The Workbench](workbench/index.md) | 20 minutes to start |
| Give an agent files, a shell, git, the web, Jira Cloud, GitHub or any MCP server | [Tools](tools/index.md) | as needed |
| Read complete harnesses for real kinds of work | [Domains](domains/index.md) | as needed |
| Look something up: a term, an interface, how stored data is versioned | [Glossary](reference/glossary.md), [Reference](reference/architecture.md) | as needed |

## Is it for you?

gvn suits you if you want to keep a growing harness understandable by splitting it into
actors with explicit contracts and verified control flow. [Is gvn for you?](fit.md) explains
how this approach fits alongside other ways of building agents.
