Skip to content

Instructions

defineInstruction(options: InstructionOptions): AgentInstruction
import { defineInstruction } from 'agentfootprint/instructions';
const instruction = defineInstruction({
id: 'refund-handling',
activeWhen: (decision) => decision.orderStatus === 'cancelled',
prompt: 'Handle with empathy. Offer refund.',
tools: [processRefundTool],
safety: false,
onToolResult: [{
id: 'empathy',
text: 'Do NOT promise reversal.',
decide: (decision, ctx) => {
decision.refundRequested = true;
},
}],
});
FieldTypeDescription
idstringUnique instruction identifier
activeWhen(decision) => booleanPredicate — when to activate
promptstringInjected into system prompt
toolsToolDefinition[]Added to available tools
safetybooleanFail-closed, unsuppressable
onToolResultToolResultInstruction[]Injected after tool results
FieldTypeDescription
idstringMatches tool ID
textstringInjected text
decide(decision, ctx) => voidMutate Decision Scope
import { AgentPattern } from 'agentfootprint/instructions';
AgentPattern.Regular // default — slots evaluated once
AgentPattern.Dynamic // re-evaluate all slots each iteration
agent
.instruction(inst) // add one instruction
.instructions([inst1, inst2]) // add multiple
.decision({ key: null }) // initial Decision Scope
.pattern(AgentPattern.Dynamic) // enable re-evaluation