Skip to content

[CN-fork] P-023: 网关投递漏接的 /steer 作为下一轮(修复桌面端引导失效) - #37

Merged
Eynzof merged 1 commit into
mainfrom
cn/fix-gateway-pending-steer
Jun 14, 2026
Merged

Eynzof merged 1 commit into
mainfrom
cn/fix-gateway-pending-steer

Conversation

@Eynzof

@Eynzof Eynzof commented Jun 14, 2026

Copy link
Copy Markdown
Owner

背景(桌面端 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 续跑链路(同文件):

  1. 在 run() 里捕获 result["pending_steer"] → steer_followup。
  2. 在 finally 释放 session["running"] 之后,用引导文本发起一次嵌套 _run_prompt_submit。
  3. 受 running 标志保护——抢跑的真实用户输入优先;引导优先级高于 goal 续跑(它自己的回合结束会再触发 goal 判定)。
  4. 不额外 _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

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>
@github-actions

Copy link
Copy Markdown

🔎 Lint report: cn/fix-gateway-pending-steer vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9847 on HEAD, 9846 on base (🆕 +1)

🆕 New issues (1):

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.

@github-actions

Copy link
Copy Markdown

⚠️ npm lockfile hash out of date

Checked against commit 59bd2bc (PR head at check time).

The hash = "sha256-..." line in these nix files no longer matches the committed package-lock.json:

Apply the fix

  • Apply lockfile fix — tick to push a commit with the correct hashes to this PR branch
  • Or run the Nix Lockfile Fix workflow manually (pass PR #37)
  • Or locally: nix run .#fix-lockfiles and commit the diff

@Eynzof
Eynzof merged commit e288a95 into main Jun 14, 2026
21 of 24 checks passed
@Eynzof
Eynzof deleted the cn/fix-gateway-pending-steer branch June 28, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant