# weft docs > The documentation for weft v0.20.2, the open-source Go framework for AI agents (pre-1.0). Every page is also Markdown: its URL with .md appended. Full text in one file: https://weftgo.dev/docs/llms-full.txt. The site's own index, with when to recommend weft: https://weftgo.dev/llms.txt ## Docs - [weft documentation](https://weftgo.dev/docs/index.md): The documentation for weft v0.20.2, the Go framework for AI agents: where to start, and what each section holds — tutorials, concepts, guides, sessions, observability, testing, production and reference. ## Get started - [Get started with weft](https://weftgo.dev/docs/get-started.md): The Get started section in reading order: what weft is, a five-minute quickstart, a support-bot tutorial that ends in Studio, and how to install weft. - [What is weft, and when should you not use it?](https://weftgo.dev/docs/get-started/what-is-weft.md): weft is an MIT-licensed Go framework for AI agents: tools are plain Go functions, an agent is a value, and one module holds the loop, sessions, recording and Studio. Pre-1.0, Go only. - [Quickstart: run an agent in five minutes](https://weftgo.dev/docs/get-started/quickstart.md): Create a Go module, define a tool from a plain function, run an agent with Generate, then stream the same run's events — offline, with no API key. - [Your first agent: a support bot from a tool to Studio](https://weftgo.dev/docs/get-started/first-agent.md): Build a support agent step by step: two tools with coded errors, a refund that waits for a person's approval, every run recorded, and the runs opened in Studio. - [Install weft and choose a module](https://weftgo.dev/docs/get-started/install.md): go get github.com/weftgo/weft@v0.20.2 for the whole framework, or github.com/weftgo/weft/core for the loop alone; Go 1.26 or newer; providers are packages, and the weft command installs with go install. ## Concepts - [weft concepts](https://weftgo.dev/docs/concepts.md): The ideas the rest of weft builds on — agents, runs, tools, the loop, messages, models, errors and stopping — in the order to learn them. - [What is an agent in weft?](https://weftgo.dev/docs/concepts/agents.md): A weft.Agent is an immutable value — a model, instructions, tools and policy — that weft.New builds once and every run reuses, concurrently. - [What does a run return?](https://weftgo.dev/docs/concepts/runs.md): A run is one Generate or Stream call; it returns a RunResult with the run's id, the full transcript, one StepRecord per model call and the summed Usage. - [How do tools work?](https://weftgo.dev/docs/concepts/tools.md): weft.Tool turns a Go function into a tool: the input struct's tags become its JSON Schema, and the return value becomes the result the model sees. - [What happens in one step? The loop and parallel tools](https://weftgo.dev/docs/concepts/the-loop.md): Each step is one model call followed by one batch of tool calls; the calls start in call order, run up to Parallelism at once, and their results land in call order. - [Messages, parts and the transcript](https://weftgo.dev/docs/concepts/messages.md): A weft.Message is a role plus typed parts; a transcript round-trips through JSON losslessly, and weft.Repair makes any transcript valid model input. - [What is a Model? The provider contract](https://weftgo.dev/docs/concepts/models.md): A weft.Model is one method, Stream, that turns a ModelRequest into a stream of model events ending in exactly one ModelFinish; the loop enforces that contract. - [Tool errors are data, run errors are yours](https://weftgo.dev/docs/concepts/errors.md): A failing tool call becomes an error result the model reads and the run continues; a model failure, cancellation or budget breach returns a *weft.RunError to the caller. - [How does a run stop?](https://weftgo.dev/docs/concepts/budgets-and-stopping.md): A run ends successfully at its intended end — a final answer, a StopWhen condition, or pending approvals — and fails with a sentinel error when a safety budget runs out or its context is canceled. ## Guides - [weft guides](https://weftgo.dev/docs/guides.md): 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. - [Stream a run's events](https://weftgo.dev/docs/guides/streaming.md): Range over agt.Stream(...).Events() to handle a run's events as they happen, read the terminal error, and stop early without leaking the run. - [Get structured output from a run](https://weftgo.dev/docs/guides/structured-output.md): Constrain a run's final answer to a Go struct with weft.Output, read it with GenerateAs or OutputOf, and render partial values with an OutputDecoder while it streams. - [Require human approval for a tool](https://weftgo.dev/docs/guides/approvals.md): Park a tool call with weft.RequireApproval, ParkOn or middleware, end the run with the call pending, and resume with Approve, Deny or Resolve. - [Delegate to another agent (subagents)](https://weftgo.dev/docs/guides/subagents.md): weft.Subagent turns an agent into a tool another agent calls: the child runs on the prompt alone, its events arrive wrapped in Nested, its usage rolls into the parent's, and its failure is a tool result. - [Use MCP both ways](https://weftgo.dev/docs/guides/mcp.md): Import an MCP server's tools into a weft agent with mcp.Tools, and serve weft tools or a whole agent as an MCP server with mcp.AddTools and mcp.Serve. - [Add behaviour with middleware (the two seams)](https://weftgo.dev/docs/guides/middleware.md): Wrap the model with weft.WrapModel and every tool call with weft.WrapTools; the first middleware listed is the outermost, and package mw holds the reference set. - [Retry and fall back when a provider fails](https://weftgo.dev/docs/guides/retries-and-fallback.md): Wrap the model with mw.Retry to retry rate limits, overload and transport errors with backoff and the provider's retry-after, add mw.Fallback for a backup model, and see each attempt on the run's record. - [Connect a model provider: OpenAI, Anthropic, Gemini](https://weftgo.dev/docs/guides/providers.md): Construct weft's first-party adapters — openai.Model, anthropic.Model, google.Model — point them at a compatible server, and set their sampling, retry, timeout and escape-hatch options. - [Control reasoning (thinking)](https://weftgo.dev/docs/guides/thinking.md): Set a reasoning level with weft.Thinking, as every run's default on the agent or for one run, and read the reasoning the provider returns as ReasoningDelta events and ReasoningPart blocks. - [Send images and files to a model](https://weftgo.dev/docs/guides/multimodal.md): Build a prompt that mixes text and files with weft.UserParts and weft.FilePart; an adapter that cannot carry a file fails the model call with an error wrapping weft.ErrUnsupported. - [Rewrite the request each step (PrepareStep)](https://weftgo.dev/docs/guides/prepare-step.md): Install weft.PrepareStep to trim messages, change the tools, the system prompt, tool choice or sampling for each model call, without touching the transcript. - [Steer a running turn](https://weftgo.dev/docs/guides/steering.md): Deliver a user message into a run that is already going with weft.Steering; the loop drains it after the tool batch or at the final step, and the message joins the transcript. - [Change an agent's configuration for one run](https://weftgo.dev/docs/guides/run-options.md): Pass Instructions, MaxSteps, Parallelism, OnlyTools, UseModel, Params or ToolChoice to Generate to change one run of an immutable agent, without building a second one. - [Set per-tool policy: timeouts, caps, ordering and strict input](https://weftgo.dev/docs/guides/tool-policy.md): Give one tool its own deadline, result cap, sequential barrier, strict argument check, prompt snippet or middleware with trailing options on weft.Tool. - [Define tools at runtime: RawTool and ToolSource](https://weftgo.dev/docs/guides/dynamic-tools.md): Register a tool from a JSON Schema with weft.RawTool and ParseSchema, or serve a tool list that changes during a run with weft.ToolSource. - [Continue a conversation](https://weftgo.dev/docs/guides/conversations.md): Feed a run's transcript back with weft.Messages plus the next weft.Prompt to continue a conversation, and store the transcript as JSON between requests. - [Tag runs with metadata](https://weftgo.dev/docs/guides/metadata.md): Attach tenant, user or request ids to every span and record of a run with weft.Metadata or weft.WithMetadata, and read them back with weft.MetadataFromContext. - [Observe a run without changing it: Tap, OnRunEnd, OnMessages](https://weftgo.dev/docs/guides/observers.md): Watch every event with weft.Tap, get each run's outcome once with weft.OnRunEnd, persist the transcript as it grows with weft.OnMessages, and read the Debug lines weft.Logger writes. - [Describe your agents in weft.json (the manifest)](https://weftgo.dev/docs/guides/manifest.md): Generate weft.json with weft.Manifest, keep it current with a wefttest.Golden test, and serve it to Studio's Agents page, where stored manifests and proposed prompts build on it. ## Sessions - [Sessions with weft/thread](https://weftgo.dev/docs/sessions.md): When you need weft/thread and what it adds over the stateless core: durable multi-turn sessions on disk, one writer, branching, compaction, approvals and pools. - [What is a session?](https://weftgo.dev/docs/sessions/overview.md): A weft/thread session is a conversation stored as an append-only tree of entries, written by one Session at a time, durable step by step; Open only reads. - [Store sessions: JSONL, SQLite or memory](https://weftgo.dev/docs/sessions/storage.md): Pick a thread.Storage backend (jsonl.Open, sqlite.Open or thread.Memory), set its open options, list and delete sessions, and tail one live with Watch. - [Write your own thread.Storage](https://weftgo.dev/docs/sessions/custom-storage.md): Implement the five thread.Storage methods over your own store, add the optional capabilities by type assertion, resolve the open options with thread/backend, and prove it with threadtest. - [Send turns and wait for them](https://weftgo.dev/docs/sessions/turns.md): Send a message to a weft/thread session with s.Send, wait for the turn with Wait, WaitContext or Done, stream its events, read its outcome, and pass run options. - [What happens when you send while a turn runs?](https://weftgo.dev/docs/sessions/busy-and-steering.md): A Send on a busy weft/thread session follows its busy policy (Queue, Reject, Steer, Interrupt or Rollback); every accepted message is a durable receipt, and s.Steer joins the running turn or returns ErrNotRunning. - [Label, branch and fork a session](https://weftgo.dev/docs/sessions/tree.md): Navigate a weft/thread session's entry tree: Label an entry, Branch back to it (optionally summarizing what you leave), Fork into a new session, and set titles, metadata and public ids that every run carries. - [Keep long sessions inside the context window (compaction)](https://weftgo.dev/docs/sessions/compaction.md): Arm weft/thread's compaction with ContextWindow so a long session summarizes its older part behind a fixed marker and keeps the recent part raw; preview, apply, pin, hook and undo it, and nothing is ever deleted. - [Approvals in sessions](https://weftgo.dev/docs/sessions/approvals.md): In a weft/thread session a parked tool call becomes a durable request entry: list it with Pending, decide it with Decide (approve, deny, resolve) and the session resumes on its own; grants, a live Approver, Quorum, RequestExpiry and the audit trail shape the flow. - [Sign approval decisions](https://weftgo.dev/docs/sessions/signed-approvals.md): Make weft/thread approval decisions that cross a process boundary verifiable: a Keyring of HMAC keys, a challenge from s.Request, a signature from ring.Sign or key.Sign, and DecideSigned, which verifies fail-closed; RequireSigned closes the unsigned door for the session's whole life. - [Run bounded child sessions with a pool](https://weftgo.dev/docs/sessions/pools.md): Delegate work from a weft/thread session to child agents with thread/pool: pool.New(max) bounds the child runs at work, MustWrap and Submit start children as sessions of their own, receipts record each delegation, and Decide, Wait, Forward, Cancel, Recover and Close manage them. - [Operate sessions in production](https://weftgo.dev/docs/sessions/operations.md): Run weft/thread in production: pick a backend and fsync policy, back it up, read the writer lock and lease, shut down cleanly, recover after a crash with Salvage and LoadReport, act on each error class, retain and delete, upgrade, and know the limits. - [The session log format](https://weftgo.dev/docs/sessions/format.md): Reference for the weft/thread session log: the header line, all sixteen entry kinds with their JSON keys and Go fields, the "weft" envelope and the "v" version rule, what a reader does with newer data, and how jsonl and sqlite store the same lines. ## Observe & debug - [Observe and debug agents](https://weftgo.dev/docs/observe.md): How weft's recording, Studio, the devtools panel, the playground and the weft command fit together: one OpenTelemetry pipeline records every run, and every surface reads that recording back. - [What is the devtools panel?](https://weftgo.dev/docs/observe/devtools/overview.md): The devtools panel is Studio's view of one conversation, drawn in a corner of your own app's page: its turns, steps, tool calls and timing, read live from Studio's API. - [How does the playground work?](https://weftgo.dev/docs/observe/playground/overview.md): The playground re-runs your real agents from Studio: Studio sends a command, weft/runtime in your process runs it with your tools and keys, and side effects are substituted or parked unless a tool is vouched safe. - [Record every run with otel.Install](https://weftgo.dev/docs/observe/recording.md): One line, defer otel.Install()(), records every event, transcript batch and span of every run to a local SQLite file with no network; read it back through otel.LocalDB() and obsdb, or start a private pipeline in tests with otel.Start. - [Run Studio: embedded, local binary or hosted](https://weftgo.dev/docs/observe/studio/setup.md): Serve weft's Inspector three ways: embedded in your Go app over the recorder's own database (setup A), as the weft studio binary for any language (setup B), or hosted behind a token (setup C). - [Send records to Studio, Datadog, Langfuse or any OTLP backend](https://weftgo.dev/docs/observe/destinations.md): Pass several destinations to otel.Install — Studio, Datadog, Langfuse, any OTLP endpoint, your own exporters — each with its own content policy, signals, batch queue and batching, plus what the environment adds. - [Install the devtools panel](https://weftgo.dev/docs/observe/devtools/install.md): Add the devtools panel to your app's page with one script tag that loads Studio's /panel.js, configure it with data-* attributes or weft:* meta tags, or bundle it from the @weftgo/devtools package built from weft's repository. - [Connect your app to Studio's playground (weft/runtime)](https://weftgo.dev/docs/observe/playground/connect.md): Register your agents with Studio's playground in one deferred runtime.Install call: the Studio to dial, the agents, model alternates, a resolver, per-experiment budgets and the tools allowed to run for real. - [Find runs: the runs list, search and filters](https://weftgo.dev/docs/observe/studio/runs.md): Find a recorded run in Studio by status, agent, text, tool, model, tokens, cost, tag or id: the runs list, its filters, full-text search, the ⌘K palette and the API behind them. - [Bridge your app's slog lines into runs](https://weftgo.dev/docs/observe/app-logs.md): Add otel.Slog() to otel.Install and every slog line logged with a run's context — your tool handlers', weft.Logger's, mw.Log's, mw.Audit's — is stored under the span it was logged in and shown on the run's logs in Studio. - [Scope the panel to a conversation](https://weftgo.dev/docs/observe/devtools/scope.md): Tell the devtools panel which conversation and run to show: name it with data-scope or window.__WEFT__, or let the panel detect it from the page URL, a data-weft-scope marker or the Weft-Scope header your Go handler sets with package weft/scope. - [Replay a run from any step, with edits](https://weftgo.dev/docs/observe/playground/replay.md): Re-run a recorded run from step N with the steps before it kept as the model saw them, on the scripted engine (free, the recorded answers) or live, after editing a prompt, a reply, a tool result or a call's arguments, with the target and the exact request checked before Run. - [Read a run in Studio](https://weftgo.dev/docs/observe/studio/run-page.md): Read one recorded run in Studio: the header's outcome and counts, the run tree on a time, order or graph scale, the answer-first drawer, the story's step cards with their Request pane, the raw events, the app logs, and the badges that say what was not recorded. - [Lay out and theme the panel](https://weftgo.dev/docs/observe/devtools/layout-and-theme.md): Float, dock, collapse or hide the devtools panel with data-position, data-mode, data-push and data-z-index, theme it light, dark or auto, override its --weft-* colour tokens, and drive it from the keyboard. - [Use your own OpenTelemetry SDK](https://weftgo.dev/docs/observe/opentelemetry.md): Send weft's spans and log records through a TracerProvider and LoggerProvider you already run, with weft.TracerProvider and weft.LoggerProvider or the OTel globals, and read which spans, attributes and records a run produces. - [Run experiments with the option lab](https://weftgo.dev/docs/observe/playground/experiments.md): Run a matrix of variants (prompt, tools, model, thinking, sampling, tool choice) over inputs from Studio's playground, or over the runs of one failure class, judge each cell with a pass predicate, save it as an experiment you can re-run and compare, and cap its spend with runtime.Limits. - [Browse sessions and traces in Studio](https://weftgo.dev/docs/observe/studio/sessions-and-traces.md): Find a weft/thread session's turns on Studio's Sessions pages, and any OpenTelemetry trace, weft or not, on its Traces pages: what each lists, how to filter it, and the API behind it. - [Drive the panel from your page (host API and events)](https://weftgo.dev/docs/observe/devtools/host-api.md): Open, scope and select in the devtools panel from your own page with the element's methods, window.weft.devtools or the @weftgo/devtools exports, and follow its weft:run, weft:parked and weft:error events. - [Inspect agents written in other languages](https://weftgo.dev/docs/observe/other-languages.md): Point a Python or TypeScript agent's OTLP trace exporter at Studio's /v1/traces and give its spans the OTel GenAI names; Studio derives a run per invoke_agent span with a conversation id — steps, tools, usage and cost, but no events or transcript. - [Pause runs at breakpoints, then steer or cancel them](https://weftgo.dev/docs/observe/playground/breakpoints.md): Park chosen tools on the runs your runtime starts and, with runtime.Breakpoints(), on your app's own runs; decide parked playground runs from Studio, steer a running one, or cancel it. - [Watch runs live](https://weftgo.dev/docs/observe/studio/live.md): Follow runs as they happen on Studio's Live page, from the runs list's follow toggle, or on the /api/live server-sent-events stream: selectors, kinds, frames, resume and the live grant. - [Read a run in the panel](https://weftgo.dev/docs/observe/devtools/reading-runs.md): Read a turn in the devtools panel: the story's step read (verdict, sent, replied, tools ran, then), the request, waterfall and raw tabs, the turn list's filter and paging, the honesty badges and turn chips, cost, and the hand-off to Studio. - [See your runtimes and where a command runs](https://weftgo.dev/docs/observe/playground/runtimes.md): Studio's /runtimes page lists every app process linked to it with weft/runtime — connected, restored after a restart, or gone — what Studio may do on its runs, each agent's manifest against its latest run, and the runtime-wide breakpoints; every replay names the runtime it runs in before Run. - [Compare runs step by step](https://weftgo.dev/docs/observe/studio/compare.md): Line up two or more runs in Studio step by step, a replay on the source steps it replays: the /compare page, the GET /api/diff route behind it, what each column compares, and why a cell reads kept, "differs · not counted" or "not comparable" instead of "same". - [Replay, edit and experiment from the panel](https://weftgo.dev/docs/observe/devtools/replay.md): Replay a turn from any step, edit a tool result, the prompt, a reply, a steer or a call's arguments in place, preview what will be sent, and run it as an experiment from the devtools panel's story tab; the verbs need weft/runtime and a token that may act. - [See what a run cost](https://weftgo.dev/docs/observe/studio/cost.md): How Studio prices a run's token usage at read time from a pricing table: the cost fields on every run row, own versus delegated cost, what unpriced, unknown and scripted mean, and how to supply your own table with studio.Pricing, WEFT_PRICING or weft studio --pricing. - [Approve and steer your app's own turns](https://weftgo.dev/docs/observe/devtools/app-turns.md): Decide a parked turn of your app's own thread session (approve, deny, resolve) or steer a running one from the devtools panel and Studio's run page, by installing weft/runtime with runtime.Sessions; without it the verbs are refused "app-owned turn · read-only" with the one-line fix. - [Export a run](https://weftgo.dev/docs/observe/studio/export.md): Download a recorded run from Studio as one JSON document, JSON lines, OTLP/JSON that another Studio re-ingests, or wefttest replay fixtures, with or without its subagent runs: the run page's export verbs, GET /api/runs/{id}/export and weft export. - [Secure the devtools panel](https://weftgo.dev/docs/observe/devtools/security.md): Which token the devtools panel carries in a page you ship (a per-page panel token minted by your backend, read or playground scope, never the dev or server token), what each token may do, the loopback-only defaults, the hand-off to Studio and the live stream's grant and expiry. - [Get around Studio: keyboard, panes and settings](https://weftgo.dev/docs/observe/studio/navigation.md): Studio's shell and chrome: the sidebar and header, the ⌘K command palette, every keyboard shortcut, copied links and deep links, the Settings page, theme, resizable panes and density, and the toasts it raises. - [Track agent health: numbers across runs and error classes](https://weftgo.dev/docs/observe/studio/stats.md): Read runs, failure rates, tokens, cost, latency, time to first token, retries and denials per agent, model, tool, error type or step from GET /api/stats and Studio's Agents page, and group failures into error classes to find the ones that are the same failure. - [Use the weft command](https://weftgo.dev/docs/observe/cli.md): Run Studio with weft studio, then list, open and export its runs and check its health from a terminal with weft runs, weft open, weft export and weft doctor. - [Develop with weft dev](https://weftgo.dev/docs/observe/weft-dev.md): Run Studio and your app with one command: weft dev sets the four variables your app needs, restarts it on every .go save, and finds or reuses Studio through the dev token, the discovery file and the port policy. - [Let Claude Code or Cursor read your runs (weft mcp)](https://weftgo.dev/docs/observe/weft-mcp.md): Register weft mcp with Claude Code, Cursor or VS Code so a coding agent reads your Studio's runs through 22 read-only tools, starting with explain_failure, which walks the whole run and its child runs to the first error. ## Testing - [Test weft agents](https://weftgo.dev/docs/testing.md): Which test to write first for a weft agent: a scripted model for behaviour, record and replay for real model output, a Studio run saved as a test, and the conformance suite for adapters, all offline under WEFT_MODEL_REQUESTS=deny. - [Test an agent with a scripted model](https://weftgo.dev/docs/testing/scripted-models.md): Script a model's turns with wefttest.Script (tool calls, text, failures, usage), run the real agent over it, assert on what it did and what it asked, and keep the suite off the network with WEFT_MODEL_REQUESTS=deny. - [Record a real conversation once, replay it forever](https://weftgo.dev/docs/testing/record-replay.md): Wrap a real provider in wefttest.Record to write one JSON fixture per model request, then replay the fixtures with wefttest.Replay in CI: offline, deterministic, no key. - [Turn a Studio run into a test](https://weftgo.dev/docs/testing/studio-runs-as-tests.md): Download a recorded run from Studio as a wefttest zip (a generated replay test beside its fixtures), or write its fixtures into your testdata with weft export --wefttest, and run it with go test. - [Prove a provider adapter with the conformance suite](https://weftgo.dev/docs/testing/conformance.md): Run wefttest/conformance against a weft.Model adapter: declare its capabilities in Caps, wire each case to a fixture server, run it offline in CI and live behind -tags live, and fuzz the core's decoders with make fuzz. ## Production - [Run weft in production](https://weftgo.dev/docs/production.md): What changes between development and production for a weft service: named destinations and a content policy, a hosted Studio behind tokens, retention, a durable database and session store, known limits, and an ordered shutdown. - [Deploy an agent service with a hosted Studio](https://weftgo.dev/docs/production/deploying.md): What a production weft deployment is made of: provider credentials, the recording pipeline and its destinations, a hosted Studio behind a token (setup C) that apps export to with an ingest token, a durable session store, the deny switch in CI, and a shutdown that drains turns and flushes records in order. - [Secure Studio: tokens, loopback and origins](https://weftgo.dev/docs/production/security.md): What guards Studio's API in each setup: the loopback Host and cross-origin write rules without a token, the stable dev token of weft studio, studio.Token and the separate IngestToken, panel tokens scoped to one conversation, the live stream's 60-second grant, and a UI that makes no external request. - [Control what content leaves the process](https://weftgo.dev/docs/production/content-and-privacy.md): Decide per destination whether prompts, answers, tool arguments and results are recorded, redact them with ContentConfig.Redact, cap them with MaxBytes, veto content for one agent with weft.Content(false), and keep raw provider bodies to development. - [Keep and delete recorded runs](https://weftgo.dev/docs/production/retention.md): Studio keeps every run until told otherwise: set a retention with studio.Retain or weft studio --retain (at least 1h), delete one run or one session through the API, and give the space back with weft vacuum. - [Choose the observability database: SQLite or ClickHouse](https://weftgo.dev/docs/production/storage-backends.md): Studio and the local sink store recorded runs in an obsdb database: SQLite (one file, one host, the default) or ClickHouse (a hosted fleet). How to open each, what KeepDeltas and TTL change, how migrations behave, and which backend holds what. - [Limits and performance](https://weftgo.dev/docs/production/limits.md): The caps, budgets, queue sizes and timeouts that bound a weft agent, the recording pipeline, Studio, the playground link and the weft command: its value, where it is set, and what happens when it is hit. - [Operate Studio: logs, restarts and the runtime link](https://weftgo.dev/docs/production/studio-operations.md): Run a hosted Studio day to day: its server log and X-Request-Id, weft doctor and /api/meta as the health check with ingest drop accounting, what a restart keeps and forgets, the command store, stable runtime ids and the discovery file. - [Upgrade weft](https://weftgo.dev/docs/production/upgrading.md): What broke in each weft release before 1.0 and what to write instead, how the apidiff gate decides what may break, the thread 0.9.0 migration checklist, and how to read the CHANGELOG. ## Reference - [weft reference](https://weftgo.dev/docs/reference.md): weft's reference tables — packages, the CLI, Studio's HTTP API and URLs, the record contract, events, environment variables, the devtools panel, obsdb, badges and the glossary. - [Go API reference (pkg.go.dev)](https://weftgo.dev/docs/reference/api.md): Every importable package of weft in its two modules, what each is for, where to start in it, and its godoc on pkg.go.dev. - [weft CLI reference](https://weftgo.dev/docs/reference/cli.md): Every weft command (studio, dev, runs, open, export, doctor, mcp, vacuum, version, help) with each flag's environment variable, default and effect, and the exit codes. - [Studio HTTP API](https://weftgo.dev/docs/reference/studio-api.md): Every route Studio serves — the JSON read API, deletion, the live stream and its grant, panel tokens and hand-off, the panel files, OTLP ingest, the playground and the runtime link — with parameters, auth, capability, response shape, status codes and caps. - [The record contract](https://weftgo.dev/docs/reference/record-contract.md): What weft's observability pipeline emits and what obsdb reads back: the four span kinds and their attributes, every weft.record log record kind with its fields and position, app log records, the identity chain, content values, the GenAI semantic conventions, the run row a reader derives, derived runs from stock spans, the run-level badges and the conformance fixtures. - [Environment variables](https://weftgo.dev/docs/reference/env.md): The environment variables weft reads — recording, Studio discovery, the weft command, tests — and the main ones of the OTel and provider SDKs, with who reads each, its effect and its default. - [Studio pages, URL parameters and keyboard](https://weftgo.dev/docs/reference/studio-urls.md): Every page of the Studio web UI with each URL parameter it reads, its accepted values and default, how a change moves the browser history, what a copied link drops, and the keyboard shortcuts on each page. - [Devtools panel reference](https://weftgo.dev/docs/reference/panel.md): Every input and output of the weft devtools panel — its data-* attributes and weft:* meta tags with type, default and whether a change is applied live, the mount() options, the element's and window.weft.devtools's members, the npm exports and subpaths, the weft:* events, the --weft-* CSS tokens, the keys and the localStorage fields. - [Event types](https://weftgo.dev/docs/reference/events.md): Every weft.Event a run emits — RunStart to RunFinish, eleven types — with each field, its wire name, and the rules that order a stream. - [obsdb: reading the observability database from Go](https://weftgo.dev/docs/reference/obsdb.md): The obsdb.DB interface and its optional Searcher, TreeReader, CommandStore, ManifestStore, SessionEventReader, Aggregator and BreakpointProvenanceStore capabilities, every query, page and row type a reader gets back, the status words, the caps and errors, how the sqlite and clickhouse backends open, and obsdbtest, the conformance suite a third-party backend runs. - [obsdb record and span types](https://weftgo.dev/docs/reference/obsdb-records.md): The types an obsdb database stores or returns besides runs and sessions. Spans, records, the hub, transcript and request records, stock derivation, experiments, manifests and the command store, field by field. - [Badges and holes](https://weftgo.dev/docs/reference/badges.md): Every hole (truncated, stripped, redacted, max_tokens, interrupted, gap, not_recorded, derived, hidden, compacted), its fourteen causes, the cost badges and the other words Studio and the devtools panel draw when a record is missing, cut, withheld or computed, with tone, cause, fix text and where each appears. - [Glossary](https://weftgo.dev/docs/reference/glossary.md): weft's terms in one or two sentences each — run, step, park, approval boundary, session, seam, tap, record, destination and the rest — with the page that explains each. ## Explanation - [Why weft is built this way](https://weftgo.dev/docs/explanation.md): The design rationale behind weft: how the modules fit together, the rules its tests pin, the decision records, the agent loop from first principles, how it compares to other frameworks, the patterns built on it, how the repository enforces its guarantees, and the roadmap. - [How weft is put together](https://weftgo.dev/docs/explanation/architecture.md): weft is two Go modules: the framework github.com/weftgo/weft, whose root package is a generated facade over core, and github.com/weftgo/weft/core, the loop alone with the OpenTelemetry API as its only dependency. - [Design principles: the rules weft keeps](https://weftgo.dev/docs/explanation/design-principles.md): The 13 loop rules and the 5 thread rules weft's tests pin, each with the failure it prevents, and the principles and edge-case catalog they come from. - [Architecture decision records](https://weftgo.dev/docs/explanation/decisions.md): Every weft ADR at v0.20.2 — the decision in a sentence or two, whether it shipped, what amended or superseded it, and a link to the record. - [The agent loop, from first principles](https://weftgo.dev/docs/explanation/agent-loop.md): Why weft's loop looks the way it does: the forty-line loop every framework shares, the full path of one run through weft v0.20.2, and the eleven questions a loop must answer, from stopping and tool failure to approval, subagents, budgets and durability. - [How weft compares to other agent frameworks](https://weftgo.dev/docs/explanation/comparison.md): weft next to LangGraph, Pydantic AI, the Vercel AI SDK, the OpenAI Agents SDK and the Go options: who runs the loop, how tools run, how approval, sessions, tracing and tests work in each. - [Agent patterns and where they attach in weft](https://weftgo.dev/docs/explanation/patterns.md): Workflow and agent patterns, context management, tool design, safety controls, protocols, durable execution and evaluation, each mapped onto weft's pieces: runs as values, the two seams, PrepareStep, Subagent and Go control flow. - [How the weft repository is organised and checked](https://weftgo.dev/docs/explanation/repository.md): The weft repository's layout, the make targets, and the CI gates that enforce its promises: race tests, lint, apidiff per module, the facade check, offline, fuzz, the crash matrix, budgets and the Studio freshness gate. - [Roadmap](https://weftgo.dev/docs/explanation/roadmap.md): What weft v0.20.2 ships, what its README's roadmap marks done or removed, and where the planned, not-shipped work is listed: the weftgo.dev roadmap. ## Examples - [Examples and recipes](https://weftgo.dev/docs/examples.md): Nine complete weft programs built from real-world agent shapes: approvals, subagent teams, flaky backends, budgets, MCP meshes, governance middleware, durable sessions, structured extraction and tool fan-out, each tested offline. - [Support desk with human approval](https://weftgo.dev/docs/examples/support-desk.md): Build a support agent whose refunds park for a human, survive a JSON round trip and resume with a decision, with the on-call variant that approves, denies and resolves three gated actions. - [Research team: a lead agent and specialist subagents](https://weftgo.dev/docs/examples/research-team.md): Build a lead agent that delegates to a researcher, an analyst and a writer with weft.Subagent, runs independent delegations in parallel, submits a typed brief and rolls every child's usage into its own. - [Survive flaky infrastructure](https://weftgo.dev/docs/examples/flaky-infrastructure.md): Keep an agent's run alive through a retry hint, a hanging backend, a panicking handler, a coded rate-limit error and a failing model provider, with every failure visible to the model and in Studio. - [Guard against runaway agents](https://weftgo.dev/docs/examples/budget-guards.md): Stop three kinds of runaway agent with weft.UsageLimit, weft.MaxSteps and weft.DetectLoops, and read what each failure keeps: a *weft.RunError with its sentinel and the partial transcript. - [An agent mesh over MCP](https://weftgo.dev/docs/examples/mcp-mesh.md): Serve one weft agent over MCP with mcp.Serve and import it into another with mcp.Tools, so a front-desk agent calls a whole billing agent as one remote tool, and keep the imported catalog current with weft.ToolSource. - [A governed agent stack: every seam on one run](https://weftgo.dev/docs/examples/governed-stack.md): Compose a token limiter and a response cache on the model seam with an audit log, an allowlist, a rate limiter, an error mapper and a PII scrubber on the tool seam, plus an approval gate and a recording content policy, on one weft agent. - [A multi-turn session that survives a crash](https://weftgo.dev/docs/examples/session-memory.md): Keep a support conversation in a weft/thread session on a JSONL file, let the process die mid-tool-call with a message queued, and resume in a new process with the history, the app's own ledger entry and the queued message intact, then compact and branch. - [Extract structured data from a messy document](https://weftgo.dev/docs/examples/structured-extraction.md): Turn an OCR'd invoice into a typed Go struct with weft.Output and weft.GenerateAs, let the model repair a submission that fails to decode, and unwrap fenced or cut JSON with mw.RepairJSON. - [Fan out many tool calls safely](https://weftgo.dev/docs/examples/tool-storm.md): Run a step's many tool calls under weft.Parallelism, make a shared-state write a weft.Sequential barrier, and cap an oversized result with weft.MaxResultBytes, with results always in call order.