Files
opencode/packages
Kit Langton ea19ee7966 refactor(session): use onInterrupt finalizer for cancelled tool output
Wire the AI SDK's abortSignal into the tool fiber via runPromiseExit's
signal option so interruption is first-class, and move the "finalize on
cancel" path into an Effect.onInterrupt finalizer that re-awaits the
still-running native Promise uninterruptibly, builds the output, and
posts it through completeToolCall.

Replaces the imperative `if (options.abortSignal?.aborted)` tail check
with structural interruption handling. When the fiber is interrupted,
the finalizer captures the truncated bash output (or MCP tool result)
and the .then on runPromiseExit resolves the SDK's Promise with the
captured value instead of propagating the interrupt cause as a
rejection, so the tool is reported as successfully completed rather
than as a tool-error.

InstanceRef is provided on the tool fiber so InstanceState.context
resolves through ServiceMap rather than falling through to the
AsyncLocalStorage, which the onInterrupt finalizer runs outside of.
2026-04-09 16:40:57 -04:00
..
2026-04-09 16:24:43 +00:00
2026-04-09 16:24:43 +00:00
2026-04-09 16:24:43 +00:00
2026-04-09 16:24:43 +00:00
2026-01-21 14:36:21 -06:00
2026-04-09 16:24:43 +00:00
2026-04-09 16:24:43 +00:00
2026-04-09 16:24:43 +00:00
2026-04-09 16:24:43 +00:00
2026-04-09 20:05:05 +00:00
2026-04-09 16:24:43 +00:00
2026-04-09 16:24:43 +00:00
2026-04-09 16:24:43 +00:00
2026-04-09 16:24:43 +00:00