MCPcopy Index your code
hub / github.com/TanStack/ai / checkForContinuation

Method checkForContinuation

packages/ai-client/src/chat-client.ts:1326–1352  ·  view source on GitHub ↗

* Check if we should continue the flow and do so if needed

()

Source from the content-addressed store, hash-verified

1324 * Check if we should continue the flow and do so if needed
1325 */
1326 private async checkForContinuation(): Promise<void> {
1327 // Prevent duplicate continuation attempts
1328 if (this.continuationPending || this.isLoading) {
1329 this.continuationSkipped = true
1330 return
1331 }
1332
1333 if (this.shouldAutoSend()) {
1334 this.continuationPending = true
1335 this.continuationSkipped = false
1336 let succeeded = false
1337 try {
1338 succeeded = await this.streamResponse()
1339 } finally {
1340 this.continuationPending = false
1341 }
1342 // If a queued check was skipped while continuationPending was true
1343 // (e.g. a chained approval responded to during the stream), re-evaluate
1344 // now that the flag is cleared. Only replay after a successful stream —
1345 // aborted or errored streams should not trigger further continuation.
1346 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- mutated asynchronously during await
1347 if (this.continuationSkipped && succeeded) {
1348 this.continuationSkipped = false
1349 await this.checkForContinuation()
1350 }
1351 }
1352 }
1353
1354 /**
1355 * Check if all tool calls are complete and we should auto-send.

Callers 3

streamResponseMethod · 0.95

Calls 2

shouldAutoSendMethod · 0.95
streamResponseMethod · 0.95

Tested by

no test coverage detected