Brian Hung
ai-sdk-harness
Sandboxes and durable runtimes for running Claude Code and Codex through the AI SDK.
Moving a working tree between sandboxes
createSession()spawn: tar czf -writeBinaryFile, then tar xzfLocalSandboxProviderchild_process and fsDockerSandboxProviderdocker exec in a containerCloudflareSandboxProviderSandbox Bridge HTTP APISession in sandbox Aat a turn boundarySession in sandbox Bfresh, from any providercheckpointSandboxstreams out, stages nothingCheckpointStorememory or R2, by keyrestoreSandboxoverlays the treeThe file tree moves; running processes don't. Files made since the checkpoint stay in place.
Running a turn on any engine
session.call: the state as JSONready_for_next_step: run the next slicerunHarnessSessionpure orchestration, JSON onlyCloudflare WorkflowsworkflowDurableSessionTemporaltemporalDurableSessionIn-processlocalDurableSessionharness:sliceup to 750 s of the turnSessionLogchunks, per sliceagent in its sandboxClaude Code or CodexEach slice is a checkpoint, so a restart resumes from the last one.The sandbox keeps running between slices, and the next slice reattaches to it.
One Durable Object per session
prompts, answersevents, permission requestssingle-threaded: no locksevery frame, with its seqClientsphone, laptop, chat threadsRunnerexactly one, fenced by generationAgentSessionDOappendAndFanout: the log assigns the next seqdurableObjectSessionLog, on the DO's SQLiteConnected clientseach frame, liveReplayfrom a lastSeq cursorSSE readersLast-Event-ID cursorExport and fork?until=N, ?seal=1Text streams out live, chunk by chunk, and is stored once, as one message.
Serving local tools to a remote session
Outcomesevery call ends in exactly onehost-tool-callhost-tool-resulttool-calltool-resultRunnermay live in a cloud sandboxAgentSessionDOone host lease, per-call budgetsconnectToolHostrelay-host, on your machinecompletedthe result, capped at byteBudgetunavailableno host attached: safe to retrytimeoutdeadlineAt passed: call cancelledambiguoushost left mid-call: never retriedA repeated call replays its recorded result, so the host never runs it twice.