Docs
CodeRabbit
Cloudflare
AG Grid
Netlify
Neon
WorkOS
Clerk
Convex
Electric
PowerSync
Sentry
Prisma
Strapi
Unkey
Fireship
CodeRabbit
Cloudflare
AG Grid
Netlify
Neon
WorkOS
Clerk
Convex
Electric
PowerSync
Sentry
Prisma
Strapi
Unkey
Fireship
Class References
Function References
Interface References
Type Alias References
Variable References
Function References

untilFinishReason

Function: untilFinishReason()

ts
function untilFinishReason(stopReasons): AgentLoopStrategy;

Defined in: activities/chat/agent-loop-strategies.ts:41

Creates a strategy that continues until a specific finish reason is encountered

Parameters

stopReasons

string[]

Finish reasons that should stop the loop

Returns

AgentLoopStrategy

AgentLoopStrategy that stops on specific finish reasons

Example

typescript
const stream = chat({
  adapter: openaiText(),
  model: "gpt-5.2",
  messages: [...],
  tools: [weatherTool],
  agentLoopStrategy: untilFinishReason(["stop", "length"]),
});