run.terminal event. Use one RunHandle for both the stream and result(); calling runtime.stream() and runtime.run() separately starts two runs.
Event envelope
EveryHarnessEvent includes schemaVersion: 1, eventId, sequence, timestamp, sessionId, runId, attemptId, rootRunId, optional parentRunId, and a discriminated payload.
Use the discriminator before reading payload-specific fields. Event sequences start at
1 within a run. result.finalCursor identifies that run’s terminal sequence.
Resume observation
handle.events({ after }) replays events with sequence greater than after, then follows live events. Persist the last processed sequence on the client. This resumes observation of an existing handle; it does not resume execution after a process restart.
HarnessEventGapError with code: "event_gap"; earliestCursor is the value to pass as after to read the oldest retained event. Replaying from it still cannot recover discarded events.
Slow consumers can also fall behind while iterating. Decide whether your UI should replace its partial state with the terminal result, show a gap, or use an application-owned persistence layer. Raising eventCapacity changes the memory bound, not durability. The exported InMemoryHarnessEventStore exposes append(), events(), cursor, and durable: false; HarnessRuntimeConfig currently has no custom event-store injection option.
Large output and artifacts
Generic event payloads are capped at 65,536 serialized bytes. A custom driver should put large values inservices.putArtifact(value) and emit an artifact reference in its output.
When a terminal result exceeds that bound, the runtime stores its full value as an artifact, truncates the inline text to 4,096 characters, omits inline structured, and returns an artifact reference. Both handle.result() and the terminal event carry that bounded result.
undefined. Runtime artifact storage is in memory; it is not a durable download service.
Telemetry versus the run stream
telemetry: EventBus provides runtime and direct model/controller observations for application instrumentation. Keep Agent instrumentation on its own bus when necessary to avoid counting the same model call twice. The typed run stream is the lifecycle contract for consumers; core telemetry events have their own schema.
See event and result declarations, runtime status handling, and observability.