Skip to content

The rules

The short list — every other page is a slower explanation of one of these.

  1. Agent configures, Turn/ModelChat act. No Ask at build time, no WithModel at runtime — the types won't let you.
  2. turn is the client, chat is the model. Direction is carried by which handle you touch, never by an overloaded verb. chat.Ask asks the model; turn.Reply answers the client.
  3. Select ids are strings (they come from a model). Declare exits with Selects to catch typos at startup.
  4. Nothing about tools is implicit. Ask never runs your handlers; WithTools/ForwardTools apply to one ask; an unanswered call goes to the client and an answered one stays internal.
  5. Errors surface in two places: Serve/Handler (wiring, startup) and Ask (schema, transport, and a tool whose handler disagrees with its schema — runtime). Builders never error mid-chain.
  6. Pass ctx to your I/O so a cancelled turn cancels your calls.
  7. bb.Respond is a stage boundary, repeatable. Every Respond delivers; only the flows after the last one are initiative, not part of the answer.

A tree of flows and agents, disguised as a model.