12. The simplest agent
Status: partly implemented. The unified 24-layer pure-Coax agent runtime (`openagents/core/core.coax`, `openagents/core/query_loop.coax`, `openagents/core/wire.coax`) and native worker (`coder/tui/oa-worker.coax`,
#14050โ#14053) ship and pass their#testchecks oncpu, driving `apps/openagents-desktop` behind the OpenAgents Cloud gateway and localpsionic-inkling-serve. Remaining: wiring the opening chapter 6coax drivechat-page case directly throughoa-workerand adding the standaloneopenagents/agent/loop.coaxteaching wrapper.
Premise
Chapter 4 left the chat page on the iPhone answering from a fake service, and chapter 6 runs its case. This chapter puts the first real agent behind it: one loop that reads a message, calls one model, streams the reply and writes both to a log. Every later chapter adds one thing to this loop and says how to tell whether it helped.
Draft
An agent is a loop around a model. Episode 5 defines it with five words: chat, plans, actions, users and tasks. The smallest version has only the first. You type a message, the loop sends it to a model, and the model's reply comes back.
That loop is where the 2023 wave of general agents started, and it is where they stalled. The loop can talk, but it can't do dependable work. It doesn't know your repository, your policy or your customer. Nobody can say whether it is right. Its cost has no bound. It has no job a buyer would pay for. And nothing says what it may touch. The general-agent essay calls these six pressures: execution, local knowledge, evaluation, cost, a buyer and authority.
We start with the bare loop on purpose. You can read all of it in one sitting, and each of the six gaps is easy to see in it. The rest of the book closes them one at a time. It does not close them by making the loop smarter. It closes them by putting specialized members behind the loop and by measuring each member before the loop relies on it.
The Coder book starts from the same place for one job, a repository task. This book starts there for every job. Where the two overlap, this book links to Coder's chapter and does not repeat it.
What we build
A plan for what this chapter ships once the draft is approved:
- A loop in Coax: one message in, one model call through the gateway, one reply out, and a log line for each.
- The loop answers chapter 4's chat page in place of the fake service's replies, through the same actions, so chapter 6's case still passes.
- A
chatverb in theopenagentscommand line that runs the loop from a terminal. This is a plan; the verb's name is the owner's to set. - A fixture run with a recorded model reply, so the loop's checks run with no network.
It builds on what exists today:
- `openagents/core/core.coax`, `openagents/core/query_loop.coax`, and `openagents/core/wire.coax` (unified 24-layer pure-Coax runtime,
#14050โ#14057) - `coder/tui/oa-worker.coax` (native worker running behind Desktop and CLI)
- `coax/lib/gateway`
- `coax/lib/agent/journal.coax`
- `apps/openagents-cli`
On the protocol (chapter 65):
| Record | Schema | Carriage | Today |
|---|---|---|---|
| The log | Coder's transcript log, id openagents.session.v1 on disk; planned package openagents.session.log.v1alpha1 (compliance plan, step C1) | A file of JSON lines; not sent | Planned. Written by hand in coax/lib/agent/session/log.coax |
The chapter's check
- Source: the loop in
openagents/agent/loop.coax, run against a fake gateway that replays one recorded model reply. No network is used. - Trace: chapter 6's case, with the loop in place of the fake service's replies:
type composer.input hello,tap composer.send, thenstate transcriptprintsyou: helloand the recorded reply, byte for byte.logsprints one line for the message and one for the reply. - Refusal: the fake gateway answers the model call with an error. No reply part appears, the transcript ends with `notice: model call failed
, andlogs` records the failed call. - Independent check: chapter 6's case passes unchanged on every target it names, and the session record's own checks (
coax/bin/coax test coax/lib/agent/session/session.coax) still pass. The logged reply matches the fixture's reply, written by hand.
Planned paths: openagents/agent/loop.coax. It drives the engines and the session record in `coax/lib/agent/` and adds no second session record.
Sources
- Episodes:
- Episode 1, *Intro*: the first statement of the project
- Episode 5, *Agent First Principles*: agents as chat, plans, actions, users and tasks
- Episode 289, *OpenAgents*: what the loop becomes
- Old code at
coder-v1.0.0, crates:openagents-chat,openagents-cli - Also:
- The Return of the General Agent (
git show coder-v1.0.0:docs/essays/2026-10-01-the-return-of-the-general-agent.md), Part I: the six pressures - Coder book, chapter 1: The simplest loop
- Promises covered (audit): P1