Skip to content

Go API reference (pkg.go.dev)

View as Markdown

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.

ModuleHoldsGet itGodoc
github.com/weftgo/weftThe root package weft and every package below except core’sgo get github.com/weftgo/weft@v0.20.2weft@v0.20.2
github.com/weftgo/weft/coreThe loop (core), core/mw, core/wefttest, core/wefttest/conformancego get github.com/weftgo/weft/core@v0.20.2core@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.

LayerPackages
The loopweft, core
Providersopenai, anthropic, google
Tools and middlewaremcp, mw
Testingwefttest, conformance
Sessionsthread, jsonl, sqlite (thread’s), pool, backend, threadtest
Recordingotel, obsdb, sqlite (obsdb’s), clickhouse, obsdbtest
Studio and the playgroundstudio, ingest, runtime (both sides), scope
The binary and its versionweft command, version

Packages under internal/ and the example programs are not importable API and are not listed.

Import pathWhat it isStart withExplained in
github.com/weftgo/weft/anthropicThe adapter for the Anthropic Messages API, over the official anthropic-sdk-goanthropic.ModelConnect a model provider
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/thread/backendFor 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 itbackend.ResolveWrite your own thread.Storage
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/obsdb/clickhouseobsdb’s hosted backend: the observability schema as ClickHouse tables, column-compatible with the OTel Collector’s ClickHouse exporterclickhouse.OpenChoose the observability database
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/cmd/weftThe framework’s one binary: a local Studio (weft studio, weft dev) and a terminal over the Studio APIgo install github.com/weftgo/weft/cmd/weft@v0.20.2weft CLI reference
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/wefttest/conformanceThe framework’s import path for the adapter conformance suite: a facade over core’sconformance.RunProve a provider adapter
github.com/weftgo/weft/core/wefttest/conformanceThe suite itself: drives a Model through the behaviours every provider adapter must shareconformance.RunProve a provider adapter
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/coreThe 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 alonecore.NewInstall weft and choose a module
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/googleThe adapter for the Gemini API, over the official google.golang.org/genai SDKgoogle.ModelConnect a model provider
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/studio/ingestStudio’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.LogsInspect agents written in other languages
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/thread/jsonlThe default durable thread.Storage: one directory, one <id>.jsonl file per session, the header line first, then one entry per line in append orderjsonl.OpenStore sessions
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/mcpThe 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 servermcp.Tools, mcp.ServeUse MCP both ways
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/mwThe framework’s import path for the reference middleware: a facade over core/mwmw.RetryAdd behaviour with middleware
github.com/weftgo/weft/core/mwThe middleware itself: model middleware for WrapModel (Retry, Fallback, Log, RepairJSON) and tool middleware for WrapTools (Allow, Audit, MapErrors)mw.FallbackRetry and fall back
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/obsdbThe 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 laneobsdb.DBobsdb: reading the observability database from Go
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/obsdb/obsdbtestThe conformance table every obsdb.DB backend runs; Run takes a factory so each subtest gets a fresh databaseobsdbtest.RunChoose the observability database
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/openaiThe adapter for the OpenAI Chat Completions API and OpenAI-compatible servers, over the official openai-go SDKopenai.ModelConnect a model provider
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/otelWires 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 policyotel.InstallRecord every run with otel.Install
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/thread/poolBounded 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 delegationpool.NewRun bounded child sessions with a pool

Two packages share the name: the app side, which you import, and Studio’s side of the same link.

Import pathWhat it isStart withExplained in
github.com/weftgo/weft/runtimeThe 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 processruntime.InstallConnect your app to Studio’s playground
github.com/weftgo/weft/studio/runtimeThe 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.NewHow does the playground work?
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/scopeThe 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 headerscope.HeaderScope the panel to a conversation

Two packages share the name: one stores sessions, the other the observability database. Both use the CGO-free modernc.org/sqlite driver.

Import pathWhat it isStart withExplained in
github.com/weftgo/weft/thread/sqliteThe thread’s second durable backend: every session in one SQLite file, with WAL and embedded migrations; by default every commit is fsyncedsqlite.OpenStore sessions
github.com/weftgo/weft/obsdb/sqliteobsdb’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 lanesqlite.OpenChoose the observability database
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/studioThe 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.HandlerRun Studio
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/threadSessions: 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 changethread.Create, thread.SessionWhat is a session?
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/thread/threadtestThe conformance table every thread.Storage backend runs before it may call itself a backend, plus crash harnessesthreadtest.RunWrite your own thread.Storage
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/versionweft’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 registrationversion.VersionUpgrade weft

The package has two names. Call version.Runtime() when your binary reports which weft it runs; the package example ExampleRuntime prints it.

NameReturnsWhere weft uses it
version.VersionThe constant tag the source carries, "v0.20.2"; it changes only with a releasestudio.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.

Import pathWhat it isStart withExplained in
github.com/weftgo/weftThe root package: the loop under the names user code imports, generated over coreweft.New, weft.Toolweft concepts
Import pathWhat it isStart withExplained in
github.com/weftgo/weft/wefttestThe framework’s import path for the offline test double: a facade over core/wefttestwefttest.ScriptTest an agent with a scripted model
github.com/weftgo/weft/core/wefttestThe test double itself: a scripted, deterministic Model, record and replay against a real provider, and helpers for events and golden fileswefttest.ReplayRecord a real conversation once, replay it forever