evaluate( )

Pattern
Jev Loop Breaker
Look up facts one step at a time. Stop when Jev is at least 90% sure the notes answer the task, or after 3 lookups.
BeginnerSep 2026View the full pattern on desktop


Problems solved
- Stop a tool loop when accumulated notes complete the task
- Cap steps so a low probability cannot run forever
- Keep the done threshold in application code
Use cases
- Research loops that should stop when the answer is complete
- Step caps beside a model-judged done signal
- Teaching custom async stopWhen with Jev
AI SDK APIs
experimental_evaluategenerateTextstopWhengatewaytool
Tags
jevevaluationtyped-decisionsbooleanstop-whenai-sdk
Requirements
- Node.js
- 24+
- Memory
- 256MB
- Other
- Vercel AI Gateway API key
Environment variables
AI_GATEWAY_API_KEYGet key
External services
vercel-ai-gatewayupstash
Ready to use?
View the full interactive pattern with live preview and copy the source code.
View the pattern on desktop






