Skip to content

feat(runtime): expose raw sandbox event tee on openSandboxRun #387

Description

@drewstone

Problem

runLoop in agent-runtime v0.78.0 now supports ExecCtx.onSandboxEvent, which forwards every raw SandboxEvent as it arrives. openSandboxRun is the persistent-box path used by product-shaped AgentProfile runs, but its OpenSandboxRunOptions currently exposes hooks and final TurnResult.events, not a per-event observer.

Source check:

  • src/runtime/types.ts: ExecCtx.onSandboxEvent exists for runLoop.
  • src/runtime/run-loop.ts: the stream drain calls args.ctx.onSandboxEvent(...) per event.
  • src/runtime/sandbox-run.ts: OpenSandboxRunOptions has hooks, but no per-event tee; settle() only collects events and returns them after the turn.

Why it matters

For stateful artifact runs, hosts need the same live/partial event capture as runLoop: tokens, tool calls, provider errors, and partial traces should be observable before the final artifact read succeeds. Today callers can recover drained events from SandboxRunAbortError on abort, but cannot stream raw events during successful long turns.

Requested shape

Add an optional observer to OpenSandboxRunOptions, matching ExecCtx.onSandboxEvent semantics as closely as possible:

onSandboxEvent?: (event: SandboxEvent, meta: { turnIndex: number; turnKind: 'start' | 'resume'; agentRunName: string }) => void | PromiseLike<void>

The observer should be best-effort, receive defensive copies, and never block or fail the run, same as runLoop.

Non-goal

Do not change AgentProfile semantics or add harness-specific config. This is runtime observability parity for the existing persistent-box primitive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions