/** * Reflection Loop Pattern * * Enables AI agents to self-critique and iteratively improve their responses. * The AI generates a response, reflects on it, and regenerates based on feedback * until a target quality score is reached or max iterations is hit. * * @example * ```typescript * const result = await reflectionLoop({ * execute: async (ctx) => { * const prompt = ctx.iteration === 1 * ? 'Write a blog post about TypeScript' * : `Previous: ${ctx.previousResponse} * Feedback: ${ctx.previousCritique?.feedback} * Improve based on this feedback.`; * return await generateText({ prompt }); * }, * reflect: async (text) => { * const critique = await generateText({ * prompt: `Rate this (1-10) and suggest improvements: ${text}` * }); * return { * score: extractScore(critique), * feedback: critique, * shouldContinue: extractScore(critique) < 8 * }; * }, * maxIterations: 5, * targetScore: 8 * }); * ``` */ import type { ReflectionLoopConfig, ReflectionLoopResult, ReflectionIteration, ReflectionHistoryStorage } from "../types/reflection-loop"; /** * In-memory storage implementation for reflection history using GlobalStorage */ export declare class InMemoryReflectionStorage implements ReflectionHistoryStorage { private storage; private readonly namespace; constructor(); save(sessionId: string, iteration: ReflectionIteration): Promise; load(sessionId: string): Promise[]>; delete(sessionId: string): Promise; listSessions(): Promise; } /** * Execute a reflection loop where the AI iteratively improves its response * through self-critique and regeneration. */ export declare function reflectionLoop(config: ReflectionLoopConfig): Promise>; //# sourceMappingURL=reflection-loop.d.ts.map