weft concepts
These pages explain what weft’s core pieces are and how they behave, one idea per page. Read them in order: each one uses only the ideas of the pages before it. The how-to guides apply them; the reference holds the tables.
- What is an agent in weft? — an agent is an immutable value: a model, instructions, tools and policy, built once with
weft.Newand run concurrently. - What does a run return? —
Generatereturns aRunResult: the run’s id, the transcript, one record per step, the usage. - How do tools work? — a tool is a Go function; its input struct’s tags are the schema the model sees.
- What happens in one step? — one model call, then one batch of tool calls that start in call order, run in parallel and land in call order.
- Messages, parts and the transcript — a message is a role plus typed parts; transcripts round-trip through JSON and
weft.Repairkeeps them valid. - What is a Model? — the provider seam: one
Streammethod and a contract the loop enforces. - Tool errors are data, run errors are yours — a failed tool call is a result the model reads; a failed run is a
*RunErroryou handle. - How does a run stop? — the intended end succeeds; a budget or a cancellation fails the run with a named error.
Two ideas build on these and have their own sections: approval as a run boundary (Require human approval for a tool) and durable conversations (What is a session?). Why the core is shaped this way is in Explanation.