Skip to content

feat: prototype session-tree execution replay - #206

Draft
hallerite wants to merge 1 commit into
mainfrom
feat/execution-replay
Draft

hallerite wants to merge 1 commit into
mainfrom
feat/execution-replay

Conversation

@hallerite

@hallerite hallerite commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Model transcripts cannot currently drive a fresh execution of an RLM session tree. This draft adds an opt-in ExecutionTape that feeds recorded model responses into the normal engine loop while native tools and child agents execute again in fresh kernels.

A parent IPython cell can spawn two children, await their work, and continue with its existing Python variables. Replay restores the children's identities and checks the recorded order of model/tool boundaries across the tree rather than flattening nested calls into a list. Compaction responses are recorded too. Divergence is latched across actors; incomplete recordings and unused replay events fail explicitly.

The implementation is a Python API prototype with a runnable examples/replay.py driver. REPLAY.md describes preparation, the artifact format, guarantees, and next steps. The ACP contract and normal execution remain unchanged when no tape is supplied.

Scope: this is boundary-level replay, not perfect deterministic execution. The caller must restore the initial sandbox at the same workspace path. Network/tool effects still execute; broker deliveries, arbitrary process races, clocks, randomness, cancellations, and model errors are not reproduced. Session paths are normalized for comparison, but executable responses are retained exactly. Runtime credentials are excluded from recorded configuration; prompts and outputs can still contain sensitive data.

Validation: uv run pytest tests/ — 330 passed. Changed-file pre-commit hooks (markdownlint, Ruff check, Ruff format), git diff --check, and the example's --help pass. Six new tests include real-kernel concurrent child execution with recreated files and no provider calls, persistent parent state, compaction, changed tool output/requests, incomplete tapes, and failure propagation.


Note

Medium Risk
Touches the core engine model/tool loop and supervisor spawn paths, but behavior is gated behind an optional tape and default execution is unchanged.

Overview
Adds an opt-in ExecutionTape that records an RLM session tree to append-only JSONL and replays it by substituting stored model responses while native tools and child agents run again in fresh kernels. Normal runs are unchanged when no tape is passed.

RLMEngine accepts optional execution_tape, shares it with the supervisor, assigns stable root/child invocation IDs from the tape, logs boundary events (engine.start, model.start/model.end, tool.start/tool.end, prompt.end), routes completions through tape.model() instead of the provider on replay, and aborts the tape on startup/prompt failures. Compaction with a tape requires an explicit summarize_at_tokens or compaction=False.

SessionTreeSupervisor propagates the tape and uses tape.child() for deterministic child IDs and sub-{id} session dirs during record/replay.

Ships examples/replay.py (record/replay CLI), REPLAY.md (format, guarantees, limits), a README pointer, and integration tests (nested concurrent children, compaction, divergence, incomplete tapes).

Reviewed by Cursor Bugbot for commit c2b01d2. Bugbot is set up for automated code reviews on this repo. Configure here.

@hallerite
hallerite marked this pull request as ready for review October 1, 2026 00:47
@hallerite
hallerite marked this pull request as draft October 1, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant