/** * Reflexion memory for loop phases — pure helpers. * * When a loop phase sets `reflexion: true`, each iteration i > 1 receives a * `{reflexion}` placeholder carrying a structured failure summary of the * immediately-prior iteration: what happened (contract violation / subagent * error / until-not-met), the precise diagnostics, and a truncated output * snippet. The model iterates WITH the failure signal instead of re-guessing * from a bare output (Reflexion, Shinn et al. 2023 — as a declarative field). * * Pure and total: assembly never throws on any input (the runtime additionally * wraps the call fail-open — a reflexion bug must never sink the phase). */ /** Cap on the assembled reflexion block (chars). Keeps the injected context * from crowding out the actual task in the iteration prompt. */ export declare const REFLEXION_MAX_CHARS = 2000; /** What iteration 1 sees: there is no prior iteration to reflect on. */ export declare const REFLEXION_SENTINEL = "_(first iteration \u2014 no prior feedback yet)_"; /** How the prior iteration ended, for the summary headline. */ export type ReflexionOutcome = "until-not-met" | "contract-violation" | "subagent-error"; export interface ReflexionInput { /** 1-based index of the PRIOR iteration being summarized. */ iteration: number; outcome: ReflexionOutcome; /** The prior iteration's raw output (or error-bearing output on failure). */ output?: string; /** errorMessage of a failed prior iteration (contract diagnostics live here). */ errorMessage?: string; /** The loop's `until` expression (shown when outcome is until-not-met). */ until?: string; } /** * Build the reflexion summary block injected into the next iteration's prompt. * Sections are conditional — no empty headings. Total: never throws. */ export declare function buildReflexionSummary(input: ReflexionInput, maxChars?: number): string; /** * Pull the per-path diagnostics out of a runOne contract-violation * errorMessage ("Output contract violated:\n- $.score: …\n- …"). * Returns [] for any other error shape. */ export declare function extractContractDiagnostics(errorMessage?: string): string[]; /** True when the errorMessage carries a contract violation (classification * for ReflexionInput.outcome). */ export declare function isContractViolation(errorMessage?: string): boolean; //# sourceMappingURL=reflexion.d.ts.map