Skip to content

Agent lesson 6: An agent's record

Read what an agent did and who answers for it - its operations in the log under its own ID, its changes written by it, its birth and line in the compliance report, and its stop.

Time: 20 minutes. Track: agent builder. Before this: agent lesson 2.

By the end of this lesson you will be able to:

  • find an agent’s operations in the repository’s log, under its own ID;
  • tell who wrote a change, and who answers for the one who did;
  • read an agent’s birth and stop in a compliance report.

An agent at work

Start a forge, and an agent of its own, as in lesson 2, limited to docs:

$ af-server --dev
...
$ source ~/af-dev/dev/env
$ cat > ~/agent-session <<'END'
> #!/bin/bash
> 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
$ af --credential ~/helper.key key
5619891c924d30fe94129d4e454c82ca7e9b28f1c6cd77f223883eabc1b50ea2
$ ~/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":"99a9cb1fdeefba444e43a5354fecf4d1f4c585093250f167f69dc7e423070c5f","expires_ms":1795705579998}
$ export AGENT=$(sed -n 's/.*"agent":"\([0-9a-f]*\)".*/\1/p' ~/helper.birth)
$ ~/agent-session ~/helper --credential ~/helper.key --actor $AGENT <<'END'
> open_workspace {"patterns":["**"]}
> start_change {"description":"Start the docs","author_name":"docs-helper","author_email":"helper@example.com"}
> ! mkdir -p ~/helper/files/docs && printf '# Docs\n' > ~/helper/files/docs/index.md
> submit {}
> wait {}
> END
open_workspace -> {"directory":"/home/you/helper/files","landing":null,"patterns":["**"],"written":0}
start_change -> {"change":"kmssvptrymstrnmrkulumytqnlsvttlu","commit":"a2b59e51545617c6c6c34faf90c1f3c286b44c1f16470279cdb9228c73bb36ce"}
submit -> {"commit":"d98547f8b30543e9149aedc3440473a30c0efd1e543cd5046b5a91bf3d4ae035","edits":1}
wait -> {"commit":"d98547f8b30543e9149aedc3440473a30c0efd1e543cd5046b5a91bf3d4ae035","detail":"the change is on main","event":"landed"}

What the log says

Every write is an operation in the repository’s log, by whoever made it. The agent’s are under its own ID, shown by its start, never under yours; the landing is the forge’s own:

$ af op log -n 3
8fe571a38d93  2026-11-25T15:06:25.075Z  land by the forge
    kmssvptrymstrnmrkulumytqnlsvttlu
6313b22a156b  2026-11-25T15:06:25.043Z  snapshot by 99a9cb1fdeef
    kmssvptrymstrnmrkulumytqnlsvttlu
2532086cea1e  2026-11-25T15:06:25.035Z  start by 99a9cb1fdeef
    kmssvptrymstrnmrkulumytqnlsvttlu

Who wrote it, and who answers for it

The commit’s author is what the agent said it was, helper@example.com: a claim, as in git. Who wrote it is not a claim: the forge records the writer of every change as the actor that proved its key, here the agent, and the agent’s birth record names its parent, you. However many agents sit between, every line ends at a person, who answers for all of it:

$ af log -r main
○  kmssvptr helper@example.com 2026-11-25T15:06:25Z d98547f8
│  Start the docs
~

In the report

A compliance report counts every agent born in its period, each from a person or an agent, each line ending at a person, and how many were stopped:

$ af report iso27001 --from 2026-01-01T00:00:00Z --to 2100-01-01T00:00:00Z --out ~/report
wrote /home/you/report/iso27001-report.json and /home/you/report/iso27001-report.html; the report's receipt is entry 4 of the log
$ grep -o '[0-9]* agents\? born[^"\\]*' ~/report/iso27001-report.json | sort -u
1 agent born, each from a person or an agent, each line ending at a person; 0 stopped.

The report is itself a receipt in the forge’s log, so what it says of the period can be checked against the log later.

Stop it

Its task done, stop it. A stop ends its line at once: it and every agent it started can act no more, and the report says so:

$ af stop $AGENT --reason "its task is done"
stop reference 4be1a068dcd4190d63d8f604963082a53345a632e4f1a5c00426ef2b26e5a6d7
stopped 99a9cb1fdeefba444e43a5354fecf4d1f4c585093250f167f69dc7e423070c5f
$ af report iso27001 --from 2026-01-01T00:00:00Z --to 2100-01-01T00:00:00Z --out ~/after
wrote /home/you/after/iso27001-report.json and /home/you/after/iso27001-report.html; the report's receipt is entry 6 of the log
$ grep -o '[0-9]* agents\? born[^"\\]*' ~/after/iso27001-report.json | sort -u
1 agent born, each from a person or an agent, each line ending at a person; 1 stopped.

Exercises

  1. Count the operations the agent made, by the start of its ID.

    $ af op log | grep -c "by ${AGENT:0:12}"
    2
  2. The agent is stopped. Can it still act, with its key and its ID?

    $ af --credential ~/helper.key --actor $AGENT status
    Error: Unauthenticated: 99a9cb1fdeefba444e43a5354fecf4d1f4c585093250f167f69dc7e423070c5f is not a live actor
    [1]

Check your understanding

The commit says its author is helper@example.com. Who wrote it?

The agent: the forge records as a change’s writer the actor that proved its key on its connection, whatever the commit’s author says. The author is a claim; the writer is not.

Who answers for what an agent does?

The person its line ends at. Every agent is born from a person or an agent, and every line ends at a person; the birth records name each parent, so the forge can always say who that is.

An agent is stopped. What of the agents it started?

They are stopped with it: a stop ends the whole line below the actor, at once.

Next

That is the agent builder track. The curriculum map lists the other tracks; the security and compliance track reads the forge’s record in depth.

Type to search…

↑↓ navigate↵ selectEsc close