Skip to content

fix(replay): seed replay context cursor at recording step 1#156

Merged
risjai merged 1 commit into
masterfrom
fix/replay-cursor-from-step
Apr 28, 2026
Merged

fix(replay): seed replay context cursor at recording step 1#156
risjai merged 1 commit into
masterfrom
fix/replay-cursor-from-step

Conversation

@risjai

@risjai risjai commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator

Why

Late catch from the dev1 Phase-3 validation right after #155 merged. The dispatch path was conflating two distinct concepts:

  • at_step — the fork point (controls which inherited prefix the fork timeline shares with main, and where new recordings get numbered).
  • from_step — the cache cursor base (controls which recorded step the next lookup targets).

Combined with peek_next_replay_step returning current_step + 1, the agent's first cache lookup targeted recorded step at_step + 1. Concrete repro on dev1 with at_step=1, session "What clusters are running?" (3-step recording):

agent first LLM call  -> lookup target = 1 + 1 = 2
                         step 2 is tool_call, expected LLM -> MISS
agent first tool call -> lookup target = 1 + 2 = 3
                         step 3 is LLM, expected tool -> MISS

Both lookups missed, the agent re-ran every step live, and the dashboard diff rendered the entire recording as "main only" past step at_step. Looked like the cache was broken; was actually ordinal misalignment.

What

Always pass 0 as from_step. Ray Serve runners (and any other client that spawns the agent fresh per dispatch) re-execute from scratch, so the cache must align with recorded step #1 on the first call. The fork still inherits the at_step prefix so operators get the "fork from step N" UX they expect; only the cursor is decoupled from the fork point.

Validated end-to-end in dev1 by manually creating a from_step=0 context and dispatching via shape B: 3 cache hits, 0 misses, 117ms total (vs 6.3 s for the original recording — ~54× speedup).

Tests

20 replay_jobs_tests pass including new regression shape_a_replay_context_starts_cursor_at_recording_step_one that pins from_step=0 regardless of at_step.

Versions

No bump — workspace is already at 0.14.1 (post-#155) and v0.14.1 hasn't been released yet, so this fix rides with the unreleased version per CLAUDE.md.

Test plan

  • CI green
  • After merge: GitHub Release v0.14.1 picks this up automatically
  • Dashboard "Run replay" button on dev1 returns deterministic cache-only re-execution

Made with Cursor

…tep+1

The dispatch shape A path was passing a.at_step as the
create_replay_context from_step, conflating two distinct concepts:

  - at_step is the FORK point (controls which inherited prefix the
    fork timeline shares with main, and where new recordings get
    numbered)
  - from_step is the cache CURSOR base (controls which recorded step
    the next lookup targets)

Combined with peek_next_replay_step returning current_step + 1,
the agent's first cache lookup targeted recorded step at_step + 1.
Concrete repro on dev1 with at_step=1, session "What clusters are
running?" (3-step recording):

  agent first LLM call -> lookup target = 1 + 1 = 2
                          step 2 is tool_call, expected LLM -> MISS
  agent first tool call -> lookup target = 1 + 2 = 3
                           step 3 is LLM, expected tool -> MISS

Both lookups missed, the agent re-ran every step live, and the
dashboard diff rendered the entire recording as "main only" past
step at_step. Looked like the cache was broken; was actually
ordinal misalignment.

Fix: always pass 0 as from_step. Ray Serve runners (and any other
client that spawns the agent fresh per dispatch) re-execute from
scratch, so the cache must align with recorded step #1 on the
first call. The fork still inherits the at_step prefix so
operators get the "fork from step N" UX they expect; only the
cursor is decoupled from the fork point.

20 replay_jobs_tests pass including new regression
shape_a_replay_context_starts_cursor_at_recording_step_one.

Made-with: Cursor
@vercel

vercel Bot commented Apr 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rewind Ready Ready Preview, Comment Apr 28, 2026 5:06pm

@risjai
risjai merged commit e3d4c33 into master Apr 28, 2026
7 checks passed
@risjai
risjai deleted the fix/replay-cursor-from-step branch April 28, 2026 17:09
risjai added a commit that referenced this pull request Apr 28, 2026
Pulls in #156 (replay context cursor fix). v0.14.1 was tagged
right after #155 merged and before #156 landed, so the cursor fix
needs a fresh GitHub Release to propagate to consumers.

Track 1 only (3 files: Cargo.toml + python/rewind_cli.py +
python-mcp/rewind_mcp_cli.py + Cargo.lock). Python SDK stays at
0.15.1 and MCP wheel stays at 0.13.1 — neither is on PyPI yet, so
the cursor fix rides with those unreleased versions.

Made-with: Cursor
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