Compiled Prompts
A Compiled Prompt is a reusable, versioned prompt template that lives inside a
A Compiled Prompt is a reusable, versioned prompt template that lives inside a workspace. Instead of hardcoding prompts in your application, you store them in the brain, version them, and assemble them at runtime — optionally grounded with recalled claims.
Why store prompts in the brain
- Editable without redeploying — change an assistant's persona, tone, or rules from the Console; your app picks it up immediately.
- Versioned — every save is a new version; you can inspect history and roll back.
- Grounded assembly — a prompt can be assembled together with retrieved claims so the model always sees fresh, cited context, not a stale hardcoded blob.
Storing and reading a prompt
# store / update a template (creates a new version)
PUT /api/v1/ws/{ws}/prompts # body: { "name": "...", "template_text": "..." }
# read the latest, list versions, or assemble with variables + retrieved context
GET /api/v1/ws/{ws}/prompts/{name}
GET /api/v1/ws/{ws}/prompts/{name}/versions
POST /api/v1/ws/{ws}/prompts/{name}/assembleTemplates reference variables with {{var}} syntax; assembling fills them in.
await brain.prompt.put("support-persona", "You are {{company}}'s support agent. Be concise.");
const text = await brain.prompt.assemble("support-persona", { company: "Acme" });Inside a Root Function: ctx.prompt(name, vars).
Capsules: compiled context frames
A capsule is a low-token, grounded context payload — the engine compiles a prompt together with the claims relevant to a query into a single cacheable frame. It is the efficient way to hand a model exactly the context it needs (deduplicated, cited) without dumping the whole corpus. Capsules can be cached and reused, and the savings are measurable.
The pattern
Keep prompts as data, not code. Your assistant's identity, your agents' instructions, your extraction rules — all live as Compiled Prompts in the workspace, versioned and grounded. Change behavior by editing a prompt, not by shipping a release.