fix(agents): clean up orphaned sub-agent sessions on parent reset#508
fix(agents): clean up orphaned sub-agent sessions on parent reset#508sytone wants to merge 1 commit into
Conversation
Add CleanupChildSessionsAsync to ISubAgentManager and DefaultSubAgentManager. GatewayHub.ResetSession now calls cleanup before archiving the parent session. NoOpSubAgentManager in SessionsController updated to implement new method. 6 new tests (4 SubAgentCleanupTests + 2 SignalRHubTests). Closes #507
sytone
left a comment
There was a problem hiding this comment.
Farnsworth Review — PR #508
CI: ✅ All checks passing (build-and-test, CodeQL, Security Scan)
Merge conflicts: ✅ Clean (MERGEABLE)
Conventional commit title: ✅ fix(agents): clean up orphaned sub-agent sessions on parent reset
Test coverage:
- ✅ CleanupChildSessionsAsync called on ResetSession
- ✅ Non-fatal error path (exception swallowed, reset continues)
- ✅ Happy path with multiple child sessions
- ✅ No-op when no child sessions exist
- 6 new tests; 1642/1642 pass
Spec completeness vs OpenClaw finding: Correctly addresses orphaned sub-agent session cleanup. Optional DI param keeps it backward-compatible. NoOpSubAgentManager updated appropriately.
LGTM. Ready to merge.
|
Closing as part of a planned hard-reset of the in-flight branch set so the new domain-model refactor can land on a clean trunk. Audit verdict: close Rationale: Touches the reset path that Phase 3c rewrites canonically. Will be subsumed. The new plan (in session state) reshapes core types: Citizen (User+Agent union), Vogen-generated value objects, ThreadId removed in favour of composite ChannelAddress, mark-not-delete compaction, centralised If this work is still wanted, refile as a new issue/PR against the post-refactor contracts. |
Closes #507
Changes
ISubAgentManager(new method)CleanupChildSessionsAsync(SessionId parentSessionId, CancellationToken ct)— kills running sub-agents for a parent session and archives their child sessionsDefaultSubAgentManager(new impl)CleanupChildAgentAsyncto stop the agent and unregister from registryKilledif still runningISessionStore(non-fatal on failure)GatewayHub.ResetSession(hooked in)ISubAgentManagerparam added to constructorCleanupChildSessionsAsyncafter supervisor stop, before memory flush and session archiveNoOpSubAgentManagerinSessionsControllerCleanupChildSessionsAsyncreturning 0 (no-op)Tests (6 new)
CleanupChildSessionsAsync_ReturnsZero_WhenNoChildrenExistCleanupChildSessionsAsync_ArchivesChildSession_WhenChildExistsCleanupChildSessionsAsync_IsNonFatal_WhenSessionArchiveFailsCleanupChildSessionsAsync_DoesNotCleanOtherParentSessionsResetSession_CallsSubAgentCleanup_WhenManagerProvidedResetSession_ProceedsNormally_WhenNoSubAgentManager1642/1642 gateway tests + full suite passing.