fix(server): keep Claude messaging sessions alive - #9612
Open
Gigioxx wants to merge 1 commit into
Open
Conversation
Contributor
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a small, focused server bug fix that preserves live Claude processes needed for cross-session messaging while leaving other provider cleanup behavior unchanged. Tests cover both retained Claude sessions and continued cleanup of stale Codex sessions. You can add or adjust custom eligibility rules. Learn more. |
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.
What Changed
Keep live Claude sessions out of the inactivity reaper so their cross-session messaging endpoint remains addressable. Other providers and Claude bindings without a live adapter session keep the existing cleanup behavior.
Why
Claude's process owns its roster entry and messaging socket. Reaping an idle thread removes it from
ListAgents, makesSendMessagefail, and resuming cannot restore the same endpoint identity.Fixes #9586.
Verification
vp test run apps/server/src/provider/Layers/ProviderSessionReaper.test.ts(9 passed)vp run --filter t3 typecheckpassedgit diff --checkpassedChecklist
Implemented with
gpt-5.6-solin T3 Code through the Codex harness.Note
Medium Risk
Changes session lifecycle for Claude only and adds a listSessions dependency each sweep; wrong skip logic could leave zombie sessions or fail to reap when messaging is gone.
Overview
The inactivity ProviderSessionReaper no longer stops idle Claude bindings when
listSessions()still reports a liveclaudeAgentsession for that thread, so cross-session messaging can keep using the same process endpoint. Other providers and Claude bindings without a live adapter session still follow the existing stale-session cleanup.Tests mock
activeSessionson the harness, assert stale codex sessions are still reaped, and add cases for idle ready / error Claude threads that must not callstopSession. Multi-session failure/defect scenarios use error thread status on the Claude side so those bindings are not exempted by the new skip rule.Reviewed by Cursor Bugbot for commit c3ab694. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
ProviderSessionReaperto keep live Claude messaging sessions aliveThe reaper previously stopped stale persisted Claude bindings even when a live session was still active. The sweep in
makeProviderSessionReapernow callsproviderService.listSessions, builds a set of active Claude thread IDs, and skips stopping any Claude binding whose thread ID is in that set.Tests in ProviderSessionReaper.test.ts are updated: the generic stale-session test switched to the Codex provider, and new parameterized tests verify that live idle Claude sessions in
readyanderrorstates are retained.Risk: non-Claude providers are unaffected; only Claude bindings with a matching live thread ID are exempted from reaping.
Macroscope summarized c3ab694.