Skip to content

weft concepts

View as Markdown

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.

  1. What is an agent in weft? — an agent is an immutable value: a model, instructions, tools and policy, built once with weft.New and run concurrently.
  2. What does a run return? — Generate returns a RunResult: the run’s id, the transcript, one record per step, the usage.
  3. How do tools work? — a tool is a Go function; its input struct’s tags are the schema the model sees.
  4. 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.
  5. Messages, parts and the transcript — a message is a role plus typed parts; transcripts round-trip through JSON and weft.Repair keeps them valid.
  6. What is a Model? — the provider seam: one Stream method and a contract the loop enforces.
  7. Tool errors are data, run errors are yours — a failed tool call is a result the model reads; a failed run is a *RunError you handle.
  8. 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.