Model
What a model adapter package (anthropic(), openai(), ...) returns.
One transport attempt per send; SDK retries off. Every send and lookup awaits context.fence() at its real network send, after any SDK or bridge queueing. An adapter or bridge route whose real transport it cannot wrap is refused when the model is constructed: ConfigError transport_fence_unsupported; it is never shipped with a weaker fence. A bridge that takes a caller's model factory (the TypeScript AI SDK bridge) qualifies only providers whose implementation sends through the fenced fetch it hands over on every path; that qualification comes from the provider implementation and its conformance tests, under the trusted-host-code boundary. The bridge also counts fenced fetches per send as misuse detection and containment, not proof of qualification: a send whose stream arrives with zero requests through that fetch ends as a broken stream (unknown outcome: it may have left unfenced, and its output is not kept), and that model refuses every later send before anything leaves with the rejected reason transport_fence_unsupported, recorded as not_sent (not billed, never retried).
Properties
infoModelInforequiredWhat this model is and can do: its name, adapter, params, limits, accepted inputs, hosted tools and lookup capability. Read when the agent is pinned.
Methods
send
Stream one attempt. Every failure before content is the one terminal rejected chunk, never a thrown error, and its reason is one of returns.errors: a provider rejection class; stale_epoch when context.fence() refused at the real network send point, after any SDK queueing, so nothing left; content_unsupported or continuation_unsupported when the adapter can't encode a rendered part, so nothing left and nothing is re-sent. transport_fence_unsupported when a bridge model already detected that its sends bypass the fenced transport, so nothing left and nothing is re-sent. A throw after dispatch is a broken stream (unknown outcome).
send(request: ModelRequest, context: ModelContext, options?: {
signal?: AbortSignal;
}): Result<AsyncIterable<ModelChunk>>requestModelRequestrequiredThe attempt to send: its client request id and the exact rendered request bytes. See ModelRequest.
contextModelContextrequiredThe fencing context for this attempt. Await context.fence() at the real network send point and send nothing if it fails; use read and put for artifact bytes. See ModelContext.
signalAbortSignalTypeScript only. TypeScript only. The run's signal option, passed through when the caller gave one; hand it to the provider SDK so an abort stops the request. Omitted when the run has no signal.
Returns an error value with one of these codes: rate_limited, overloaded, server_error, prompt_too_long, provider_error, stale_epoch, content_unsupported, continuation_unsupported, transport_fence_unsupported.
lookup
Recover a response after a crash by client request id. Present when info.lookup is not none. Fenced like send: context.fence() at the real network send point; a found response's reasoning and hosted tool bytes are put() before their parts name them.
lookup(requestId: string, context: ModelContext): Promise<Result<LookupResult<ModelResponse>>>requestId / request_idstringrequiredThe client request id of the lost attempt, the same one ModelRequest.request_id carried when it was sent.
contextModelContextrequiredThe fencing context: await context.fence() before the lookup call, and put() any reasoning or hosted tool bytes of a found response before its parts name them. See ModelContext.
Returns an error value with one of these codes: stale_epoch.
Schedule
A cron schedule on a host: each time it is due, it starts a run of one of the host's agents on a new thread.
ModelContext
What the loop hands an adapter for one send or lookup: the fencing pair it re-checks at its real send point, and artifact access, since the rendered request carries refs, not bytes.