Conversation rewind and fork
File restore (checkpoints) puts the workspace back; this puts the conversation back, in place (rewind) or into a new session (fork). The log is never erased.
Points
Section titled “Points”A point is a user prompt that started a run from idle: a
CommandAccepted carrying a user message or a skill invocation, folded
while no run was going. Its sequence number names it. The run it
started is the next run to begin: at once, or after its prompt’s hooks
have run, so its RunID may be later; RewindPoints pairs the two to
find that run’s checkpoint pass. Messages queued or steered into a
running run are not points.
The conversation at a point is the conversation part (below) of the state folded up to, not including, the point’s event. Every point is an idle moment, so the run-scoped fields there are at rest by construction.
Session.RewindPoints lists the points of the conversation as it now
stands: after a rewind, the points it dropped are gone from the list (they
remain in the log). Each point gives its prompt text, time, and whether a
checkpointed files would change when restoring it (Files).
The state split
Section titled “The state split”Every field of loop.stateData is in exactly one class.
TestStateFieldsClassified enumerates the struct’s fields and fails on
one that is unclassified or in two classes, so a new field can’t slip past
the decision. loop.Conversation carries exactly the conversation class.
Conversation: taken from the point. What the model saw and was working on.
| Field | Why |
|---|---|
| History, Notes | The conversation itself, and the notes owed to the next call. |
| Goal, Plan, Todos | The work the conversation set; the plan the user approved in it. |
| Requirements, VerificationWork, VerificationWorks, RequirementEvidence | Requirements declared in the conversation; evidence linkage follows them. |
| Instructions, Skills, SkillText | Which instructions and skills are in the history; ones dropped must load again. |
| ModelMode, ContextMode | Measured against the history, so mode notes stay correct. |
| SummaryUsers, SummaryOmitted, Native | The compacted form of the history and the provider’s window for it. |
| RecentFiles | What the history saw of files, listed again at the next compaction. |
| Answers, Said, Denials, ReviewNotes | The user’s answers and denials belong to calls in the history; the classifier must not take a dropped answer as authorization, and a compaction must not keep what the user said to a call the rewind dropped. |
| Points | The points of the conversation; a rewind keeps only those before its own. |
Session: kept as it is now. What happened in the world, or belongs to the session rather than its conversation.
| Field | Why |
|---|---|
| Config, PlanFrom, Session, Seq, Commands, Records | Identity, configuration (current model and mode included, and the mode plan mode was entered from), deduplication. |
| Usage, Ledger, Last, LastReport, Text, Trace | Spent is spent; the last run’s report stays a fact. |
| Processes, Subagents, Timers, Requests, Settled | Live and finished things the session owns. |
| Materializ*, Releasing, FileRestore, Workspace, Move, Deleted | Storage and workspace state. |
| Title, Tags, NextOutput, Output, Memory, SkillIndex | Host- and user-set; memory is the store’s newest view, and the skill index the sources’ newest. |
| Evidence, EvidenceRuns, PassedRuns, Tainted, ScopedEvidence, Generation | Facts about the workspace. Generation is bumped, so all of it is stale. |
| Breaker, PolicyRevision, Classified | The auto-mode breaker never resets by rewinding. ReviewRevision is bumped, so no cached verdict is reused. |
| Compactions, LastInput, Uncached, Cleared, Cwd | Counters and the tools’ directory, which follow the workspace. |
| Rewind | The last rewind itself, which holds commands off until it finishes. |
| CheckpointVersions, CheckpointPasses, StartingPoint | Checkpoints record what the files really were; a rewind doesn’t change the files, so it keeps them (checkpoints). |
Run: one run’s own state, reset as a run ends or the next one starts. A rewind needs an idle session and leaves these as they are. Pending, Calls, Queued, QueuedBy, Advance, Moving, Notices, Decisions, Interrupt, Ending, Turns, RunID, Changes, Continuations, Constrained, ContinuedAt, Failures, Stuck, Flags, Truncations, Cut, Claim, Reported, Steering, SteerOwed, GoalPending, Blocked, Suspended, SuspendedAt, TaskAttempts, OutputFailures, OutputExhausted, OutputRejected, OutputErrors, RunOutput, RunRecords, ActiveSkill, QueuedSkill, HookRuns, Due, StopBlocks, CompactGate, CompactRequest, CompactOnly, BatchHooked, SwitchChecked, PromptsBlocked, ModelChanges, ModeChanges, RuleChanges, PolicyChanges, Classifying, Requested, RequestedRevision, Materializing, Compacted, RunPoint, CheckpointCalls.
Reset: cleared or bumped on a rewind.
| Field | To | Why |
|---|---|---|
| Files | empty | The rewound conversation’s view of files is not the workspace’s; every write needs a fresh read. |
| Measured | nil | The next request’s size can’t be estimated from the last. |
| ContextRevision, ReviewRevision, Generation | +1 | Invalidate measurements, cached verdicts and evidence. |
Rewind
Section titled “Rewind”Rewind uses three events:
RewindRequested{Point, Files, Conversation}: intent.Conversationis the conversation part at the point, as JSON the loop owns (loop.Conversation), so replay never re-reads earlier events and the event stands alone, like a compaction.Filessays code is restored too.- File restore’s existing events, when
Filesis set. RewindFinished{Outcome}: done or failed.
The fold applies the conversation at RewindFinished(done): conversation
fields replaced, reset fields reset, and a harness note added for the
next model call: “The user rewound the conversation to before their
message <prompt>: what came after it is undone in the conversation.”
Then either “Files were restored to how they stood then.” or “Files were
not restored: they may differ from what the conversation above shows, so
read a file again before relying on it.”, and “The working directory is
<cwd>.” Without it, a model told
nothing would trust what it remembers of files it can no longer see
changing.
Conversation only: requested and finished are appended in one batch. Code and conversation: requested, then the file restore transaction, then finished: done if the restore finished done, failed otherwise. A crash between them is recovered by the next execution before it accepts commands: a requested rewind whose restore finished done finishes done, any other finishes failed. Mutations are never repeated, as for file restore.
Refused, before intent, while: a run is going, the session is suspended, an input request is open, a process lives, a child is unfinished, a file restore is unfinished, or the point isn’t one of the current points.
Agent.Fork(ctx, from, point, id) reads the source under no lease
(the log is append-only, and the fork reads a prefix), and writes a new
log:
SessionStartedwith the source’s current configuration. When the source has scratch, the fork records its own path under the same scratch root and names that path in its context. A fork is a conversation of its own, even of a subagent’s session: it drops the child’s parent, subagent type, budget share and parent’s requests, takes the conversation hooks, and its system prompt leaves out the subagent definition’s prompt. The limits the child ran with (policy, tools, turns, output) stay.SessionForked{From, Point, Prompt, Conversation}.
Both go in one batch (driver.Fork), so a fork is never seen without its
conversation. Before it, under the fork’s lease, the source’s outputs are
copied into the fork’s (retention): the conversation may
name them, as saved command output or compaction notes do.
Its session fields start empty: no processes, children, checkpoints or
spending, and a fresh auto-mode breaker, as any new session has. Its
points start empty too: the source’s are sequence numbers in the source’s
log, so the fork’s own begin with its first prompt. The note says the
session was forked from <source>, before <prompt> or as it stood, and
that files are shared with the source. A point of zero forks the
conversation as it now stands. Of a running source it forks what the
run has done so far (loop.State.ConversationSoFar): every finished step
is kept, and the model turn or tool calls still under way are left out,
so no tool call lacks its result. Messages queued for the run are kept,
since the user sent them, and a second note says the copy was taken
mid-run and how many unfinished items it left out. The run’s own state
isn’t copied: the fork starts idle. Forking at the latest point instead
would drop work the user watched finish, and the run that is going may
not have started from a point at all. The fork takes only what a model had: a process notice whose wake the
source withdrew before any model call carried it (wakes) is
left out, judged by the source as it stands now, also for a conversation cut
at a point before the withdrawal was recorded. The fork has none of the
source’s commands, so it couldn’t tell such a notice from one a model saw. A
native compaction window keeps standing for the same items, because the
fork lowers its Skip by the notices dropped from the items it replaces. A
rewind of the same session keeps the recorded conversation, since the session
keeps its withdrawals. The source isn’t changed, and deleting it later doesn’t affect the
fork. store.SessionInfo.ForkedFrom names the source in the catalog.
Compatibility
Section titled “Compatibility”The events have frozen codec fixtures.