Skip to main content
Construct one HarnessRuntime with host-approved configuration. Start runs with an authenticated caller’s identity and a session ID. A run can use only the tools and model roles allowed by that runtime.

Runtime configuration

The main role uses the provider supplied by an Agent or custom driver’s model call unless models.main overrides it. Other roles need an explicit host model binding. Granting a role alone does not provide a model.

Set shared budgets

Values must be nonnegative integers. 0 disables the corresponding operation. Follow-ups and completion revisions share the run’s budgets; they do not receive fresh allowances. A policy model call also consumes the same model/token budgets. Token caps constrain output reservations and account for reported usage. They are not an exact spending guarantee: provider-reported input or reasoning usage can exceed an estimate. Exhausted budgets stop further admitted work with reason.code: "budget_exhausted".

Start, await, or stream

runtime.run(input, options) returns the settled HarnessResult. runtime.stream(input, options) starts a new run and returns its event iterator. runtime.start(input, options) returns a RunHandle immediately, allowing you to consume events, send input, cancel, and await the result for the same run. This function accepts an already configured runtime:
Planning mode is still an execution mode: do not assume it means no model calls or no reads. Use tool effect metadata and execution policy to control what operations are admitted.

Send input and cancel

For an active handle, call handle.send(input, { mode: "follow_up" }). Built-in drivers support follow-ups: input is queued and processed after the current completed pass. The queue holds up to 32 inputs. Sending after cancellation or termination fails. steer requires a custom driver that advertises and consumes it through services.takeInput(). It does not automatically interrupt a model call. replace appears in the shared type but is unsupported by the current runtime; constructing a driver that advertises it fails with HarnessUnsupportedError. Call handle.cancel(reason?) or abort the caller signal to request cancellation. Wait for handle.result() to observe cleanup and final status. Closing an event iterator only disconnects that observer. Cancellation does not roll back external effects that already started.

Handle results and errors

Invalid constructor/start arguments can throw synchronously. Errors after a run starts are normally represented in its terminal result. Cleanup errors appear in cleanupDiagnostics without hiding the primary outcome. Event iteration can separately throw a cursor/gap error; see events. Results include text, optional structured, usage, runId, sessionId, and finalCursor. Large output may be returned through scoped artifact references. See full runtime declarations and events and results.