Go API reference (pkg.go.dev)
weft ships as two Go modules. github.com/weftgo/weft is the framework: the loop, the provider adapters, sessions, recording, Studio and the playground, one version and one go get. github.com/weftgo/weft/core is the loop alone, for a service that wants nothing else; its only dependency is the OpenTelemetry API. pkg.go.dev holds every signature; this page lists each importable package, what it is for, where to start, and the docs page that explains it.
Modules
Section titled “Modules”| Module | Holds | Get it | Godoc |
|---|---|---|---|
github.com/weftgo/weft | The root package weft and every package below except core’s | go get github.com/weftgo/weft@v0.20.2 | weft@v0.20.2 |
github.com/weftgo/weft/core | The loop (core), core/mw, core/wefttest, core/wefttest/conformance | go get github.com/weftgo/weft/core@v0.20.2 | core@v0.20.2 |
The root package weft and the packages mw, wefttest and wefttest/conformance are generated facades over core: every name is an alias of, or a wrapper around, the same name there (weft.Agent is core.Agent). So pkg.go.dev documents the methods and fields of those types on core’s pages, and a link to Agent.Generate goes to weft/core@v0.20.2#Agent.Generate. Package-level names (weft.New, weft.Tool) are on the root page. Which module to choose: Install weft and choose a module.
Packages by layer
Section titled “Packages by layer”| Layer | Packages |
|---|---|
| The loop | weft, core |
| Providers | openai, anthropic, google |
| Tools and middleware | mcp, mw |
| Testing | wefttest, conformance |
| Sessions | thread, jsonl, sqlite (thread’s), pool, backend, threadtest |
| Recording | otel, obsdb, sqlite (obsdb’s), clickhouse, obsdbtest |
| Studio and the playground | studio, ingest, runtime (both sides), scope |
| The binary and its version | weft command, version |
Packages under internal/ and the example programs are not importable API and are not listed.
Package anthropic
Section titled “Package anthropic”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/anthropic | The adapter for the Anthropic Messages API, over the official anthropic-sdk-go | anthropic.Model | Connect a model provider |
Package backend
Section titled “Package backend”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/thread/backend | For authors of thread.Storage backends: resolves the open options an app passes (thread.Salvage, FsyncOnFlush, NoLock, OpenLogger) into the configuration a backend acts on. Applications never import it | backend.Resolve | Write your own thread.Storage |
Package clickhouse
Section titled “Package clickhouse”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/obsdb/clickhouse | obsdb’s hosted backend: the observability schema as ClickHouse tables, column-compatible with the OTel Collector’s ClickHouse exporter | clickhouse.Open | Choose the observability database |
Command weft
Section titled “Command weft”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/cmd/weft | The framework’s one binary: a local Studio (weft studio, weft dev) and a terminal over the Studio API | go install github.com/weftgo/weft/cmd/weft@v0.20.2 | weft CLI reference |
Package conformance
Section titled “Package conformance”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/wefttest/conformance | The framework’s import path for the adapter conformance suite: a facade over core’s | conformance.Run | Prove a provider adapter |
github.com/weftgo/weft/core/wefttest/conformance | The suite itself: drives a Model through the behaviours every provider adapter must share | conformance.Run | Prove a provider adapter |
Package core
Section titled “Package core”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/core | The agent loop, the module at the bottom of the framework. The root package re-exports it under the same names; import it directly when a service wants the loop alone | core.New | Install weft and choose a module |
Package google
Section titled “Package google”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/google | The adapter for the Gemini API, over the official google.golang.org/genai SDK | google.Model | Connect a model provider |
Package ingest
Section titled “Package ingest”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/studio/ingest | Studio’s OTLP/HTTP receiver: POST /v1/traces and /v1/logs, protobuf and JSON, optional gzip, at most 16 MiB decompressed (ingest.MaxBody) | ingest.Traces, ingest.Logs | Inspect agents written in other languages |
Package jsonl
Section titled “Package jsonl”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/thread/jsonl | The default durable thread.Storage: one directory, one <id>.jsonl file per session, the header line first, then one entry per line in append order | jsonl.Open | Store sessions |
Package mcp
Section titled “Package mcp”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/mcp | The bridge to the Model Context Protocol, both ways, over the official Go SDK: a server’s tools as weft tools, and an agent as an MCP server | mcp.Tools, mcp.Serve | Use MCP both ways |
Package mw
Section titled “Package mw”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/mw | The framework’s import path for the reference middleware: a facade over core/mw | mw.Retry | Add behaviour with middleware |
github.com/weftgo/weft/core/mw | The middleware itself: model middleware for WrapModel (Retry, Fallback, Log, RepairJSON) and tool middleware for WrapTools (Allow, Audit, MapErrors) | mw.Fallback | Retry and fall back |
Package obsdb
Section titled “Package obsdb”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/obsdb | The observability database: what weft/otel’s local sink writes and Studio reads. OTLP-shaped spans and log records, the DB backend interface, and the in-process hub that is the live lane | obsdb.DB | obsdb: reading the observability database from Go |
Package obsdbtest
Section titled “Package obsdbtest”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/obsdb/obsdbtest | The conformance table every obsdb.DB backend runs; Run takes a factory so each subtest gets a fresh database | obsdbtest.Run | Choose the observability database |
Package openai
Section titled “Package openai”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/openai | The adapter for the OpenAI Chat Completions API and OpenAI-compatible servers, over the official openai-go SDK | openai.Model | Connect a model provider |
Package otel
Section titled “Package otel”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/otel | Wires weft’s observability to one or more OpenTelemetry destinations at once (the local sink, Studio, Datadog, Langfuse, any OTLP endpoint, your own exporters), each with its own signals and content policy | otel.Install | Record every run with otel.Install |
Package pool
Section titled “Package pool”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/thread/pool | Bounded concurrent child runs for sessions: a FIFO semaphore per Pool value, subagent tools whose children run as sessions of their own, and receipts recording every delegation | pool.New | Run bounded child sessions with a pool |
Package runtime
Section titled “Package runtime”Two packages share the name: the app side, which you import, and Studio’s side of the same link.
| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/runtime | The playground’s in-app side: registers your agents with Studio, receives experiment commands over the runtime link, and executes them as real runs in your process | runtime.Install | Connect your app to Studio’s playground |
github.com/weftgo/weft/studio/runtime | The runtime link’s server side: the registry of connected runtimes and the routes a weft/runtime client speaks to (register, the SSE command stream, acks). studio.New builds one under studio.Playground(true) | runtime.New | How does the playground work? |
Package scope
Section titled “Package scope”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/scope | The Go side of the devtools panel’s scope: one conversation’s public id and, optionally, the session, flow and run inside it. Since 0.20.0 it can instead name a page of unrelated runs by an agent and run-metadata tags (a test batch). It has one string form, pub_…;session=…;flow=…;run=…;agent=…;tag.<k>=<v>, and a net/http middleware that sends it as the Weft-Scope header | scope.Header | Scope the panel to a conversation |
Package sqlite
Section titled “Package sqlite”Two packages share the name: one stores sessions, the other the observability database. Both use the CGO-free modernc.org/sqlite driver.
| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/thread/sqlite | The thread’s second durable backend: every session in one SQLite file, with WAL and embedded migrations; by default every commit is fsynced | sqlite.Open | Store sessions |
github.com/weftgo/weft/obsdb/sqlite | obsdb’s default backend: the observability schema in one SQLite file. Its DB also carries the hub every Write publishes to, which is setup A’s live lane | sqlite.Open | Choose the observability database |
Package studio
Section titled “Package studio”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/studio | The Inspector: the UI, the JSON API, the live stream and the OTLP receiver over one observability database, served by Go alone. Embedded in your app (setup A), run as weft studio (setup B), or hosted behind a token (setup C) | studio.Handler | Run Studio |
Package thread
Section titled “Package thread”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/thread | Sessions: a conversation as an append-only tree of entries, durable through a Storage backend, with turns, branching, compaction, approvals and delegation built on that tree. Pre-1.0: the API and the format may change | thread.Create, thread.Session | What is a session? |
Package threadtest
Section titled “Package threadtest”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/thread/threadtest | The conformance table every thread.Storage backend runs before it may call itself a backend, plus crash harnesses | threadtest.Run | Write your own thread.Storage |
Package version
Section titled “Package version”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/version | weft’s one version string, the framework module’s tag (v0.20.2), stamped into Studio’s meta, the panel bundle, the otel resource and the runtime’s registration | version.Version | Upgrade weft |
The package has two names. Call version.Runtime() when your binary reports which weft it runs; the package example ExampleRuntime prints it.
| Name | Returns | Where weft uses it |
|---|---|---|
version.Version | The constant tag the source carries, "v0.20.2"; it changes only with a release | studio.Version and /api/meta’s studio_version, the devtools panel bundle’s stamp, the otel resource’s weft.version, the runtime registration’s weft_version |
version.Runtime() | The framework module version this binary was built from, read from debug.ReadBuildInfo: the main module’s version when the binary is weft’s own, else the github.com/weftgo/weft dependency’s, or its replacement’s when a replace names another version | /api/meta’s weft_version, /panel-config.json’s version, weft version’s output, the discovery file’s version, the weft mcp server’s version |
Runtime() falls back to Version whenever the build info names no release: no build info at all, (devel) (inside the workspace or a test), a replace by a local directory, a pseudo-version (v0.9.1-0.20260101120000-abcdef123456) or a version with +dirty build metadata. Those name a commit, not a tag, so the source’s own tag is the more honest answer.
Package weft
Section titled “Package weft”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft | The root package: the loop under the names user code imports, generated over core | weft.New, weft.Tool | weft concepts |
Package wefttest
Section titled “Package wefttest”| Import path | What it is | Start with | Explained in |
|---|---|---|---|
github.com/weftgo/weft/wefttest | The framework’s import path for the offline test double: a facade over core/wefttest | wefttest.Script | Test an agent with a scripted model |
github.com/weftgo/weft/core/wefttest | The test double itself: a scripted, deterministic Model, record and replay against a real provider, and helpers for events and golden files | wefttest.Replay | Record a real conversation once, replay it forever |