feat(session): durable save/resume via FileSessionStore - #92
Merged
Merged
Conversation
Persist typed SessionSnapshot (transcript, tool-call records, cost) under sessions_dir so Harness.resume_session can continue after process death. Co-authored-by: Cursor <cursoragent@cursor.com>
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
13 tasks
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
|
@greptileai please review |
Greptile SummaryThe PR adds durable, private session snapshots and harness APIs for saving and resuming conversations across process restarts.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the effective turn-limit and snapshot-consistency issues from the previous review are addressed by persisting the bound engine’s resolved limit and synchronously rejecting snapshots while a send is active.
|
| Filename | Overview |
|---|---|
| src/dream/session.py | Adds consistent snapshot creation and restoration, including effective turn-limit persistence, transcript sanitization, metadata filtering, and active-send rejection. |
| src/dream/harness.py | Adds configurable file-store resolution and high-level save/resume APIs that bind restored state to a fresh engine. |
| src/dream/services/session_store.py | Implements typed snapshot serialization, strict JSON decoding, safe session paths, atomic private writes, tool-call extraction, and cost conversion. |
| tests/test_services/test_session_store.py | Covers persistence, permissions, traversal rejection, option restoration, active-send rejection, tool-call integrity, cost restoration, and resumed execution. |
| tests/evals/eval_session_save_resume.py | Exercises cross-process transcript, tool-call, cost, and metadata restoration as an end-to-end correctness evaluation. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Active Session] -->|snapshot when idle| B[SessionSnapshot]
B -->|atomic JSON write, mode 0600| C[FileSessionStore]
C -->|load by safe session ID| D[SessionSnapshot]
D -->|restore options, transcript, and cost| E[Fresh Session Engine]
E --> F[Continued Conversation]
Reviews (3): Last reviewed commit: "fix(session): stabilize snapshots for sa..." | Re-trigger Greptile
Remove the planning HTML artifact; session save/resume changes stay in code and specs. Co-authored-by: Cursor <cursoragent@cursor.com>
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Combine session save/resume notes with the merged Level-2 tool stack entries; drop stale edit_file changelog line superseded by apply_patch. Co-authored-by: Cursor <cursoragent@cursor.com>
Persist the engine's effective max_turns when SessionOptions omits it, reject snapshot/save while send is in flight, and sanitize transcript messages at the snapshot boundary so resumed sessions keep the same turn budget and consistent tool-call history. Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Aug 8, 2026
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.
User description
Summary
Typed
FileSessionStore/SessionSnapshot(transcript + tool-call records + cost) underDreamPaths.sessions_dir, wired throughSession.snapshot/restore_from_snapshotandHarness.save_session/resume_sessionfor cross-process resume.Snapshots are private by construction — they contain full transcripts, so they're written
atomic_write_text(..., mode=0o600)rather than at the default umask.Resume also restores the session's shape, not just its messages:
SessionSnapshotpersistsmax_turnsand JSON-compatiblemetadata, andresume_sessionrebuildsSessionOptionsfrom them when the caller passes none.response_formatand non-JSON metadata values are deliberately not serialized (they aren't JSON-representable) — theresume_session/Session.snapshotdocstrings state that callers must pass those explicitly.Type
Checklist
tests/test_public_api.pyupdated if the public API changedCHANGELOG.mdupdated for user-visible changes.env.local, or credentials in the diffdream(org/company features belong in sibling repos)Test plan
uv run pytest tests/test_services/test_session_store.py tests/evals/eval_session_save_resume.py— 17 passed0o600, serializable options round-trip, non-JSON metadata excludeduv run ruff check src tests/uv run mypyuv sync --all-extras—librt==0.15.0publishes nocp314wheel or sdist — before any test runs. feat(observability): default-on OTLP export beside JSONL traces #93/feat(security): tool-call SecretProxy (placeholders + redact) #94/feat(tools): slim default registry to Level-2 coding surface #95 pass 3.14 with identical dependency declarations, so this is registry availability drift, not this diff; the job can't be re-run from the API.Link to Devin session: https://app.devin.ai/sessions/4f7deb4af0914056a24a4d660a661713
Requested by: @divo12
CodeAnt-AI Description
Save and resume sessions across process restarts
What Changed
Impact
✅ Sessions survive process restarts✅ Tool calls remain connected to their results✅ Continued conversations retain prior history and usage costs💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.