Builtin Library
README.md
drain
Return your unread notices as the delivery block, instead of waiting for them to be attached to your next tool result.
Notices normally ride tool results, because for most clients a tool result is the only channel into the model's context. That leaves a hole: a notice posted while you are not mid-tool-call — an import or a build that finishes after your turn ends — has nothing to ride, and nobody reads it. A harness that composes its own context pulls the queue here instead, and can start a turn with what it finds.
What it returns is marked read for you, so read it: if you also read notices
off your tool results, each one reaches you exactly once, on whichever path
reads it first. Nothing is removed for other callers — a notice addressed to
several callers still reaches the ones that have not read it — and keys you
muted with suppress are passed over.
Returns { block }, or nil when you have nothing unread. Overflow content is
written under /source/tmp/notices/ and named in the block. Use list for a
look at the notices addressed to you that marks nothing read.