Sealed adapters and library-specific semantics¶
Each library has its own objects, its own streaming style and its own way of reporting progress. The code that translates those into the block's declared interface is an adapter, and it is sealed inside the block's capsule with the rest of the block's code. It runs in the block's cell, against the library versions the block's closure selected, and it is reviewed and versioned with the block.
A capsule carries up to two adapters:
- The dispatch module, which every capsule has. The pipeline generates it from the interface. It takes a method number and typed arguments, checks them, and calls your method. See Capsule-local adapter dispatch.
- The Run adapter, for a block whose target is framework-native and long running, such as an agent framework's run loop. It turns the framework's native output into the Run's declared response, chunks, events, checkpoints and artifacts.
The Run adapter¶
A one-shot block gets a generated default Run adapter: it calls the method and
returns its result as the declared response. A block that wraps a framework's
own loop uses an authored adapter, written by the block author or supplied by an
integration package. The adapter is invoked with the Run's input and a
RunContext, returns the declared response, and uses the context while the
framework runs:
await ctx.response.emit(chunk) # progressive output
await ctx.events.emit(event) # an observed event, such as tool use
message = await ctx.steering.receive() # a steering message sent to the Run
ctx.cancellation.requested # whether cancellation was requested
await ctx.checkpoints.propose(snapshot) # a checkpoint proposal
await ctx.artifacts.publish(artifact) # an artifact the Run produced
The adapter is the only consumer of the framework's native output stream. How an authored adapter is registered on a block is an open design decision.
What the adapter emits, and what the kernel decides¶
The adapter emits declared values, buffers, artifacts, handles, chunks, events, faults and checkpoint proposals. The owner cell's monitor validates each one against the Run's contract, and output outside those forms is refused.
The kernel decides the rest: the Run's phase and outcome, every handle, fan-out of the output to subscribers, replay, and retention. An event the adapter emits is recorded as an observation.
Framework objects, including the framework's native response object, stay in the block's cell. See Framework objects.
The Run contracts the adapter emits into are covered in Invoking runs.