Repository navigation
fix(sessions): reap a run Stop cannot unwind when idle shutdown is disabled - #1017
Merged
Merged
Conversation
…sabled (#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]>
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]>
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
解开 agegr#981 的 DirectoryPicker 冲突后,这一段(390e70f..f52fd84)实测 0 冲突: - agegr#992 移动端输入框停在键盘上方并给打字更多空间 - agegr#997 限制每客户端 SSE 积压 - agegr#1001 可配置发送键(Enter / Ctrl+Enter) - agegr#1006 从 pi 的 provider catalog 解析 discovery endpoint - agegr#1017 空闲关闭被禁用时回收 Stop 无法解除的运行 - agegr#1016 Stop 结束输出被幸存进程持住的命令 - agegr#1015 保留用户消息里输入的换行 - agegr#1019 在 Safari / iOS 16.2 上可加载(新增 browserslist,无新依赖)
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
…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.
Refs #656
Problem
A turn only stays "running" indefinitely when the pi SDK awaits a promise that ignores the abort signal, such as a third-party extension handler or tool. Stop cannot cancel that, because
AgentSession.abort()waits for an idle state that never arrives. #575 made Stop setforceShutdownOnIdle, so the next idle-timer tick shuts the wrapper down and the session recovers without a server restart.PI_WEB_IDLE_TIMEOUT_MS=0, added later, returned fromresetIdleTimer()before arming any timer, so with idle shutdown disabled that safety net silently disappeared and a stuck session again needed a server restart.Changes
resetIdleTimer():0still never shuts down an idle session, but after Stop the forced cleanup is armed at the 10-minute default.abort/abort_basharm the timer right after raising the flag instead of relying on the reset that ran before it.Testing
PI_WEB_IDLE_TIMEOUT_MS=0, a run whose abort never settles is torn down 10 minutes after Stop and not before (fails without the fix); a Stop that unwinds keeps the session alive.node --experimental-strip-types --test lib/rpc-manager*.test.mjs,tsc --noEmit, eslint on changed files.[DONE]without close, socket reset, 500, empty completion): all end the run on their own and Stop cancels them within milliseconds.🤖 Generated with Claude Code