partly implementedProfilecpuQualifiedcpu

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 #test checks on cpu, driving `apps/openagents-desktop` behind the OpenAgents Cloud gateway and local psionic-inkling-serve. Remaining: wiring the opening chapter 6 coax drive chat-page case directly through oa-worker and adding the standalone openagents/agent/loop.coax teaching 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 chat verb in the openagents command 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:

On the protocol (chapter 65):

RecordSchemaCarriageToday
The logCoder'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 sentPlanned. 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, then state transcript prints you: hello and the recorded reply, byte for byte. logs prints 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, and logs` 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