Interface GenerationHookResult

Context available to post-generation hooks. Hooks may return a modified copy to transform the generation output.

interface GenerationHookResult {
    text: string;
    toolCalls: ToolCallRecord[];
    usage: TokenUsage;
    step: number;
    cacheDiagnostics?: null | CacheDiagnostics;
}

Properties

text: string

Generated text from the LLM.

toolCalls: ToolCallRecord[]

Tool calls requested by the LLM.

usage: TokenUsage

Token usage for this step.

step: number

Current agentic step index (0-based).

cacheDiagnostics?: null | CacheDiagnostics

Cache-diagnostics verdict for THIS step (Anthropic beta; present only when the run opted in via GenerateTextOptions.cacheDiagnostics). null = this step's request matched the previous one (cached prefix stable). A populated cacheMissReason names the earliest divergence — log it: it is the direct answer to "why did this step miss the cache".