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

AbortInfo.md

56 lines1.8 KB

1---
2id: AbortInfo
3title: AbortInfo
4---
5​
6Defined in: [packages/ai/src/activities/chat/middleware/types.ts:521](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/middleware/types.ts#L521)
7​
8Information passed to onAbort.
9​
10## Properties
11​
12### cancelRequested?
13​
14```ts
15optional cancelRequested?: boolean;
16```
17​
18Defined in: [packages/ai/src/activities/chat/middleware/types.ts:541](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/middleware/types.ts#L541)
19​
20True only when the abort came from an explicit, out-of-band cancel (e.g. a
21cancel endpoint setting `RunRecord.cancelRequested`), never from a mere
22client disconnect.
23​
24A disconnect and a user pressing "stop" are the SAME connection close on
25the wire, so consumers must not infer intent from an abort alone. Middleware
26that tears down expensive resources reads this to distinguish "the viewer
27left, keep going" from "the user wants this stopped". Populated from the
28abort reason: `true` exactly when the run was aborted with `RUN_CANCEL_REASON`
29(matched with `===`, so an arbitrary error message can never be read as a
30deliberate cancel), `false` for every other abort. The durable channel is
31separate — middleware that must also catch a cancel recorded on a different
32host reads `RunRecord.cancelRequested` in addition to this flag.
33​
34***
35​
36### duration
37​
38```ts
39duration: number;
40```
41​
42Defined in: [packages/ai/src/activities/chat/middleware/types.ts:525](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/middleware/types.ts#L525)
43​
44Duration until abort in milliseconds
45​
46***
47​
48### reason?
49​
50```ts
51optional reason?: string;
52```
53​
54Defined in: [packages/ai/src/activities/chat/middleware/types.ts:523](https://github.com/TanStack/ai/blob/main/packages/ai/src/activities/chat/middleware/types.ts#L523)
55​
56The reason for the abort, if provided