weft v0.20.2 · open source, MIT

Build reliable AI agents.
Iterate on real runs.

weft is the Go framework to build your agent, then test and experiment on real runs until it answers right and does the job.

Start building Read the docs
$go get github.com/weftgo/weft
  • Claude Code
  • Cursor
  • Codex
  • OpenAI
  • Anthropic
  • Gemini
  • MCP
  • OpenTelemetry
Building an agent and making it reliable, in five scenes. Build: a coding agent is asked to add a refund tool and writes weft.Tool("refund", …, weft.RequireApproval()); go vet and go test pass. See it: a user asks “Refund my last order.” and the agent answers “Done: order 1041 is refunded.”, which is wrong; the recorded run shows step 1 called refund for 1041 while the last order is 1042, because it never looked the order up. Experiment: the run is replayed from step 1 with three variants side by side: A adds a line to the prompt and still refunds 1041; B adds “Look it up first.” to the refund tool's description and refunds 1042; C uses a bigger model and refunds 1042, slower; the refund itself is answered from the recording, so nothing runs twice. Decide: a table puts your call on each answer beside latency and cost, and you keep B: right, fast and cheap. Keep it: weft export --wefttest (or save as test in Studio) makes the run a test, go test passes offline, and the next run refunds the right order.

who does what

Each side does what it is best at.

  • your coding agent

    builds and changes it

  • weft

    keeps it robust

  • you

    decide what good is

making it good

Every bad run makes it better.

The improvement loop. Ship: your coding agent builds the agent. Record: otel.Install records every run. Find: weft runs --failed and Studio show the runs that went wrong. Prove: replay the failed run in Studio with the fix. Keep: weft export --wefttest turns it into a test, and the agent ships again.

production-ready

Built for production.

  • Observable

    Every run recorded. See every step.

    otel.Install weft dev

  • Accurate

    Typed tools. Errors the model can act on.

    weft.Tool ToolError

  • Fast

    Tool calls in parallel. Answers stream.

    Parallelism agt.Stream

  • Safe

    Risky calls wait for a person.

    RequireApproval mw.Allow

  • Worth the cost

    Budgets stop a runaway loop.

    UsageLimit MaxSteps

the building blocks

What it is built from.

See every feature, animated →

the weft command

One command for the dev loop.

Studio and your app, restarted on save.

$weft dev

terminal
go install \
  github.com/weftgo/weft/cmd/weft@v0.20.2
weft dev            # Studio + your app
weft runs --failed  # find the bad run
weft export <id> --wefttest .  # keep it as a test
weft mcp            # Studio for Claude Code

for coding agents

Your coding agent can learn weft in one read.

  • AGENTS.mdThe API on one screen.
  • llms.txtSummary or everything, as Markdown.
  • TypedA wrong field is a build error.
  • Runs it can readweft mcp hands it the recorded run.

paste into Claude Code, Cursor or Codex

prompt
Read https://weftgo.dev/llms-full.txt and https://github.com/weftgo/weft/blob/v0.20.2/AGENTS.md. Build a Go support agent with weft and a lookup_order tool, record every run, and serve Studio at /studio/. Test it offline with wefttest. When a run fails, read it with weft mcp's explain_failure, fix the cause, and keep the run as a test with weft export --wefttest.

why weft

Built like the standard library.

  • Shaped like net/http.If you know it, you know weft.
  • A tool error is data.Only a failed run comes back to you as an error.
  • Nothing hidden.Official SDKs, standard OpenTelemetry, no phone-home.
  • Pay for what you import.The core needs only the OpenTelemetry API.

roadmap

Where weft is going. coming soon

  • next

    weft new and skills for coding agents, the definition of good as Go tests, fixes that come with proof

  • later

    AI in Studio that tests its own fixes, weft flow for graphs and workflows, durable execution

  • teams

    Studio for teams, quality trends per agent, approvals inbox, self-hosted

See the roadmap →

faq

Questions people ask.

What is weft?

weft is the open-source Go framework to build reliable AI agents: you build the agent, then iterate, test and experiment on real runs until it answers right and does the job. Your coding agent builds the agent with it; weft runs the agent loop, keeps durable sessions and records every run over OpenTelemetry; and Studio replays any run from any step, so a fix is proven on the exact run that failed and kept as a test. Tools are plain Go functions. MIT licensed, v0.20.2, Go 1.26+. More in the docs: What is weft.

What makes an AI agent reliable?

It answers right and does the job, and keeps doing so as models, users and APIs change. Building the agent is the small part; most of the work is iterating on it. weft makes that work first-class: every run recorded, replay from any step to try a change on the exact run that went wrong, recorded runs as offline tests, approvals and budgets enforced inside the loop. Your coding agent builds the agent, weft keeps it robust, and you decide what good is.

Which Go framework should I use for AI agents in production?

For a Go service, weft: a standard-library-shaped API, the vendors' official SDKs for OpenAI, Anthropic and Google, MCP both ways, parallel tools on goroutines, human approvals, durable sessions, OpenTelemetry recording, Studio with replay from any step, and offline tests from recorded runs. Every layer is optional, so you can adopt only the core. See how weft compares.

How do I debug an AI agent that gave a wrong answer?

Record every run with defer otel.Install()(). Then weft runs --failed lists the failed runs, and Studio (weft dev) shows each step, tool call and the exact request sent to the model. Studio's runs list groups failures by error class, each with its count, and weft mcp gives Claude Code, Cursor or VS Code the same runs with explain_failure. To check a fix, replay the run from the failing step in Studio's playground with the changed prompt, tool or model, or up to 20 runs of an error class at once, side by side; tools with side effects answer from the recording, so nothing fires twice. See recording and replay and experiments.

