Skip to content

fix(server): idle GC preserves durable session (ADR-0070 D1) - #610

Merged
delete-cloud merged 1 commit into
mainfrom
feat/idle-gc-preserve-durable-session
Jun 16, 2026
Merged

delete-cloud merged 1 commit into
mainfrom
feat/idle-gc-preserve-durable-session

Conversation

@delete-cloud

Copy link
Copy Markdown
Owner

Why (ADR-0070 D1)

cleanup_idle_sessions routed idle sessions through close_session → _remove_session_async → delete_session, permanently deleting the durable session (metadata + tape/runs/checkpoints) after 30 min idle. This is restart-independent and is the actual cause of the REVISION-6 "lost sessions". "Durable session" should mean persisted until the user/admin deletes it, not until idle GC.

What

  • cleanup_idle_sessions now calls shutdown_session_runtime instead of close_session: frees the in-memory runtime, persists the row, does not delete metadata/tape/runs/checkpoints.
  • It does not release the owner lease (the lease-renewal task keeps the session owned), so a later prompt's _assert_owner still passes and the runtime is lazily rebuilt. Only sessions with live runtime resources are shut down.
  • Explicit close/delete still deletes the durable row — only the idle path changed.

Test (tests/ui/test_session_manager_public_api.py)

  • test_cleanup_idle_sessions_preserves_durable_session_and_history
  • test_idle_cleaned_session_rebuilds_runtime_on_next_prompt
  • test_explicit_close_session_still_deletes_durable_session
  • test_cleanup_idle_sessions_shuts_down_idle_runtimes_with_async_helpers

uv run pytest tests/ui/test_session_manager_public_api.py tests/ui/test_http_server.py → 347 passed. cleanup_idle_sessions is referenced only by these test modules; no other test depended on idle deletion.

Part of the ADR-0070 series (#608 docs). Next: D2 (graceful drain + Helm lifecycle).

🤖 Generated with Claude Code

…ession

Implements ADR-0070 D1. cleanup_idle_sessions routed idle sessions through
close_session -> _remove_session_async -> delete_session, permanently deleting
the durable session (metadata + tape/runs/checkpoints) after 30 min idle —
restart-independent destruction of the user's conversation.

Idle is resource reclamation, not deletion. cleanup_idle_sessions now calls
shutdown_session_runtime (frees the in-memory runtime, persists the row, does
NOT release the owner lease — the lease-renewal task keeps the session owned, so
a later prompt's _assert_owner still passes and the runtime is lazily rebuilt).
Only sessions with live runtime resources are shut down. Explicit close/delete
still deletes the durable row.

Tests: durable session + history preserved after idle cleanup; runtime rebuilds
on the next prompt; explicit close still deletes; async-helper path + log copy.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@delete-cloud, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 25 minutes and 20 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dc8f46e2-f6b8-40bf-bde6-425a2c827fc0

📥 Commits

Reviewing files that changed from the base of the PR and between 43e64ed and d743caa.

📒 Files selected for processing (2)
  • coding-agent/src/coding_agent/server/session_manager.py
  • coding-agent/tests/ui/test_session_manager_public_api.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/idle-gc-preserve-durable-session

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@delete-cloud
delete-cloud merged commit aa92afc into main Jun 16, 2026
2 checks passed
@delete-cloud
delete-cloud deleted the feat/idle-gc-preserve-durable-session branch June 16, 2026 07:59
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