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

AgentLoopState.md

77 lines1.7 KB

1---
2id: AgentLoopState
3title: AgentLoopState
4---
5​
6# Interface: AgentLoopState
7​
8Defined in: [packages/ai/src/types.ts:833](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L833)
9​
10State passed to agent loop strategy for determining whether to continue
11​
12## Properties
13​
14### finishReason
15​
16```ts
17finishReason: string | null;
18```
19​
20Defined in: [packages/ai/src/types.ts:839](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L839)
21​
22Finish reason from the last response
23​
24***
25​
26### iterationCount
27​
28```ts
29iterationCount: number;
30```
31​
32Defined in: [packages/ai/src/types.ts:835](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L835)
33​
34Current iteration count (0-indexed). One iteration = one model turn.
35​
36***
37​
38### lastTurnToolCallCount
39​
40```ts
41lastTurnToolCallCount: number;
42```
43​
44Defined in: [packages/ai/src/types.ts:851](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L851)
45​
46Tool calls in the most recent budgeted batch — a live model turn or a
47pending/resume batch (0 when the last phase produced no tool calls).
48​
49***
50​
51### messages
52​
53```ts
54messages: ModelMessage<
55 | string
56 | ContentPart<unknown, unknown, unknown, unknown, unknown>[]
57 | null>[];
58```
59​
60Defined in: [packages/ai/src/types.ts:837](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L837)
61​
62Current messages array
63​
64***
65​
66### toolCallCount
67​
68```ts
69toolCallCount: number;
70```
71​
72Defined in: [packages/ai/src/types.ts:846](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L846)
73​
74Cumulative tool calls counted so far in this run (model-emitted during the
75agent loop, including ones skipped by middleware, and pending tools from
76the inbound message list when resumed). Not a recount of full message
77history; not model turns.