Skip to content

fix(gateway): abort active runs during sessions.reset#16571

Closed
Grynn wants to merge 1 commit intoopenclaw:mainfrom
Grynn:fix/sessions-reset-abort-active-run
Closed

fix(gateway): abort active runs during sessions.reset#16571
Grynn wants to merge 1 commit intoopenclaw:mainfrom
Grynn:fix/sessions-reset-abort-active-run

Conversation

@Grynn
Copy link
Contributor

@Grynn Grynn commented Feb 14, 2026

Summary

  • align sessions.reset runtime cleanup with sessions.delete by clearing queues and stopping subagents for the target session key before resetting
  • abort any active embedded run for the session and wait for shutdown before rotating session ID
  • return UNAVAILABLE when the session is still active after timeout, instead of returning a misleading reset success
  • add e2e regression coverage for sessions.reset with an active run

Why

Live debugging showed agent:main:main can remain stuck after embedded run timeouts. sessions.reset previously rotated IDs/transcripts but did not clear runtime lane/queue state.

Closes #16568.

Testing

  • pnpm exec vitest run --config vitest.e2e.config.ts src/gateway/server.sessions.gateway-server-sessions-a.e2e.test.ts

Greptile Overview

Greptile Summary

This PR aligns the sessions.reset handler with the existing sessions.delete handler by adding runtime cleanup before session ID rotation. Specifically, it clears session queues, stops subagents, aborts any active embedded Pi run, and waits for shutdown before proceeding with the reset. If the session is still active after a 15-second timeout, it returns UNAVAILABLE instead of a misleading success response.

  • Adds queue clearing, subagent stopping, and embedded run abort/wait to sessions.reset, matching the existing sessions.delete cleanup pattern
  • Returns UNAVAILABLE error when an active session cannot be stopped within the timeout window
  • Adds a focused e2e regression test that validates the full cleanup flow (queue clearing, subagent stopping, abort/wait calls) during sessions.reset with an active run

Confidence Score: 5/5

  • This PR is safe to merge — it applies a well-established cleanup pattern from sessions.delete to sessions.reset with no architectural changes.
  • The new code in sessions.reset is a near-exact copy of the proven cleanup logic already in sessions.delete. All imports and function signatures are correct. The e2e test properly validates the full cleanup flow. No new dependencies or architectural changes are introduced. The TOCTOU window between loadSessionEntry and updateSessionStore is an existing pattern shared with sessions.delete, not a new concern.
  • No files require special attention.

Last reviewed commit: c45f57e

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

@Grynn
Copy link
Contributor Author

Grynn commented Feb 14, 2026

Closing in favor of #16576 (same fix, re-authored commit metadata).

@Grynn Grynn closed this Feb 14, 2026
@openclaw-barnacle openclaw-barnacle bot added gateway Gateway runtime size: S labels Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sessions.reset does not abort active embedded runs, leaving main session stuck

1 participant

Comments