How do I test an AI agent?

In go test, offline. wefttest.Script scripts the model's turns; wefttest.Record records a real model once and wefttest.Replay replays it forever. Any recorded run becomes a test with save as test in Studio, or with weft export <run-id> --wefttest .: a replay test beside its fixtures, ready for go test. Set WEFT_MODEL_REQUESTS=deny in CI so no test can reach a network. See record and replay.

Does weft work with Claude Code, Cursor and Codex?

Yes. AGENTS.md in the repository has the whole API on one screen, weftgo.dev/llms.txt and the docs' llms.txt index every page as Markdown, and weft mcp is a read-only MCP server over your recorded runs (claude mcp add weft -- weft mcp) with runs, search, stats, diff, logs and explain_failure. Tool inputs are typed, so a coding agent's wrong field is a compile error, not a bad run. See weft mcp.

How does weft keep agents safe in production?

Approvals are a run boundary: weft.RequireApproval parks a call and ends the run with res.Pending until someone approves or denies it; sessions add persistent, signed and quorum decisions (thread.Quorum). Budgets stop a run inside the loop: MaxSteps, UsageLimit and DetectLoops. mw.Allow puts imported MCP tools behind an allowlist, and Studio shows what each middleware layer decided on a call (retried, fell back, denied). Each recording destination has its own content policy and redaction, and the framework never calls home. See approvals and budgets and stopping.

How do I control an agent's cost and latency?

Tool calls run in parallel on goroutines (weft.Parallelism, four per step by default) and agt.Stream streams the answer as it is written. weft.UsageLimit caps tokens per run and MaxSteps caps steps. Studio prices every run and step and shows where the time went, and its Agents page charts each agent's runs, failure rate, latency p50 and p95, tokens and cost; the playground reruns a recorded turn on another model so you can compare before switching, and weft.UseModel picks a model per run. See cost in Studio and agent stats.

When is weft not the right fit?

When you want a hosted, no-code or drag-and-drop agent builder: weft is a library you write Go code against. Also when you want to write the agent itself in Python or TypeScript, need a graph engine today (weft's is designed, not shipped), or need a frozen 1.0 API now. Studio still works for agents in any language: it ingests OpenTelemetry.

Can I use weft if my backend is Python, TypeScript or Java?

Yes, as a service. The agent runs as a small Go program beside your backend, which calls it over HTTP, gRPC or a queue; Go compiles to one static binary. Studio also ingests OpenTelemetry from agents written in any language: run weft studio and point the exporter at 127.0.0.1:7331; each top-level agent span in the GenAI conventions becomes a run page, and its conversation id groups runs into a session. See agents in other languages.

Can I watch the agent from inside my own app?

Yes. One script tag docks the devtools panel beside your page: it follows the conversation the page is on, turn by turn, and from it you approve, deny or steer the app's own turns and replay a step. Name the conversation with data-scope, a ?weft_scope= link or the Weft-Scope header (scope.Header), or name a batch of runs by agent, flow or tag, such as a nightly eval, and the panel lists exactly those runs; a panel token minted for those tags reads nothing else. See the devtools panel and scope.

Which model providers does weft support?

OpenAI and any OpenAI-compatible server, Anthropic, and Google Gemini, through the vendors' official Go SDKs. MCP works both ways: consume MCP servers as tools, or expose your tools as an MCP server. See providers and MCP.

How does weft keep a conversation across restarts?

With weft/thread. A session is an append-only log, in jsonl, SQLite or memory out of the box, or in any database through the five-method thread.Storage interface, checked by the thread/threadtest conformance suite: s.Send writes the prompt before the run starts and appends each step as it joins, so a crash mid-turn loses nothing, and thread.Open(ctx, st, id, agent) brings the conversation back. The same log lets you steer a running turn (s.Steer), label, branch or fork from any entry (s.Label, s.Branch, s.Fork), compact a long context (s.Compact) and park turns for approval (s.Decide). See sessions.

Where can I see weft in action?

The animation at the top of weftgo.dev shows the loop: a coding agent builds a refund tool, a run answers wrong, three fixes are replayed side by side on that exact run, you keep the one that works, and the run becomes a test. The features page walks through weft in eight animated steps: tools, parallel tools on goroutines, sessions, recording, Studio, replay, the devtools panel and the rest. For a runnable demo, examples/getting-started in the repository is one Go file; the docs have more examples.

What is on the weft roadmap?

Next: weft new and skills so coding agents build weft agents right the first time, the definition of good as Go tests (scenarios, assertions and judges), fixes that come with proof, serving agents over HTTP and versioned prompts. Later: AI in Studio that proposes a fix and proves it by replay, weft flow for typed graphs and agentic workflows, durable execution, long-term memory adapters, Postgres sessions at scale and a stable 1.0. For teams: Studio with single sign-on and roles, quality trends per agent, an approvals inbox, replay in CI and self-hosted installs. It is a direction with no dates; the full list is on the roadmap.

Is weft production ready?

weft is v0.20.2, pre-1.0. Every layer has been through a production-readiness review; the thread API and storage format are not frozen. Pin your versions, because breaking changes can still happen between minor releases. A stable 1.0 behind an API-compatibility gate is on the roadmap. See running weft in production and upgrading.

get started

Your first agent in five minutes.

  1. Install

    go get github.com/weftgo/weft@v0.20.2
  2. Write a tool

    A Go function. Or ask your coding agent.

  3. Run and watch

    weft dev

    Every run recorded, ready to replay.