1.8 KiB
| id | title |
|---|---|
| RunDetachedCapability | RunDetachedCapability |
Variable: RunDetachedCapability
const RunDetachedCapability: Capability<true, "run-detached">;
Defined in: packages/ai/src/activities/chat/middleware/run-store.ts:329
Whether this run's teardown DID detach — the disconnect was survived, the agent is still working, and a later attach can take the run over.
The past-tense counterpart of DetachableRunCapability, and the two must not be confused:
- detachABLE is published at
setup, and only says a disconnect may be survived (aRunStoreand a durable log are wired). - detachED is published on the ABORT path, by the middleware that actually
makes the call —
withSandbox'sonAbort, which is the only actor that has resolved BOTH out-of-band cancel bands (AbortInfo.cancelRequestedandwasCancelRequestedon the record) anddetachOnDisconnect. An explicit cancel, a non-detachable disconnect, an error, and a normal finish all leave it unpublished.
Its consumer is the durable DELIVERY sink in stream-to-response.ts: a
detached run's log must stay OPEN and un-terminalized so the takeover can
continue it (see wasRunDetached in ../../../delivery-detach). Reading it
is safe and race-free only because a for await over the chat stream awaits
the generator's return() — and therefore the whole onAbort chain — before
the sink's own finally runs.
Read with { optional: true }: absent means "not detached", which is every
other exit path and every app that has not wired durability.
Typed true, not boolean, for the same reason as
DetachableRunCapability: absence is the only negative, so publishing
false must not be representable.