---
title: What is weft, and when should you not use it?
description: '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.'
url: https://weftgo.dev/docs/get-started/what-is-weft/
type: concept
sources:
  - 'weft/README.md:1-38 (badges, the opening paragraph, the package table, concurrency, status: 32-37, v0.20.2 — experimental, pre-1.0, one module plus core)'
  - weft/README.md:974-1017 (Layout; two modules, ADR 0027; the two-line recorder and inspector)
  - 'weft/README.md:1079-1104 (Roadmap: serve and eval next, the sandbox abandoned; License)'
  - weft/LICENSE:1 (MIT License)
  - 'weft/AGENTS.md (intro: two modules, facades; rules 1, 4, 13; Working in this repo — the apidiff gate)'
  - weft/docs/adr/0027-framework-module-and-core.md (Decision 1–4)
  - weft/docs/adr/0007-approval-boundary.md (a policy seam, not a security boundary)
  - weft/docs/agent-loop-deep-dive.md §13 (the core is stateless), §16 (orchestration in the loop), §25 (a run is a function of agent, transcript, decisions)
  - weft/core/agent.go:23-24 (defaultMaxSteps = 10, defaultParallelism = 4); godoc Parallelism, MaxSteps, New
  - weft/core/tool.go godoc Tool
  - 'weft/README.md:343-358 (setup B: weft studio for any language''s OTel app)'
  - docs-site/examples/getstarted/main_test.go:TestAnswer, TestToolResultInTranscript
  - weft/otel/pipeline.go:223-238, 332-351 (the default local sink only with no destination; otel.Local named keeps it)
  - weft/core godoc StopWhen, RequireApproval (a run also ends on a stop condition or a park)
---

# 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`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Agent.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:

```go title="getstarted/main.go"
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(), nil
```

[getstarted/main.go on GitHub](https://github.com/weftgo/weftgo.dev/blob/main/docs-site/examples/getstarted/main.go)

[`weft.Tool`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Tool) reflects the tool's JSON Schema from `LookupInput`'s struct tags. [`weft.New`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#New) builds the agent; every option has a working default. [`weft.Prompt`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Prompt) is the user's message, and [`res.Text()`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#RunResult.Text) the model's final answer.

## 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`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2) | 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`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/openai), [`anthropic`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/anthropic), [`google`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/google)), MCP both ways ([`mcp`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/mcp)), reference middleware ([`mw`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/mw)) and the offline test model ([`wefttest`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/wefttest)). |
| [`weft/thread`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/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`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/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`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/obsdb) | The database those records land in, queryable from Go: SQLite locally, ClickHouse hosted (`weft/obsdb/clickhouse`). |
| [`weft/studio`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/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`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/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`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/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](https://weftgo.dev/docs/get-started/install/#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`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#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](https://weftgo.dev/docs/get-started/first-agent/) builds both.

![weft Studio's runs list: each run's status, prompt and id, agent, steps, tokens, cost, start and duration, newest first, with a checkbox per row to pick runs to compare](https://weftgo.dev/docs/_astro/studio-runs.light.CFMu-KA1.webp)

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](https://github.com/weftgo/weft/actions/workflows/ci.yml)), the API reference is on [pkg.go.dev](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2), and each release is tagged on GitHub ([v0.20.2](https://github.com/weftgo/weft/releases/tag/v0.20.2)).

## How it works

A [run](https://weftgo.dev/docs/reference/glossary/#run) is one call to `Generate` or `Stream`. Each [step](https://weftgo.dev/docs/reference/glossary/#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`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#StopWhen) condition matches, or when a call is parked for approval; it fails when a budget such as `MaxSteps` runs out.

> **Diagram:** agt.Generate starts a run (RunStart). Each step is one model call, one chat span. When the model asks for tools, each call starts (ToolStart), the tools run in parallel, and their results come back (ToolFinish) to the model as one tool message; the step ends with StepFinish and, if the budgets allow, the next step calls the model again. MaxSteps bounds the loop, 10 steps by default. The run ends at RunFinish when the model answers with no tool calls, when StopWhen matches, or when calls are pending approval.

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 `ctx` or a spent budget fail the run with a [`*weft.RunError`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#RunError) that carries the partial transcript.
- **Every run has an id.** [`weft.RunStart`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#RunStart) is its first event and, when it succeeds, [`weft.RunFinish`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#RunFinish) its last.
- **Budgets fail at the continuation point.** [`weft.MaxSteps`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#MaxSteps) caps a run's model calls, 10 by default; the run fails with `ErrMaxSteps` only when the loop would call the model again.

## 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 studio` inspects any language's OpenTelemetry app ([Inspect agents written in other languages](https://weftgo.dev/docs/observe/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 the `core` module 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`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Subagent)), and [`weft.PrepareStep`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#PrepareStep) rewrites 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](https://github.com/weftgo/weft/blob/v0.20.2/docs/adr/0007-approval-boundary.md)), 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](https://weftgo.dev/docs/explanation/roadmap/).

## License

weft is released under the MIT License. The full text is in [`LICENSE`](https://github.com/weftgo/weft/blob/v0.20.2/LICENSE).

## Best practices & gotchas

- **Import `weft` in application code, not `core`.** The root package is the facade users write against; the layers import `core` inside the repository. Import `core` only 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.Script` plays model turns offline, and `WEFT_MODEL_REQUESTS=deny` makes the first-party adapters refuse to call their provider. (Source: AGENTS.md "Test offline"; `getstarted/main_test.go`)

## See also

- Next: [Quickstart: run an agent in five minutes](https://weftgo.dev/docs/get-started/quickstart/), which builds and runs a complete program
- [Install weft and choose a module](https://weftgo.dev/docs/get-started/install/)
- [What happens in one step? The loop and parallel tools](https://weftgo.dev/docs/concepts/the-loop/)
- [How weft compares to other agent frameworks](https://weftgo.dev/docs/explanation/comparison/)

Symbols used: [`weft.Tool`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Tool) · [`weft.New`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#New) · [`weft.Name`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Name) · [`weft.Instructions`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Instructions) · [`weft.Prompt`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Prompt) · [`Agent.Generate`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#Agent.Generate) · [`RunResult.Text`](https://pkg.go.dev/github.com/weftgo/weft/core@v0.20.2#RunResult.Text) · [`weft.Parallelism`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Parallelism) · [`weft.StopWhen`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#StopWhen) · [`weft.MaxSteps`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#MaxSteps) · [`weft.ErrMaxSteps`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#ErrMaxSteps) · [`weft.RunError`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#RunError) · [`weft.RunStart`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#RunStart) · [`weft.RunFinish`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#RunFinish) · [`weft.Subagent`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Subagent) · [`weft.PrepareStep`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#PrepareStep) · [`wefttest.Script`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/wefttest#Script) · [`otel.Install`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/otel#Install) · [`otel.Local`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/otel#Local) · [`otel.LocalDB`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/otel#LocalDB) · [`studio.Handler`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#Handler) · [`studio.DB`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#DB) · [`scope.Header`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/scope#Header)
