Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

untilFinishReason.md

38 lines718 Bytes

1---
2id: untilFinishReason
3title: untilFinishReason
4---
5​
6```ts
7function untilFinishReason(stopReasons): AgentLoopStrategy;
8```
9​
10Defined in: packages/ai/src/activities/chat/agent-loop-strategies.ts:47
11​
12Creates a strategy that continues until a specific finish reason is encountered
13​
14## Parameters
15​
16### stopReasons
17​
18`string`[]
19​
20Finish reasons that should stop the loop
21​
22## Returns
23​
24[`AgentLoopStrategy`](../type-aliases/AgentLoopStrategy.md)
25​
26AgentLoopStrategy that stops on specific finish reasons
27​
28## Example
29​
30```typescript
31const stream = chat({
32 adapter: openaiText("gpt-6.1-sol"),
33 threadId: "thread-1",
34 messages: [...],
35 tools: [weatherTool],
36 agentLoopStrategy: untilFinishReason(["stop", "length"]),
37});
38```