Describe your agents in weft.json (the manifest)
weft.Manifest renders your agents as weft.json: one generated, committed, diffable description of every agent and tool. The code stays the only source of truth; the file is output, never input, and nothing is configured from it. Generate it in a golden test so a stale file fails go test, and give it to Studio, whose Agents page draws it.
The golden test in manifest/main_test.go:
// TestManifest keeps weft.json current: a tool or policy change without// regenerating fails go test. Regenerate: go test ./manifest -updatefunc TestManifest(t *testing.T) { b, err := weft.Manifest(newAgent()) if err != nil { t.Fatal(err) } wefttest.Golden(t, "weft.json", b)}wefttest.Golden compares the bytes with the committed file. A tool or policy change without regenerating fails the test, and the diff is the review artifact.
Generate weft.json
Section titled “Generate weft.json”Build the agent in one function that both the program and the test call, and give it a name with weft.Name:
// newAgent builds the support agent; the app and the golden test both call it.func newAgent() *weft.Agent { lookup := weft.Tool("lookup_order", "Look up an order by ID.", func(_ context.Context, in LookupInput) (string, error) { return "order " + in.OrderID + " has shipped", nil }, weft.Timeout(5*time.Second), weft.Replay(weft.ReplaySafe)) refund := weft.Tool("refund_order", "Refund a customer's order.", func(_ context.Context, in RefundInput) (string, error) { return "refunded " + in.OrderID, nil }, weft.RequireApproval(), weft.PromptSnippet("Refund only after looking the order up.")) return weft.New(wefttest.Script(wefttest.Say("ok")), weft.Name("support-bot"), // the manifest requires a name weft.Instructions("You are a support agent."), weft.MaxSteps(8), weft.StopWhen(weft.HasToolCall("refund_order")), lookup, refund)}Regenerate the file after a change, then commit it:
go test ./manifest -updateThe -update flag goes after the package list: placed before it, the go tool routes it to the wrong package’s binary. With -update, Golden writes the file and logs which files it created or rewrote; an up-to-date file is left untouched. Without it, a missing file fails with the regenerate hint.
Manifest returns the bytes. It takes any number of agents and fails on a nil agent, an agent without a name, and two agents with the same name:
_, err = weft.Manifest(weft.New(wefttest.Script()))fmt.Fprintln(w, "unnamed:", err)unnamed: weft: Manifest: agent 0 has no name (set one with the Name option)The file is a review artifact, and agent_1 in a diff is noise. The package example is ExampleManifest.
What the file holds
Section titled “What the file holds”This is manifest/weft.json, the file the test keeps current:
{ "weft": 1, "agents": [ { "name": "support-bot", "model": { "provider": "wefttest", "name": "script" }, "instructions": "You are a support agent.", "policy": { "parallelism": 4, "max_steps": 8, "max_result_bytes": 65536, "stop_when": [ "has_tool_call:refund_order" ], "max_model_retries": 3 }, "tools": [ { "name": "lookup_order", "description": "Look up an order by ID.", "input_schema": { "type": "object", "properties": { "order_id": { "type": "string", "description": "the order to look up" } }, "required": [ "order_id" ] }, "timeout": "5s", "replay_policy": "safe", "source": "weftgo.dev/docs/examples/manifest/main.go:32" }, { "name": "refund_order", "description": "Refund a customer's order.", "input_schema": { "type": "object", "properties": { "order_id": { "type": "string", "description": "the order to refund" } }, "required": [ "order_id" ] }, "require_approval": true, "prompt_snippet": "Refund only after looking the order up.", "source": "weftgo.dev/docs/examples/manifest/main.go:38" } ] } ]}"weft": 1is the format version. It changes only on a breaking shape change; new fields are added without a bump (ADR 0012). It is notweft.SchemaVersion, which versions the message wire format: the JSON ofMessageand its parts, which persistence layers envelope.- Each agent has
name,model,instructions(when set: the construction-time prompt; a run-levelweft.Instructionsdoes not change it) andpolicy:parallelism,max_steps,max_result_bytesandmax_model_retriesalways, the rest when set. Stop conditions are named (has_tool_call:refund_order,step_count_is:3); a custom function readscustom. - Each tool has its
name,descriptionwhen set,input_schema,output_schemawhen it has one (a verbatimstringresult has none) and, only when set, its own policy:timeout,max_result_bytes,strict_input,sequential,require_approval,replay_policy(written only forsafe),prompt_snippet, andsubagentfor aweft.Subagenttool, naming the child agent.Manifestdoes not recurse into the child: it is described only when you pass it toManifesttoo, andsubagentis omitted when the child has noweft.Name. sourceis theweft.Tool(...)call site as<import path>/<file>:<line>: the defining package’s import path, the file’s base name and the line, with/separators on every OS. Since 0.20.0 it is the same on every machine, since nogo.modis consulted; before, it was relative to the nearestgo.mod(manifest/main.go:32). For amainpackage the import path is the binary’s build-info path, such asweftgo.dev/docs/examples/manifest; a build without one,go run main.go, readsmain/main.go:32. Aweft.RawToolhas none. The line moves with edits; that churn is expected.- Since 0.20.0 an agent also lists its
model_middlewareandtool_middleware, outer to inner, and itshooks(prepare_step,tap,on_run_end,tool_source), each{name, params?, source?, opaque?}. An agent built withweft.Paramslists its sampling knobs asparams(temperature,top_p,max_tokens,stop,seed), which Studio compares a run’s overrides against. A tool lists its ownmiddleware. A closure readsfunc@<dir>/<file>:<line>(The onion in the record). This guide’s agents have none, so the file above shows none.
The bytes are deterministic: tools keep registration order, agents argument order, and encoding/json sorts map keys. A ToolSource’s tools are runtime state, so the manifest does not list them; it names the hook that serves them.
The manifest hash
Section titled “The manifest hash”New computes the sha256 of a named agent’s one-agent manifest once, and every run of that agent carries it as weft.manifest.hash on its invoke_agent span and run_start record. It answers “which version of this agent ran”. TestRunsCarryManifestHash checks that the attribute equals the hash of weft.Manifest(agt).
b, err := weft.Manifest(newAgent())if err != nil { return err}w.Write(b)sum := sha256.Sum256(b) // a one-agent document's hash: its runs' weft.manifest.hashfmt.Fprintln(w, "sha256:", hex.EncodeToString(sum[:])[:12])Studio’s Agents page
Section titled “Studio’s Agents page”Studio’s Agents page (/agents/) draws the manifest as agent and tool cards: schemas as trees, per-tool policy chips, and each tool’s source file and line. Studio reads the agents from one of two sources:
- A
weft.jsonfile. In setup A pass the bytes withstudio.Manifest. Withweft studioorweft dev, the file is--manifest, elseWEFT_MANIFEST, else the nearestweft.jsonfrom the working directory upward. It is read once at start; a named file that cannot be read or does not parse is a start error. - Runtime registrations. Without a file, Studio shows the manifests your app’s
runtime.Installregisters over the playground link. It remembers each by (service, manifest hash) in memory, so a restart forgets them until the runtime registers again.
weft studio --manifest weft.jsonA link can open the page on one agent: /agents?agent=<name> scrolls to that agent’s card, rings it and opens it (0.20.0), and keeps the card in view while the numbers above it load and lay out, until you scroll (0.20.1). The devtools panel links its header’s agent name there. ?window=24h or ?window=7d picks the window of the numbers each card shows under the stats capability. Studio pages, URL parameters and keyboard lists both keys.
Above the cards, the page lists each source on one line: weft.json, or the registering service’s name; the manifest hash’s first 12 characters (the full hash on hover); its state, weft.json, live, or remembered · runtime gone; and, for a registration, the runtime id and when it registered, relative (registered 3m ago), the full stamp on hover.
The file wins when both exist. With neither, GET /api/manifest answers 404 with the reason and the UI hides the Agents nav. With --no-playground and no file, the Agents page, the playground and the run page’s replay controls say why they are off, from /api/meta’s capabilities_off; /api/meta’s manifest_sources counts the sources /api/manifest lists.


