fix(tui): release agent workers on close - #735
Merged
lsdefine merged 1 commit intoAug 6, 2026
Merged
Conversation
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.
背景
本 PR 基于 @JeanStory 在 #734 中发现并说明的 TUI session 关闭后 Agent worker 线程泄露问题。
GenericAgent.run()在空闲时阻塞于task_queue.get();仅从前端 session 列表移除对象不会唤醒该 worker。abort()只能中止正在运行的任务,也不能让空闲 worker 从队列等待中返回。修改
tuiapp.py:/close在移除 session 前中止任务、发送现有字符串退出信号并等待 worker 退出。tuiapp_v2.py:/close与 Ctrl+D 复用相同的 worker 清理路径;停止并 join 后释放日志锁、清理空 task directory,再移除 session。tui_v3.py:v3 为单AgentBridge架构而非多 session;在整体 TUI 退出的finally中统一停止并 join 唯一的 Agent runner,同时释放其日志锁。不修改
agentmain.py:其现有run()循环已将字符串任务作为退出 sentinel 处理。验证
python -m py_compile frontends/tuiapp.py frontends/tuiapp_v2.py frontends/tui_v3.pygit diff --checktuiapp_v2.py与ga_cli tui2相关进程均已退出。