Implement an evaluator-optimizer agent loop with the Vercel AI SDK where a critic LLM scores outputs and a generator LLM iterates until quality thresholds are met. This self-improving pattern produces significantly better outputs than single-pass generation for complex tasks.
- High-quality writing that iterates until tone, length, and clarity pass review
- Code generation with automated test and fix cycles
- Data extraction with validation-retry loops for structured accuracy
- Creative content that self-evaluates against scoring rubrics
Tech stack
Vercel AI SDKNext.jsTypeScriptZodAnthropic Claude
npx shadcn@latest add https://shadcnagents.com/r/ai-chat-agent-evaluator-optimizer-pattern