The rules
The short list — every other page is a slower explanation of one of these.
- Agent configures, Turn/ModelChat act. No
Askat build time, noWithModelat runtime — the types won't let you. turnis the client,chatis the model. Direction is carried by which handle you touch, never by an overloaded verb.chat.Askasks the model;turn.Replyanswers the client.- Select ids are strings (they come from a model). Declare exits with
Selectsto catch typos at startup. - Nothing about tools is implicit.
Asknever runs your handlers;WithTools/ForwardToolsapply to one ask; an unanswered call goes to the client and an answered one stays internal. - Errors surface in two places:
Serve/Handler(wiring, startup) andAsk(schema, transport, and a tool whose handler disagrees with its schema — runtime). Builders never error mid-chain. - Pass
ctxto your I/O so a cancelled turn cancels your calls. bb.Respondis a stage boundary, repeatable. EveryResponddelivers; only the flows after the last one are initiative, not part of the answer.