Repository navigation
Conversation
## Summary When Substrate reports a Session's Actor `CRASHED`, a caller can revert it to its last durable snapshot through `SessionService.RevertSession`. Recovery runs only when a client asks: an admitted recovery is a durable `RUNTIME_OPERATION_REVERT` operation, and a retried `RevertSession` joins it, the same way Create and Delete retries work. ### How a revert works 1. **Observe.** `observeCrash` reads the Session's generation (lifecycle operation ID, recorded Actor UID, Actor template) in one statement, then reads the Actor from Substrate. A missing, replaced, or retemplated Actor is unrecoverable, never a crash. 2. **Admit.** `BeginCrashedSessionRecovery` runs one transaction under the Session lock. It: - checks the Actor UID and generation, and that no checkpoint is being created; - fails the interrupted turn with a timeline-positioned crash note, keeping waits the snapshot captured. Publishing saved results and retiring idle-work markers reuse the helpers Session deletion uses; - starts a REVERT operation. 3. **Execute.** The shared `execute` path reverts the Actor in place. Substrate restores the last completed durable snapshot. Every suspend of a kagent Actor is synchronous, so that is the snapshot admission settled against. `applyRevert` requires the same Actor back, SUSPENDED. If preparation fails, the REVERT is kept for a retry. ### API - `RevertSession` validates `session_id` as a UUID and needs `AccessUpdate`, so a read-only share cannot invoke it. - A runtime that is not crashed returns the Session unchanged. That is also what a retry sees after a revert whose response was lost. - A missing or replaced Actor returns `FAILED_PRECONDITION`. Contention returns `ABORTED`, and transient failures return `UNAVAILABLE`. - Delete supersedes a recovery even after a revert was issued. A revert restores the recorded Actor in place and creates nothing that Delete could miss. ### Schema `000002_session_revert_operation.sql` adds `RUNTIME_OPERATION_REVERT` to the `runtime_instance` operation CHECK. ## Testing - `make -C go lint`, `make proto-generate` - `go test` for `service/session`, `substrate`, `grpcserver` (revert), and `pkg/migrations` (up/down round trip) - PostgreSQL store tests, including `TestInlineSQLPrepares` - E2E: `go/core/test/e2e/session_revert_test.go` Stack: this PR → #3399 (GetSession recovery report and chat). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Ada Lundhe <adalundhe@lundhe.audio> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit aaf1ca8) Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
This was referenced Nov 9, 2026
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backports #3395 (
aaf1ca882) torelease/v1.0.xwithout modifications.Stacked on
backport/v1.0.x/02-3545. Merge it after the PR below it in the stack.Stack (merge in order, bottom first):
🤖 Generated with Claude Code