---
title: weft guides
description: 'How-to guides for weft, one task per page: streaming, structured output, conversations, per-step and per-run configuration, steering, approvals, tools, providers, middleware, observers, metadata and the manifest.'
url: https://weftgo.dev/docs/guides/
type: how-to
sources:
  - weft/AGENTS.md:20-193 (blocks 1-5, the API these guides cover)
---

# weft guides

Each guide does one task with weft and ends with a complete program that runs offline, against a scripted model or (for providers) a local test server. The guides assume you have built an agent once ([Quickstart](https://weftgo.dev/docs/get-started/quickstart/)) and know what a run and a tool are ([Concepts](https://weftgo.dev/docs/concepts/)). Pick a guide by what you need to do.

## Run an agent and read the result

- [Stream a run's events](https://weftgo.dev/docs/guides/streaming/): range over `Events()` to show progress, read the terminal error, stop early.
- [Get structured output from a run](https://weftgo.dev/docs/guides/structured-output/): constrain the final answer to a Go struct with `weft.Output`.
- [Continue a conversation](https://weftgo.dev/docs/guides/conversations/): feed the transcript back with `weft.Messages` and store it between requests.

## Shape what a run does

- [Rewrite the request each step (PrepareStep)](https://weftgo.dev/docs/guides/prepare-step/): trim messages, change the tools, the system prompt or sampling for each model call.
- [Change an agent's configuration for one run](https://weftgo.dev/docs/guides/run-options/): override instructions, narrow tools, switch the model, sample differently or force a tool call for a single run.
- [Steer a running turn](https://weftgo.dev/docs/guides/steering/): deliver a user message into a run that is already going.
- [Control reasoning (thinking)](https://weftgo.dev/docs/guides/thinking/): set a reasoning level for every run or for one.
- [Require human approval for a tool](https://weftgo.dev/docs/guides/approvals/): park a call, end the run, resume it with a decision.

## Give an agent tools

- [Set per-tool policy: timeouts, caps, ordering and strict input](https://weftgo.dev/docs/guides/tool-policy/): one tool's own deadline, result cap, barrier, input rule or prompt snippet.
- [Define tools at runtime: RawTool and ToolSource](https://weftgo.dev/docs/guides/dynamic-tools/): a tool with an explicit schema, or a catalogue that changes during a run.
- [Delegate to another agent (subagents)](https://weftgo.dev/docs/guides/subagents/): run an agent as another agent's tool.
- [Use MCP both ways](https://weftgo.dev/docs/guides/mcp/): import an MCP server's tools, or serve an agent as an MCP server.

## Work with models and providers

- [Connect a model provider: OpenAI, Anthropic, Gemini](https://weftgo.dev/docs/guides/providers/): construct and configure the first-party adapters.
- [Send images and files to a model](https://weftgo.dev/docs/guides/multimodal/): mix text and files in one prompt.
- [Add behaviour with middleware (the two seams)](https://weftgo.dev/docs/guides/middleware/): wrap the model and every tool call.
- [Retry and fall back when a provider fails](https://weftgo.dev/docs/guides/retries-and-fallback/): retry transient errors and switch to a backup model.

## Observe and describe your agents

- [Observe a run without changing it: Tap, OnRunEnd, OnMessages](https://weftgo.dev/docs/guides/observers/): see every event, the outcome, or each batch of messages as it joins the transcript.
- [Tag runs with metadata](https://weftgo.dev/docs/guides/metadata/): put tenant, user or request ids on every span and record of a run.
- [Describe your agents in weft.json (the manifest)](https://weftgo.dev/docs/guides/manifest/): generate and golden-gate the manifest that Studio's Agents page reads.

## See also

- [Concepts](https://weftgo.dev/docs/concepts/): what the core pieces are and how they behave
- [Sessions](https://weftgo.dev/docs/sessions/): durable conversations with `weft/thread`
- [Testing](https://weftgo.dev/docs/testing/): scripted models, record and replay
- [Package weft on pkg.go.dev](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2)
