session-startRequired
{ readonly instructions: string; }
Return { instructions } to append text to the system instructions of the turn.
before-promptRequired
{ readonly prompt: string; } | { readonly deny: string; }
Only the explicit before-prompt transformation shown in this type is accepted. never forbids a decision; throwing fails execution except while reporting an existing failure.
before-modelRequired
{ readonly messages?: readonly ModelMessage[]; readonly system?: string; }
Replace messages or system instructions for this request. Message validation preserves replayable reasoning; typed response instructions remain final.
after-modelRequired
{ readonly result: Pick<ModelResult, "text" | "content"> & { readonly usage?: never; readonly stopReason?: never; }; }
Replace text and optionally content passed to the loop. Original usage, refusals and output limits remain effective; injected tool calls still require permissions.
model-errorRequired
never
Only the explicit model-error transformation shown in this type is accepted. never forbids a decision; throwing fails execution except while reporting an existing failure.
before-compactionRequired
{ readonly messages: readonly ModelMessage[]; }
Only the explicit before-compaction transformation shown in this type is accepted. never forbids a decision; throwing fails execution except while reporting an existing failure.
after-compactionRequired
{ readonly messages: readonly ModelMessage[]; }
Only the explicit after-compaction transformation shown in this type is accepted. never forbids a decision; throwing fails execution except while reporting an existing failure.
before-subagentRequired
{ readonly prompt: string; } | { readonly deny: string; }
Only the explicit before-subagent transformation shown in this type is accepted. never forbids a decision; throwing fails execution except while reporting an existing failure.
after-subagentRequired
{ readonly text: string; }
Only the explicit after-subagent transformation shown in this type is accepted. never forbids a decision; throwing fails execution except while reporting an existing failure.
run-endRequired
never
Only the explicit run-end transformation shown in this type is accepted. never forbids a decision; throwing fails execution except while reporting an existing failure.
before-toolRequired
{ readonly deny: string; } | { readonly input: unknown; }
Return { deny } with a nonempty reason to refuse the call and skip later hooks, or { input } to pass a replacement to the next hook. The final input is validated and checked against permissions again.
after-toolRequired
{ readonly result: ToolOutput; }
Return { result } with text or { content, isError } to replace what the model receives; later hooks see the replacement.
stopRequired
{ readonly continue: string; }
Return { continue } with a nonempty message to refuse the final answer; the message becomes the next user message and later stop hooks are skipped. Bounded by maxSteps.