Policy chips
Section titled “Policy chips”Each agent card carries one chip per policy field of its manifest entry, and each tool card one per field the tool sets. Hover a chip for what it does and the option that set it.
| Chip | Card | Means |
|---|---|---|
parallelism n | agent | Up to n tool calls of one step run at once (Parallelism); at 1, one at a time (Parallelism(1) or Sequential()) |
max steps n | agent | The run fails with ErrMaxSteps rather than call the model an (n+1)th time (MaxSteps; default 10) |
retries n | agent | Consecutive RETRY results one tool may return before the run fails with ErrModelRetriesExceeded (MaxModelRetries; default 3) |
cap 64 KiB, cap off | agent, tool | A tool result longer than the cap is cut, with a marker the model sees (MaxResultBytes); cap off is MaxResultBytes(0). On a tool card only when the tool sets its own |
timeout 30s | agent, tool | A tool call still running after it becomes an error result (Timeout) |
strict input | agent, tool | Arguments with fields the input struct does not declare are rejected (StrictInput) |
loops n | agent | n consecutive steps asking for the same tool calls fail the run with ErrLoopDetected (DetectLoops) |
stops when … | agent | One per StopWhen condition, as the manifest names it: stops when has_tool_call:submit, stops when output_submitted. The run ends successfully once it holds; MaxSteps is the budget behind it |
usage ≤ 25.0k in / 50.0k out | agent | The run fails with ErrUsageLimit before a model call once its tokens, subagents included, pass either figure (UsageLimit; a zero field is no limit and is left out) |
sequential | tool | The tool’s call runs alone, a barrier between the calls before and after it (Sequential on the tool) |
approval | tool | A call parks the run until it is approved or denied (RequireApproval) |
subagent: name | tool | The call runs the agent name as a child run (Subagent) |
Chips that are off are not drawn: no timeout, strict input, loops, stops when or usage chip appears unless the option was set.
The manifest API
Section titled “The manifest API”GET /api/manifest returns the file’s own bytes with a sources key appended, or the registered agents merged into one document. Each entry of sources[] names its source (file or runtime), its manifest_hash and its agents with their own hashes; a registered source also carries its service, runtime_id, registered_at and live, true while a connected runtime holds it. A remembered source is never shown as live, and two services that register one agent name in different versions both appear. The manifest carries every agent’s system prompt, so a read-scoped panel token is refused (403, badge hidden).
/api/meta’s manifest_check compares each manifest agent’s hash with the weft.manifest.hash of that agent’s latest stored run: source, agents, checked, stale (agents whose latest run ran another version) and differs (agents registered in several versions). It is given to the dev token, or to setup A’s loopback; weft doctor prints it.
Stored manifests
Section titled “Stored manifests”GET /api/manifests/{hash} (capability manifests) answers the configuration a run’s manifest_hash names, after it stopped being the current one: {manifest_hash, agent, source, first_seen, current_manifest_hash, manifest}. current_manifest_hash is the hash the current manifest gives that agent, "" when it names no such agent. The run document carries manifest_available: true when its hash resolves.
Studio writes the store from both sources: each agent of the weft.json at New, and every runtime registration. A weft.json rewritten while Studio runs is stored only after the next restart, or when an app running that configuration next registers; under weft dev an app with runtime.Install registers again on every save-and-restart. The DB must implement obsdb.ManifestStore, which both first-party backends do. Entries are content-addressed, the first write is kept, and they are kept forever: DELETE /api/runs/{id}, DELETE /api/sessions/{id} and the retention sweeper never touch them. The route follows /api/manifest’s rule for read tokens.
Proposed prompts
Section titled “Proposed prompts”When you edit an agent’s prompt in the playground or the devtools panel, “keep as prompt” copies it to the clipboard, and Studio also remembers it as the agent’s proposed instructions. The Agents page shows it as “proposed” next to “registered”, and GET /api/manifest carries it on the agent as proposed: {instructions, instructions_hash, since}. Nothing reaches the app or your files. The page says so above the cards, ending “to keep it, copy it into the agent’s weft.Instructions(…) in your code”; do that, then regenerate weft.json.
PUT /api/agents/{name}/proposal {"instructions": "..."}DELETE /api/agents/{name}/proposal- Capability
proposals, for the dev token or setup A’s loopback; every panel token gets 403. - An agent no manifest names is 404. While a file is served, an agent only a runtime registered is 409:
/api/manifestserves the file, so the proposal would not show. - Proposals live in memory: at most 64 agents, the oldest forgotten first, all forgotten on restart.
With no agent registered, “keep as prompt” says “copy the edited prompt” and only copies: there is no agent to propose to. Otherwise its toast says what happened in two parts, the copy (copied, or copy failed — the browser refused the clipboard) and the proposal: copied · proposed as <agent>'s instructions (see Agents), copied · proposal refused: <reason> in the server’s words, or, where it may only copy (a panel token, or no proposals capability), copied · a proposal needs the dev token.
On the Agents page, an agent with a proposal shows a registered → proposed block: the proposal’s since and the first 12 characters of its hash (the full hash on hover), the line diff from the registered instructions to the proposed ones, and two buttons. copy proposed copies the proposed text (“copied”). withdraw sends the DELETE (proposal for <agent> withdrawn, or withdraw refused: … in the server’s words); under a panel token, or when the proposals capability is off, it is disabled, its tooltip reading “a proposal needs the dev token”.
keep as prompt beside a step’s system prompt in the run page’s Request pane proposes the agent’s instructions, not the composed prompt the model saw. When the manifest verifies the run’s agent (its weft.manifest.hash) and the offered tools’ PromptSnippets end the recorded prompt, Studio strips them: adopting the composed prompt as Instructions would compose them twice. Otherwise the text goes as recorded, and the toast adds what it may carry, such as “proposed as recorded: may include 2 tool snippets or a PrepareStep rewrite (the manifest does not verify this run’s agent)”.
Complete example
Section titled “Complete example”manifest/main.go builds the agent, prints its manifest and hash, and shows the unnamed-agent error; main_test.go holds the golden test:
// Command manifest runs the examples of the guide "Describe your agents// in weft.json (the manifest)": go run ./manifest prints the manifest the// golden test in main_test.go keeps committed as manifest/weft.json.package main
import ( "context" "crypto/sha256" "encoding/hex" "fmt" "io" "os" "time"
"github.com/weftgo/weft" "github.com/weftgo/weft/wefttest")
// LookupInput is the lookup tool's input; its tags are the schema.type LookupInput struct { OrderID string `json:"order_id" jsonschema:"the order to look up"`}
// RefundInput is the refund tool's input.type RefundInput struct { OrderID string `json:"order_id" jsonschema:"the order to refund"`}
// newAgent builds the support agent; the app and the golden test both call it.func newAgent() *weft.Agent { lookup := weft.Tool("lookup_order", "Look up an order by ID.", func(_ context.Context, in LookupInput) (string, error) { return "order " + in.OrderID + " has shipped", nil }, weft.Timeout(5*time.Second), weft.Replay(weft.ReplaySafe)) refund := weft.Tool("refund_order", "Refund a customer's order.", func(_ context.Context, in RefundInput) (string, error) { return "refunded " + in.OrderID, nil }, weft.RequireApproval(), weft.PromptSnippet("Refund only after looking the order up.")) return weft.New(wefttest.Script(wefttest.Say("ok")), weft.Name("support-bot"), // the manifest requires a name weft.Instructions("You are a support agent."), weft.MaxSteps(8), weft.StopWhen(weft.HasToolCall("refund_order")), lookup, refund)}
func run(_ context.Context, w io.Writer) error { b, err := weft.Manifest(newAgent()) if err != nil { return err } w.Write(b) sum := sha256.Sum256(b) // a one-agent document's hash: its runs' weft.manifest.hash fmt.Fprintln(w, "sha256:", hex.EncodeToString(sum[:])[:12])
_, err = weft.Manifest(weft.New(wefttest.Script())) fmt.Fprintln(w, "unnamed:", err) return nil}
func main() { if err := run(context.Background(), os.Stdout); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) }}View on GitHub · run it from docs-site/examples:
go run ./manifestgo test ./manifest{ "weft": 1, "agents": [ { "name": "support-bot", "model": { "provider": "wefttest", "name": "script" }, "instructions": "You are a support agent.", "policy": { "parallelism": 4, "max_steps": 8, "max_result_bytes": 65536, "stop_when": [ "has_tool_call:refund_order" ], "max_model_retries": 3 }, "tools": [ { "name": "lookup_order", "description": "Look up an order by ID.", "input_schema": { "type": "object", "properties": { "order_id": { "type": "string", "description": "the order to look up" } }, "required": [ "order_id" ] }, "timeout": "5s", "replay_policy": "safe", "source": "weftgo.dev/docs/examples/manifest/main.go:32" }, { "name": "refund_order", "description": "Refund a customer's order.", "input_schema": { "type": "object", "properties": { "order_id": { "type": "string", "description": "the order to refund" } }, "required": [ "order_id" ] }, "require_approval": true, "prompt_snippet": "Refund only after looking the order up.", "source": "weftgo.dev/docs/examples/manifest/main.go:38" } ] } ]}sha256: 7d00e7f2dfbdunnamed: weft: Manifest: agent 0 has no name (set one with the Name option)Best practices & gotchas
Section titled “Best practices & gotchas”- Gate the file with a golden test, not a build step. A
go:generatestep is one nobody runs; a golden test fails exactly when the committed file lies. (Source: ADR 0012, Alternatives considered) - Name every agent you describe.
Manifesterrors on an unnamed or duplicate name, and an unnamed agent’s runs carry noweft.manifest.hash. (Source:weft/core/manifest.go:28-42,weft/core/agent.go:750-759,weft/core/loop.go:140) - Put
-updateafter the package list. Before it, the go tool hands the flag to the wrong binary. (Source:weft/core/wefttest/golden.go:19-26) - Pass every subagent’s agent to
Manifest. The file describes the agents it is given, not the fleet: a child you leave out appears only as thesubagentname on its parent’s tool, and an unnamed child not even that. (Source:weft/core/manifest.go:123-127, 192;weft/core/subagent.go:344) - Never read the manifest back as configuration. It is output; the agent is built from code. (Source: ADR 0012, Context)
- Build the binary from a package, never
go run main.go. A file list has no build info, so its sources readmain/…. Its manifest hash then differs from the committedweft.json’s, and its runs read stale against the file. Usego run .,go run ./cmd/appor a module build;weft dev -hsays the same. (Source:weft/core/manifest.go:250-310;weft/cmd/weft/dev.go:95-98) - Expect
sourcelines to churn. They move with every edit above the tool. The path part does not: it is the import path, never an absolute or machine-dependent one. (Source:weft/core/manifest.go:250-300, ADR 0012 decision 2) - A proposal does not say whether its snippets were stripped. The proposal body is the text alone, so the Agents page cannot tell a stripped prompt from one proposed as recorded; read the toast when you keep it. (Source:
studio/web/src/lib/request-pane.ts:261-301) - Read a tool’s
timeout 0schip as no deadline. A tool built withweft.Timeout(0)lifts the agent’s default, and the manifest records it as"0s"; the chip’s title still reads “this tool’s call still running after 0s becomes an error result”. (Source:weft/core/tool.go:500;weft/core/manifest.go:221-229;studio/web/src/lib/policy.ts:121-126) - Treat a proposal as a reminder, not a change. It lives in Studio’s memory only; the agent changes when your code does. (Source:
weft/studio/proposals.go:16-26)
See also
Section titled “See also”- Studio setup
- Connect your app to the playground
- Set per-tool policy: the policy keys the manifest records
- Studio API reference
Symbols used: weft.Manifest · weft.Name · weft.SchemaVersion · weft.Tool · weft.RawTool · weft.Subagent · weft.Timeout · weft.Replay · weft.RequireApproval · weft.PromptSnippet · weft.StopWhen · weft.HasToolCall · weft.MaxSteps · weft.Instructions · wefttest.Golden · studio.Manifest · obsdb.ManifestStore · ExampleManifest