Repository navigation
fix: emit session_shutdown on every dispose path - #575
Merged
agegr merged 3 commits intoAug 25, 2026
Merged
Conversation
Ensure AgentSessionWrapper destroy/dispose always notifies extensions before inner.dispose, and force idle shutdown even when a session is stuck running so MCP children are reaped.
magnum-pr
pushed a commit
to magnum-pr/pi-web
that referenced
this pull request
Sep 27, 2026
* fix: emit session_shutdown before every dispose path Ensure AgentSessionWrapper destroy/dispose always notifies extensions before inner.dispose, and force idle shutdown even when a session is stuck running so MCP children are reaped. * fix: preserve active sessions during shutdown cleanup --------- Co-authored-by: Alex Yang <[email protected]>
agegr
added a commit
that referenced
this pull request
Sep 30, 2026
…sabled (#1017) * fix(sessions): reap a run Stop cannot unwind when idle shutdown is disabled (#656) A turn can only stay "running" forever when the SDK awaits a promise that ignores the abort signal, typically a third-party extension handler or tool. Stop cannot cancel that: AgentSession.abort() waits for idle, which never comes. #575 made Stop set forceShutdownOnIdle so the next idle-timer tick shuts the wrapper down anyway and the session recovers without a server restart. PI_WEB_IDLE_TIMEOUT_MS=0 (added later) returned from resetIdleTimer() before arming any timer, so with idle shutdown disabled that safety net silently disappeared and a stuck session needed a server restart, the exact symptom reported in #656. The abort path also only reset the timer before raising the flag, relying on a timer the 0 setting never arms. Keep 0 meaning "never shut down an idle session", but still arm the forced cleanup after Stop, at the 10-minute default, and arm it right after raising the flag. A Stop whose run does unwind clears the flag as before, so the session then stays alive indefinitely. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(sessions): keep the forced cleanup deadline after Stop (#656) Every command other than get_state reset the idle timer, so a reload's get_tools, typing `/`, or pressing Stop again re-armed the forced cleanup for another full timeout. A user retrying on a stuck run kept it alive indefinitely. Once the forced timer is armed, later resets keep its deadline until the run is no longer running. Also covers abort_bash with PI_WEB_IDLE_TIMEOUT_MS=0. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
…sabled (agegr#1017) * fix(sessions): reap a run Stop cannot unwind when idle shutdown is disabled (agegr#656) A turn can only stay "running" forever when the SDK awaits a promise that ignores the abort signal, typically a third-party extension handler or tool. Stop cannot cancel that: AgentSession.abort() waits for idle, which never comes. agegr#575 made Stop set forceShutdownOnIdle so the next idle-timer tick shuts the wrapper down anyway and the session recovers without a server restart. PI_WEB_IDLE_TIMEOUT_MS=0 (added later) returned from resetIdleTimer() before arming any timer, so with idle shutdown disabled that safety net silently disappeared and a stuck session needed a server restart, the exact symptom reported in agegr#656. The abort path also only reset the timer before raising the flag, relying on a timer the 0 setting never arms. Keep 0 meaning "never shut down an idle session", but still arm the forced cleanup after Stop, at the 10-minute default, and arm it right after raising the flag. A Stop whose run does unwind clears the flag as before, so the session then stays alive indefinitely. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(sessions): keep the forced cleanup deadline after Stop (agegr#656) Every command other than get_state reset the idle timer, so a reload's get_tools, typing `/`, or pressing Stop again re-armed the forced cleanup for another full timeout. A user retrying on a stuck run kept it alive indefinitely. Once the forced timer is armed, later resets keep its deadline until the run is no longer running. Also covers abort_bash with PI_WEB_IDLE_TIMEOUT_MS=0. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
* fix: emit session_shutdown before every dispose path Ensure AgentSessionWrapper destroy/dispose always notifies extensions before inner.dispose, and force idle shutdown even when a session is stuck running so MCP children are reaped. * fix: preserve active sessions during shutdown cleanup --------- Co-authored-by: Alex Yang <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
…sabled (agegr#1017) * fix(sessions): reap a run Stop cannot unwind when idle shutdown is disabled (agegr#656) A turn can only stay "running" forever when the SDK awaits a promise that ignores the abort signal, typically a third-party extension handler or tool. Stop cannot cancel that: AgentSession.abort() waits for idle, which never comes. agegr#575 made Stop set forceShutdownOnIdle so the next idle-timer tick shuts the wrapper down anyway and the session recovers without a server restart. PI_WEB_IDLE_TIMEOUT_MS=0 (added later) returned from resetIdleTimer() before arming any timer, so with idle shutdown disabled that safety net silently disappeared and a stuck session needed a server restart, the exact symptom reported in agegr#656. The abort path also only reset the timer before raising the flag, relying on a timer the 0 setting never arms. Keep 0 meaning "never shut down an idle session", but still arm the forced cleanup after Stop, at the 10-minute default, and arm it right after raising the flag. A Stop whose run does unwind clears the flag as before, so the session then stays alive indefinitely. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(sessions): keep the forced cleanup deadline after Stop (agegr#656) Every command other than get_state reset the idle timer, so a reload's get_tools, typing `/`, or pressing Stop again re-armed the forced cleanup for another full timeout. A user retrying on a stuck run kept it alive indefinitely. Once the forced timer is armed, later resets keep its deadline until the run is no longer running. Also covers abort_bash with PI_WEB_IDLE_TIMEOUT_MS=0. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Destroy/dispose now always emits
session_shutdownbeforeinner.dispose(), and idle teardown still runs when a session is stuck running so extension children can be reaped.Fixes #546