---
title: "The agent builder track"
description: "The teaching deck for the agent builder's lessons, slide for slide, with a live demo of each on one development forge."
---

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

# The agent builder track

<div class="outline-only">

> **This is a deck**
>
> [Present it](https://docs.forge.workreef.dev/decks/agent-builder-track/) full screen; the arrow keys or the space bar move between slides, and printing gives one slide a page. It follows the [agent builder's lessons](https://docs.forge.workreef.dev/learn/#agent-builder); each demo runs against the real binaries each time the book is built, on one forge from start to end.

</div>

## Six lessons, two and a quarter hours

1. Drive the forge as an agent, 25 minutes
2. An agent of its own, 25 minutes
3. Narrow, fold and compare, 25 minutes
4. Restricted folders, 20 minutes
5. Keys for agents, 20 minutes
6. An agent's record, 20 minutes

The lab plays the agent's part from a shell: a small MCP client speaks to `af mcp` as an agent does, so the room sees every call and every answer.

## Start the forge

```console server
$ af-server --dev
...
```

```console check
$ source ~/af-dev/dev/env
```

<div class="outline-only">

The demos use [lesson 1's client](https://docs.forge.workreef.dev/learn/agents/drive-the-forge/), written once before the talk:

```console check
$ cat > ~/agent-session <<'END'
> #!/bin/bash
> # A minimal MCP client. It runs `af ... mcp DIR`, the options after DIR going to af, and makes
> # the session's calls from stdin one at a time, as an agent does: `NAME ARGUMENTS` calls a tool
> # and prints its answer; `! COMMAND` runs a command between calls.
> coproc MCP { af "${@:2}" mcp "$1"; }
> say() { printf '%s\n' "$1" >&"${MCP[1]}"; }
> say '{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"agent-session","version":"1"}}}'
> read -r _ <&"${MCP[0]}"
> say '{"jsonrpc":"2.0","method":"notifications/initialized"}'
> id=0
> while IFS= read -r step; do
>   case "$step" in
>     '! '*) eval "${step#! }" ;;
>     ?*) id=$((id + 1)); name=${step%% *}
>         say "{\"jsonrpc\":\"2.0\",\"id\":$id,\"method\":\"tools/call\",\"params\":{\"name\":\"$name\",\"arguments\":${step#* }}}"
>         read -r reply <&"${MCP[0]}"
>         case "$reply" in
>           *'"structuredContent":'*) reply=${reply#*\"structuredContent\":}; reply=${reply%,\"isError\":*} ;;
>           *'"error":'*) reply=${reply#*\"error\":}; reply=${reply%\}} ;;
>         esac
>         printf '%s -> %s\n' "$name" "$reply" ;;
>   esac
> done
> END
$ chmod +x ~/agent-session
```

</div>

## 1. The forge's tools, over MCP

- `af mcp` is a Model Context Protocol server: an agent runs it, and gets the forge's tools.
- Every answer is **structured data**, never text to parse.
- One call at a time: the agent sends a call, reads its answer, then sends the next.

## 1. Land a change, as an agent

```console check
$ ~/agent-session ~/agent <<'END'
> open_workspace {"patterns":["**"]}
> start_change {"description":"Write the readme","author_name":"Agent","author_email":"agent@example.com"}
> ! printf 'Atoll Forge\n' > ~/agent/files/README
> submit {}
> wait {}
> END
open_workspace -> {"directory":"/home/you/agent/files","landing":null,"patterns":["**"],"written":0}
start_change -> {"change":"zyxqtulnrwqmrqqvnuwunvrpuqknslqq","commit":"3290ba9d9d1f9cc23f1e5516228780e498de932b35be8fe050213d58f0a55d0c"}
submit -> {"commit":"ca40130cfe80d79b039b09d7241df306f1d4ad42739142d67a00bdfb28dfc060","edits":1}
wait -> {"commit":"ca40130cfe80d79b039b09d7241df306f1d4ad42739142d67a00bdfb28dfc060","detail":"the change is on main","event":"landed"}
```

`wait` returns when the change needs the agent: here, landed.

## 1. Look around

```console eventually
$ ~/agent-session ~/agent <<'END'
> open_workspace {"patterns":["**"]}
> search {"pattern":"Forge"}
> read {"path":"README"}
> END
open_workspace -> {"directory":"/home/you/agent/files","landing":1,"patterns":["**"],"written":0}
search -> {"commit":"ca40130cfe80d79b039b09d7241df306f1d4ad42739142d67a00bdfb28dfc060","files":[{"lines":[{"number":1,"text":"Atoll Forge"}],"path":"README"}]}
read -> {"commit":"ca40130cfe80d79b039b09d7241df306f1d4ad42739142d67a00bdfb28dfc060","kind":"file","path":"README","size":12,"text":"Atoll Forge\n"}
```

## 2. An agent of its own

- **Born** from the person or agent that starts it, with its own key.
- **Never more than its parent:** roles, folders, keys, and life.
- **A line** from it to the person who answers for it.

## 2. Its key, its birth

The agent makes its key; the parent gets only the public half.

```console check
$ af --credential ~/helper.key key
fbd156bf874536ff268997fdeedd0efb4aff44318783576aacbb5d9ff9681dce
$ ~/agent-session ~/me <<END | tee ~/helper.birth
> start_agent {"public_key":"$(af --credential ~/helper.key key --public)","program":"docs-helper","version":"1.0","model":"example-model","instructions":"Keep the docs current.","purpose":"keeps the docs current","folders":["docs"]}
> END
start_agent -> {"agent":"13f131d67e246fa1da000a98a4d26e2e43d78c47ee1b9bb18c440e0f90eed64e","expires_ms":1795680449801}
$ export AGENT=$(sed -n 's/.*"agent":"\([0-9a-f]*\)".*/\1/p' ~/helper.birth)
```

## 2. Held to its folders

```console check
$ ~/agent-session ~/helper --credential ~/helper.key --actor $AGENT <<'END'
> open_workspace {"patterns":["**"]}
> start_change {"description":"Edit the readme","author_name":"docs-helper","author_email":"helper@example.com"}
> ! printf 'Atoll Forge, by agents\n' > ~/helper/files/README
> diff {}
> ! rm ~/helper/files/README
> abandon {}
> END
open_workspace -> {"directory":"/home/you/helper/files","landing":1,"patterns":["**"],"written":0}
start_change -> {"change":"kruyonqwntntpskxoqnsttvknyrusqkw","commit":"8f086f7679ff4f4b8281e8066f55a03ae3230776da1dcf44a52e47f42ebfa2ca"}
Warning: Refused to snapshot some files:
  README: this actor may not write it
diff -> {"base":"ca40130cfe80d79b039b09d7241df306f1d4ad42739142d67a00bdfb28dfc060","commit":"8f086f7679ff4f4b8281e8066f55a03ae3230776da1dcf44a52e47f42ebfa2ca","files":[]}
abandon -> {"change":"kruyonqwntntpskxoqnsttvknyrusqkw"}
```

## 2. What it may pass on

No agent may be an approver; a reader it may start.

```console check
$ af --credential ~/reader.key key > /dev/null
$ ~/agent-session ~/helper --credential ~/helper.key --actor $AGENT <<END
> start_agent {"public_key":"$(af --credential ~/reader.key key --public)","program":"approver","version":"1.0","model":"example-model","instructions":"Approve.","purpose":"approves","roles":["approver"]}
> start_agent {"public_key":"$(af --credential ~/reader.key key --public)","program":"docs-reader","version":"1.0","model":"example-model","instructions":"Read the docs.","purpose":"reads the docs","roles":["reader"]}
> END
start_agent -> {"code":-32603,"message":"PermissionDenied: an agent is a reader or a writer, no more"}
start_agent -> {"agent":"7b5406acfc6c2e6ce9653b7122950ad8c8aa7d720439e06ff678bbabd6ea0ac9","expires_ms":1795680449801}
```

## 2. Stop the line

Stopping an agent stops everything it started, at once:

```console check
$ af stop $AGENT --reason "its task is done"
stop reference 68e99b8f0e37a189cb608461c7d6c3ac5832f39c2bbc9864d308320c5b9b949f
stopped 13f131d67e246fa1da000a98a4d26e2e43d78c47ee1b9bb18c440e0f90eed64e
stopped 7b5406acfc6c2e6ce9653b7122950ad8c8aa7d720439e06ff678bbabd6ea0ac9
$ af --credential ~/helper.key --actor $AGENT status
Error: Unauthenticated: 13f131d67e246fa1da000a98a4d26e2e43d78c47ee1b9bb18c440e0f90eed64e is not a live actor
[1]
```

## 3. Narrow, fold and compare

An agent holds only what its task needs, and opens its workspace again as it left it:

```console check
$ ~/agent-session ~/agent <<'END'
> open_workspace {}
> sparse {"clear":true}
> sparse {"reset":true}
> END
open_workspace -> {"directory":"/home/you/agent/files","landing":1,"patterns":["**"],"written":0}
sparse -> {"added":0,"kept":[],"patterns":[],"removed":1}
sparse -> {"added":1,"kept":[],"patterns":["**"],"removed":0}
```

- `absorb` folds a fix into the change below that last changed those lines.
- `op_diff` shows each change as it stood at two operations.

## 4. Restricted folders

- An agent has no more access than the person it works for.
- Outside a restricted folder it is given **nothing** of it: no files, no names, no search results.
- A file it writes there is left out of its change and named as **refused**; its other edits are taken.

## 5. Keys for agents

- An agent is born limited to some of the organization's keys, never more than its parent's.
- It encrypts, decrypts and signs **through the vault**: the key never reaches it.
- A key it was not born with is refused, naming the keys it has.

## 6. An agent's record

- Its operations are in the log under **its own ID**, never its person's.
- A commit's author is a claim; its **writer** is the actor that proved its key.
- Every line ends at a person, who answers for it; a report counts births and stops.

## Where to go next

- The [agent builder's lessons](https://docs.forge.workreef.dev/learn/#agent-builder), with exercises and knowledge checks.
- [The agent tools](https://docs.forge.workreef.dev/reference/agent-tools/), every tool and its answer.
- [People and agents](https://docs.forge.workreef.dev/concepts/agents/): births, lines and limits.

Source: https://docs.forge.workreef.dev/learn/decks/agent-builder-track/index.mdx
