Skip to content

feat(infinity-daemon): fork a session from a user turn (non-destructive rewind) - #166

Open
akainth015 wants to merge 1 commit into
mainfrom
pr/daemon-rewind
Open

akainth015 wants to merge 1 commit into
mainfrom
pr/daemon-rewind

Conversation

@akainth015

@akainth015 akainth015 commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Adds ClientMessage::ForkSession { thread_id, user_turn, keeps_session_alive }: creates a NEW session seeded with the session's history before its user_turn-th user-text turn. The original session is only read, never modified.

  • Rows before the cut are copied verbatim, so turn indices stay compaction-stable. The latest compaction summary at or before the cut is carried over.
  • The fork inherits cwd and model, and is registered last so a half-seeded fork never lists.
  • Like CreateSession, the requesting connection is attached to the fork and receives Connected.
  • Non-sessions and out-of-range turns return Error. Remote forwarding strips ThreadRefs.

Uses only existing store APIs (no store-trait changes); agent-core is untouched.

Replaces #144 (same auto-merge accident as #142).

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Deploying infinity with  Cloudflare Pages  Cloudflare Pages

Latest commit: c426040
Status: ✅  Deploy successful!
Preview URL: https://5accb55c.infinity-dc7.pages.dev
Branch Preview URL: https://pr-daemon-rewind.infinity-dc7.pages.dev

View logs

@akainth015
akainth015 removed this pull request from stack #167 October 19, 2026 23:51
@akainth015
akainth015 added this pull request to stack #171 October 19, 2026 23:51
@akainth015
akainth015 requested a review from a team October 20, 2026 00:16
@akainth015
akainth015 marked this pull request as draft October 20, 2026 02:52
@akainth015
akainth015 removed this pull request from stack #171 October 29, 2026 22:53
…ve rewind)

Adds `ClientMessage::ForkSession { thread_id, user_turn, keeps_session_alive }`:
create a NEW session whose history is the original's conversation just
before its `user_turn`-th user-text turn. The original session is only
read, so "rewinding" is an edit-and-fork that keeps it intact.

* `SessionManager::fork_session` resolves the turn (0-based over the
  session's persisted user-text rows, matching the `UserInputEcho` entries
  in its `Replay`; rows behind a compaction summary still count) and seeds
  a new root thread with existing `ConversationStore` primitives: the rows
  before the cut are copied verbatim and the latest compaction summary at
  or before the cut is carried over. The fork inherits cwd and model and is
  registered last, so a half-seeded fork never lists.
* Like `CreateSession`, the requesting connection is attached to the fork
  and receives `Connected`; clients then send the (edited) turn as
  `UserInput`. Non-sessions and out-of-range turns are reported via
  `DaemonMessage::Error`. `ThreadRef`s are stripped on the
  remote-forwarding path.

Based directly on `main`; independent of any interrupt work.
@akainth015
akainth015 changed the base branch from pr/daemon-interrupt to main October 29, 2026 22:57
@akainth015
akainth015 marked this pull request as ready for review October 29, 2026 22:57
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