[CN-fork] P-023: 网关投递漏接的 /steer 作为下一轮(修复桌面端引导失效) - #37
Merged
Merged
Conversation
run_conversation() only injects /steer into a *following* tool result. A steer that lands after the final tool batch — or during a text-only turn — comes back as result["pending_steer"] for the caller to re-deliver. cli.py consumes it, but the tui_gateway turn-runner (every desktop/TUI/Dashboard chat) never read it, so the leftover steer was silently dropped. This is acute on the desktop, whose default busy-input mode is "steer": users reported (NousResearch#193) that a steer sent mid-task "等到任务执行完也没插入进去". Fix mirrors the existing goal_followup chain: capture result["pending_steer"] and, after the finally releases session["running"], fire a nested _run_prompt_submit with the steered text. Guarded by the running flag so a racing real prompt wins; runs before goal continuation since it's explicit user input. No extra message.start (the nested call emits its own). Tests: tests/tui_gateway/test_pending_steer_followup.py. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-import |
1 |
First entries
tests/tui_gateway/test_pending_steer_followup.py:16: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
✅ Fixed issues: none
Unchanged: 5108 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
|
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.
背景(桌面端 NousResearch#193 反馈)
桌面端运行时输入行为默认是 引导(steer)。用户在 agent 忙时发送引导,
session.steer被接受(agent.steer()返回queued),但任务结束后引导内容并未生效。根因
agent.steer(text)只能把引导注入到后续的工具结果里(agent/conversation_loop.py的 pre-API / post-tool drain)。当引导落在最后一个工具批次之后,或落在纯文本回合(没有后续工具调用)时,run_conversation()会把它作为result["pending_steer"]返回,交由调用方重新投递。cli.py会消费result.get("pending_steer")✅tui_gateway的回合执行器(桌面端 / TUI / Dashboard 聊天都走它)从未读取它 ❌ → 漏接的引导被静默丢弃。修复
仿照已有的
goal_followup续跑链路(同文件):run()里捕获result["pending_steer"]→steer_followup。finally释放session["running"]之后,用引导文本发起一次嵌套_run_prompt_submit。running标志保护——抢跑的真实用户输入优先;引导优先级高于 goal 续跑(它自己的回合结束会再触发 goal 判定)。_emit("message.start")(嵌套调用自己会发)。净效果:引导若能即时注入工具结果 → 即时生效;若漏接 → 任务结束后作为新一轮自动跑(与 CLI 行为一致),不再静默消失。
测试
tests/tui_gateway/test_pending_steer_followup.py:第一轮返回pending_steer→ 断言执行器自动追加携带引导文本的第二轮;无pending_steer时不追加;不会无限循环。ruff check通过;tests/tui_gateway/+tests/run_agent/test_steer.py共 126 项回归通过。FORK_NOTES
新增 P-023(中英双语表格 + 英文详述)。建议上游(通用可靠性修复)。
这是 Core 改动。要让运行中的桌面端生效,需要发一个
runtime-v*运行时版本并由桌面端 managed runtime 升级承载——单独此 PR 合并不会立即改变用户已安装桌面端的行为。🤖 Generated with Claude Code