What is weft, and when should you not use it?
weft is an open-source Go framework for building AI agents. A tool is a plain Go function, an agent is a value you build once and run many times, and Generate runs the loop — model, tools, model — until the model answers. One go get brings the loop, durable sessions, run recording and Studio, the web UI that shows each run. weft is pre-1.0 and Go only.
The smallest agent in getstarted/main.go has one tool, one agent and one run:
lookup := weft.Tool("lookup_order", "Look up an order by ID.", func(ctx context.Context, in LookupInput) (string, error) { return "order " + in.OrderID + ": shipped", nil })
agt := weft.New(model, weft.Name("support"), weft.Instructions("You are a support agent."), lookup,)
res, err := agt.Generate(ctx, weft.Prompt(question))if err != nil { return "", err}return res.Text(), nilweft.Tool reflects the tool’s JSON Schema from LookupInput’s struct tags. weft.New builds the agent; every option has a working default. weft.Prompt is the user’s message, and res.Text() the model’s final answer.
What weft is
Section titled “What weft is”weft’s API is small interfaces, context.Context first in every signature, functional options, wrapped errors, and no required configuration. The framework is one module, github.com/weftgo/weft, at one version. Its packages are layers; you import the ones you use. The loop’s companions — the provider adapters, MCP, middleware and the test model — sit alongside the root package, each in its own package:
| Package | What it gives you |
|---|---|
weft | The agent loop: tools from Go functions, parallel tool calls, typed streaming events, structured output, approvals, steering and subagents. |
weft/openai, weft/anthropic, weft/google, weft/mcp, weft/mw, weft/wefttest | The OpenAI, Anthropic and Google adapters (openai, anthropic, google), MCP both ways (mcp), reference middleware (mw) and the offline test model (wefttest). |
weft/thread | Durable sessions: an append-only conversation tree with branching, compaction, approvals that survive a restart, steering and a bounded pool of child agents, stored as JSONL, in SQLite or in memory. |
weft/otel | Recording with otel.Install: every event, transcript and span exported over OpenTelemetry to a local database, Studio or any OTLP backend, with a content policy and redaction per destination. |
weft/obsdb | The database those records land in, queryable from Go: SQLite locally, ClickHouse hosted (weft/obsdb/clickhouse). |
weft/studio | Studio, the inspector: runs, sessions, traces and live streams in a web UI; a devtools panel for your own pages; a playground that re-runs a turn with an edited prompt, model or tools. The weft command (weft studio, weft dev) serves it for apps in any language. |
weft/scope | The devtools panel’s scope header: scope.Header sets Weft-Scope on your own chat endpoint, so the in-page panel follows the conversation and run a response belongs to. |
weft/runtime | The playground’s in-app side: your app executes Studio’s experiment commands, with side-effect tools substituted or parked unless you opt them in. |
The loop also exists alone, as the module github.com/weftgo/weft/core, whose only dependency is the OpenTelemetry API. The root package weft re-exports it name for name: weft.Agent is core.Agent. Install weft and choose a module says which one to go get.
A step’s tool calls run on their own goroutines, at most four at once by default; weft.Parallelism changes the bound, and a failing tool never cancels its siblings.
Recording and inspection are two lines: defer otel.Install(otel.Local(""))() records every run to ./.weft/weft.db (plus any Studio the environment names), and studio.Handler(studio.DB(otel.LocalDB())) serves Studio over that database. Your first agent builds both.


The status at v0.20.2: experimental and pre-1.0, released as the framework module plus core. The core’s message model, error model and tool contract are implemented and tested. CI runs on every change (CI on GitHub), the API reference is on pkg.go.dev, and each release is tagged on GitHub (v0.20.2).
How it works
Section titled “How it works”A run is one call to Generate or Stream. Each step is one model call. When the model asks for tools, the loop runs them, sends their results back as one tool message, and calls the model again. The run ends when the model answers without asking for a tool, when a weft.StopWhen condition matches, or when a call is parked for approval; it fails when a budget such as MaxSteps runs out.
Three rules hold on every run:
- A tool error is data the model sees; a run error is a Go error. A handler error, a panic or bad arguments become an error result the model reads. A model failure, a cancelled
ctxor a spent budget fail the run with a*weft.RunErrorthat carries the partial transcript. - Every run has an id.
weft.RunStartis its first event and, when it succeeds,weft.RunFinishits last. - Budgets fail at the continuation point.
weft.MaxStepscaps a run’s model calls, 10 by default; the run fails withErrMaxStepsonly when the loop would call the model again.
When not to use weft
Section titled “When not to use weft”weft is the wrong tool in these cases:
- Your agent is not written in Go. The loop is a Go library. Studio is not tied to Go:
weft studioinspects any language’s OpenTelemetry app (Inspect agents written in other languages). - You need a frozen API. weft is pre-1.0. A minor release can break the framework module’s packages, and
weft/thread’s API and file format are not frozen. Only thecoremodule fails CI on an incompatible change. - You want a graph or workflow engine. Orchestration lives in the loop: a subagent is a tool (
weft.Subagent), andweft.PrepareSteprewrites each step’s request. weft ships no graph. - You need a run to resume after its process dies. The core keeps no state: a run is a function of the agent, the input transcript and the approval decisions, and it lives in its process. weft ships no durable-execution engine.
- You need a security boundary around tools. Approval is a policy seam, not a security boundary (ADR 0007), and weft ships no sandbox for tools.
- You need a model server or evaluations. Neither has shipped: serving and the eval modules are next on the roadmap.
License
Section titled “License”weft is released under the MIT License. The full text is in LICENSE.
Best practices & gotchas
Section titled “Best practices & gotchas”- Import
weftin application code, notcore. The root package is the facade users write against; the layers importcoreinside the repository. Importcoreonly when you want the loop and nothing else. (Source: AGENTS.md intro; ADR 0027, decision 4) - Pin the exact version. Pre-1.0, a minor release may carry breaking changes; the CHANGELOG lists them under Breaking. (Source: README.md status; AGENTS.md “Working in this repo”)
- Test without a network.
wefttest.Scriptplays model turns offline, andWEFT_MODEL_REQUESTS=denymakes the first-party adapters refuse to call their provider. (Source: AGENTS.md “Test offline”;getstarted/main_test.go)
See also
Section titled “See also”- Next: Quickstart: run an agent in five minutes, which builds and runs a complete program
- Install weft and choose a module
- What happens in one step? The loop and parallel tools
- How weft compares to other agent frameworks
Symbols used: weft.Tool · weft.New · weft.Name · weft.Instructions · weft.Prompt · Agent.Generate · RunResult.Text · weft.Parallelism · weft.StopWhen · weft.MaxSteps · weft.ErrMaxSteps · weft.RunError · weft.RunStart · weft.RunFinish · weft.Subagent · weft.PrepareStep · wefttest.Script · otel.Install · otel.Local · otel.LocalDB · studio.Handler · studio.DB · scope.Header