Instructions
Static instruction strings and dynamic patches from before hooks.
Instructions are what the model reads before it answers. A generated agent
sets them on Agent({ ... }):
export const assistant = Agent({
id: "assistant",
name: "Order assistant",
instructions:
"Help with orders. Always use lookup_order for order questions.",
}).build();instructions accepts one string or an ordered list. A string is normalized
to a one-element array at build. Top-level instructions compile as capability
id "agent". Named capabilities can add their own:
capability({
id: "support",
instructions: "Ask for an order number before using find_order.",
tools: [findOrder],
})Dynamic instructions
A before("turn") or before("step") hook can return a Patch with extra
instructions. Turn-scoped patches apply to every model call in that turn;
step-scoped patches apply to that model call only.
export const support = Agent({
id: "support",
instructions: "Help with orders.",
})
.before("turn", ({ info }) => ({
instructions: [`Tenant ${info?.tenantId ?? "unknown"}`],
}))
.build();info is host identity from the Runtime session. It is not model-visible
unless a hook copies it into instructions. See Hooks.
Do not put secrets in instructions, manifests, or hook patches that become history.