MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / presentAssistantMessageSafe

Method presentAssistantMessageSafe

src/core/task/Task.ts:366–380  ·  view source on GitHub ↗

* Fire-and-forget wrapper around `presentAssistantMessage` that swallows the * expected cancellation rejection (the presenter throws when `this.abort` is set) * and logs any other failure. Keeping it non-blocking preserves the streaming * presenter's self-locking semantics while preventing unh

()

Source from the content-addressed store, hash-verified

364 * from crashing the extension host.
365 */
366 private presentAssistantMessageSafe(): void {
367 void presentAssistantMessage(this).catch((error) => {
368 // Discriminate on the error message rather than `this.abort` state,
369 // which can flip between the throw and the catch microtask running:
370 // a real failure followed by an abort flip would otherwise be
371 // silently swallowed, and a stale abort error logged as a failure.
372 // The abort throw site in presentAssistantMessage emits a message
373 // ending in "aborted" (matching the other abort-throw contracts in
374 // this file), so we suppress exactly that.
375 if (error instanceof Error && error.message.endsWith("aborted")) {
376 return
377 }
378 console.error(`[Task#presentAssistantMessage] task ${this.taskId}.${this.instanceId} failed:`, error)
379 })
380 }
381
382 /**
383 * Push a tool_result block to userMessageContent, preventing duplicates.

Callers 2

Task.spec.tsFile · 0.80

Calls 2

presentAssistantMessageFunction · 0.90
errorMethod · 0.65

Tested by

no test coverage detected