---
title: Describe your agents in weft.json (the manifest)
description: Generate weft.json with weft.Manifest, keep it current with a wefttest.Golden test, and serve it to Studio's Agents page, where stored manifests and proposed prompts build on it.
url: https://weftgo.dev/docs/guides/manifest/
type: how-to
sources:
  - 'W11-auditB2-fix, v0.20.2: weft/studio/web/src/lib/saves.ts:97-120, 133 (keepPromptWords)'
  - 'W11-auditB1-fix, v0.20.2: weft/core/manifest.go:254-306 (sourceRel: a main package by mainPath, else main/f.go; mainPath empty for command-line-arguments, a go run of files); weft/cmd/weft/dev.go:95-98 (weft dev -h: run a package, never go run main.go); weft/studio/web/src/routes/agents.index.tsx:40-54, 74-85, 150-175 (?agent= scrolled to, ringed, opened; ?window=); weft/studio/web/src/lib/stats.ts:16-21 (24h, 7d); weft/studio/web/src/panel/element.ts:3034-3042 (the header''s agent name links agentsLink)'
  - 'weft/studio/web/src/lib/policy.ts:1-4 (every policy field a chip with a title), 19-38 (bytesWords, capChip), 41-116 (agentPolicyChips: parallelism, max steps, retries, cap, timeout, strict input, loops, stops when, usage ≤), 119-159 (toolPolicyChips: timeout, sequential, approval, strict input, cap, subagent)'
  - weft/studio/web/src/components/studio/agent-cards.tsx:91, 144 (the tool and agent chips)
  - 'weft/studio/web/src/lib/format.ts:62-68 (tokens: 25.0k)'
  - weft/studio/README.md:2490-2493 (every chip titled with what it does and the option that set it)
  - 'weft/core/manifest.go:213-229 (durationName; toolTimeoutName: a set tool timeout renders even at 0s)'
  - weft/core/manifest.go:15-49 (Manifest), 51-145 (the document's fields), 231-300 (stop names, source file:line)
  - 'weft/core/manifest.go:123-127 (Subagent: the manifest does not recurse into the child; omitempty), 192 (Subagent: t.subagent)'
  - 'weft/core/subagent.go:344 (t.subagent = child.name: empty for an unnamed child)'
  - weft/core/agent.go:424-427 (Name), 750-759 (manifest hash computed at New)
  - weft/core/message.go:8-13 (SchemaVersion)
  - weft/core/wefttest/golden.go:13-34 (Golden, -update)
  - weft/docs/adr/0012-manifest-format.md
  - weft/AGENTS.md:69 (Name), 192-193 (block 5), 243-253 (block 7 manifest routes)
  - weft/README.md:789-811 (The manifest)
  - weft/example_test.go:118 (ExampleManifest)
  - weft/studio/studio.go:129-136 (studio.Manifest)
  - weft/studio/manifest.go:14-21, 172-208 (api/manifest, sources, 404)
  - weft/studio/meta.go:193-214, 388-442 (manifest_check)
  - weft/studio/manifests.go:13-27, 76-92 (api/manifests/{hash})
  - weft/studio/proposals.go:16-44, 158-185 (proposals)
  - weft/cmd/weft/main.go:449-450, 516-550 (--manifest, WEFT_MANIFEST, found upward)
  - weft/studio/web/src/routes/agents.index.tsx:1-40 (the Agents page)
  - 'weft/studio/web/src/routes/agents.index.tsx:303-310 (sourceState: weft.json, live, remembered · runtime gone; shortHash 12), 312-349 (SourceList: service, hash, state, runtime id, registered), 403-481 (Proposed: registered → proposed, since, hash, copy proposed, withdraw disabled with the dev-token hint, the diff)'
  - 'weft/studio/web/src/lib/saves.ts:133 (a proposal needs the dev token: the disabled button''s title, routes/agents.index.tsx:236, 272-280, mayProposeWith over caps and the token), 214-223 (copied, withdrawn, withdraw refused)'
  - 'weft/studio/web/src/lib/request-pane.ts:261-301 (proposalOf: snippets stripped when verified, else proposed as recorded with a note)'
  - weft/studio/manifests.go:50-56 (the weft.json stored once at New); weft/studio/studio.go:287
  - weft/studio/README.md:3369-3374 (a weft.json rewritten while Studio runs)
  - weft/CHANGELOG.md:351, 975, 1212, 2414, 2499, 5411, 6342
  - docs-site/examples/manifest/main.go, main_test.go TestManifest, TestRun, TestRunsCarryManifestHash, TestDuplicateNames
  - 'weft/core/manifest.go:60-90 (model_middleware, tool_middleware, hooks), 134 (a tool''s middleware), 250-310 (sourceRel: the import-path form, no go.mod, main by its build-info path) — v0.20.2; weft/CHANGELOG.md:70 (0.20.0 breaking: the source form, middleware and hooks listed). The example''s weft.json golden regenerates at the bump: TestManifest at rc reads weftgo.dev/docs/examples/manifest/main.go:32 and :38'
---

# Describe your agents in weft.json (the manifest)

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

```go title="manifest/main_test.go"
// TestManifest keeps weft.json current: a tool or policy change without
// regenerating fails go test. Regenerate: go test ./manifest -update
func TestManifest(t *testing.T) {
	b, err := weft.Manifest(newAgent())
	if err != nil {
		t.Fatal(err)
	}
	wefttest.Golden(t, "weft.json", b)
}
```

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

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

Build the agent in one function that both the program and the test call, and give it a name with [`weft.Name`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Name):

```go title="manifest/main.go"
// 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)
}
```

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

Regenerate the file after a change, then commit it:

```sh
go test ./manifest -update
```

The `-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:

```go title="manifest/main.go"
_, err = weft.Manifest(weft.New(wefttest.Script()))
fmt.Fprintln(w, "unnamed:", err)
```

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

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

### What the file holds

This is `manifest/weft.json`, the file the test keeps current:

```json
{
  "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": 1` is the format version. It changes only on a breaking shape change; new fields are added without a bump ([ADR 0012](https://github.com/weftgo/weft/blob/v0.20.2/docs/adr/0012-manifest-format.md)). It is not [`weft.SchemaVersion`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#SchemaVersion), which versions the message wire format: the JSON of `Message` and its parts, which persistence layers envelope.
- Each agent has `name`, `model`, `instructions` (when set: the construction-time prompt; a run-level `weft.Instructions` does not change it) and `policy`: `parallelism`, `max_steps`, `max_result_bytes` and `max_model_retries` always, the rest when set. Stop conditions are named (`has_tool_call:refund_order`, `step_count_is:3`); a custom function reads `custom`.
- Each tool has its `name`, `description` when set, `input_schema`, `output_schema` when it has one (a verbatim `string` result has none) and, only when set, its own policy: `timeout`, `max_result_bytes`, `strict_input`, `sequential`, `require_approval`, `replay_policy` (written only for `safe`), `prompt_snippet`, and `subagent` for a [`weft.Subagent`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Subagent) tool, naming the child agent. `Manifest` does not recurse into the child: it is described only when you pass it to `Manifest` too, and `subagent` is omitted when the child has no `weft.Name`.
- `source` is the `weft.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 no `go.mod` is consulted; before, it was relative to the nearest `go.mod` (`manifest/main.go:32`). For a `main` package the import path is the binary's build-info path, such as `weftgo.dev/docs/examples/manifest`; a build without one, `go run main.go`, reads `main/main.go:32`. A [`weft.RawTool`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#RawTool) has none. The line moves with edits; that churn is expected.
- Since 0.20.0 an agent also lists its `model_middleware` and `tool_middleware`, outer to inner, and its `hooks` (`prepare_step`, `tap`, `on_run_end`, `tool_source`), each `{name, params?, source?, opaque?}`. An agent built with `weft.Params` lists its sampling knobs as `params` (`temperature`, `top_p`, `max_tokens`, `stop`, `seed`), which Studio compares a run's overrides against. A tool lists its own `middleware`. A closure reads `func@<dir>/<file>:<line>` ([The onion in the record](https://weftgo.dev/docs/guides/middleware/#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

`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)`.

```go title="manifest/main.go"
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])
```

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

## 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:

1. **A `weft.json` file.** In setup A pass the bytes with [`studio.Manifest`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#Manifest). With `weft studio` or `weft dev`, the file is `--manifest`, else `WEFT_MANIFEST`, else the nearest `weft.json` from 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.
2. **Runtime registrations.** Without a file, Studio shows the manifests your app's `runtime.Install` registers over the [playground](https://weftgo.dev/docs/observe/playground/connect/) link. It remembers each by (service, manifest hash) in memory, so a restart forgets them until the runtime registers again.

```sh
weft studio --manifest weft.json
```

A 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](https://weftgo.dev/docs/reference/studio-urls/#agents-runtimes-and-experiment-parameters) 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.

![The support-bot card on Studio's Agents page, drawn from weft.json: its numbers over the last 24 hours (runs, failed, duration p50 and p95, first token, tokens, cost unpriced, retried, denials), the stale manifest badge, its policy chips and the lookup_order and refund_order tool cards with their schemas, source lines and per-tool calls, failure rate and latency](https://weftgo.dev/docs/_astro/studio-agents.light.BVg8mYUa.webp)

*The Agents page over this guide's weft.json: support-bot's numbers, its policy chips and its two tool cards, each with its schema, source line and call numbers.*

### 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

`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

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

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`.

```text
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/manifest` serves 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](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#PromptSnippet) 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

`manifest/main.go` builds the agent, prints its manifest and hash, and shows the unnamed-agent error; `main_test.go` holds the golden test:

```go title="manifest/main.go"
// 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)
	}
}
```

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

[View on GitHub](https://github.com/weftgo/weftgo.dev/tree/main/docs-site/examples/manifest) · run it from `docs-site/examples`:

```sh
go run ./manifest
go test ./manifest
```

```text
{
  "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: 7d00e7f2dfbd
unnamed: weft: Manifest: agent 0 has no name (set one with the Name option)
```

## Best practices & gotchas

- **Gate the file with a golden test, not a build step.** A `go:generate` step is one nobody runs; a golden test fails exactly when the committed file lies. (Source: ADR 0012, Alternatives considered)
- **Name every agent you describe.** `Manifest` errors on an unnamed or duplicate name, and an unnamed agent's runs carry no `weft.manifest.hash`. (Source: `weft/core/manifest.go:28-42`, `weft/core/agent.go:750-759`, `weft/core/loop.go:140`)
- **Put `-update` after 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 the `subagent` name 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 read `main/…`. Its manifest hash then differs from the committed `weft.json`'s, and its runs read stale against the file. Use `go run .`, `go run ./cmd/app` or a module build; `weft dev -h` says the same. (Source: `weft/core/manifest.go:250-310`; `weft/cmd/weft/dev.go:95-98`)
- **Expect `source` lines 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 0s` chip as no deadline.** A tool built with `weft.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

- [Studio setup](https://weftgo.dev/docs/observe/studio/setup/)
- [Connect your app to the playground](https://weftgo.dev/docs/observe/playground/connect/)
- [Set per-tool policy](https://weftgo.dev/docs/guides/tool-policy/): the policy keys the manifest records
- [Studio API reference](https://weftgo.dev/docs/reference/studio-api/)

Symbols used: [`weft.Manifest`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Manifest) · [`weft.Name`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Name) · [`weft.SchemaVersion`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#SchemaVersion) · [`weft.Tool`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Tool) · [`weft.RawTool`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#RawTool) · [`weft.Subagent`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Subagent) · [`weft.Timeout`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Timeout) · [`weft.Replay`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Replay) · [`weft.RequireApproval`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#RequireApproval) · [`weft.PromptSnippet`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#PromptSnippet) · [`weft.StopWhen`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#StopWhen) · [`weft.HasToolCall`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#HasToolCall) · [`weft.MaxSteps`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#MaxSteps) · [`weft.Instructions`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Instructions) · [`wefttest.Golden`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/wefttest#Golden) · [`studio.Manifest`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#Manifest) · [`obsdb.ManifestStore`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/obsdb#ManifestStore) · [`ExampleManifest`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#example-Manifest)
