Skip to content

fix(agent-core-v2): ignore non-user prompts during Tower wake - #4952

Merged
sailist merged 3 commits into
bug-370-11-15-release-fixesfrom
bug-372-11-15-tower-task-manual-termination
Nov 15, 2026
Merged

sailist merged 3 commits into
bug-370-11-15-release-fixesfrom
bug-372-11-15-tower-task-manual-termination

Conversation

@sailist

@sailist sailist commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

Tower 用户没有主动停止任务时,后台通知仍可能让唤醒轮次进入用户取消路径,使 TUI 显示用户中断、Desktop 显示“已手动终止”,后续通知与轮询也可能停摆。

本 PR 让 Tower 只把真实用户提交识别为唤醒轮次的抢占信号,同时保留后台通知的正常投递与队列推进。

Bug Reproduction Steps

  1. 开启 Tower,并让主 Agent 处于 tower_inbox 唤醒轮次。
  2. 在唤醒轮次结束前完成一个后台 Task,或投递 cron/injection 通知。
  3. 修复前,这些内部来源也会派发 PromptSubmitted,Tower 以 Aborted by the user 取消当前唤醒轮次;没有真实用户 continuation 时,Loop 还可能进入不自动续跑的中断态。
  4. 修复后,内部通知不会触发用户取消;真实用户提交仍会取消唤醒轮次,并在用户轮次结束后重新唤醒 Tower。

Root Cause

Loop runtime 迁移(#4630)后,普通用户、Task、cron 和 injection 都会经过统一的 Prompt 投影并发布 PromptSubmitted,但事件没有携带已有的 PromptOrigin。Tower 的唤醒抢占订阅只检查 agent 与 turn,因此把所有来源都当成真实用户,并固定使用用户取消原因。

这是根本修复,不是修改状态文案或绕过取消结果:事件显式携带来源,Tower 在取消前按来源作出判断。

Code Changes

保留所有来源的提交事件,在事件生产端透传完整 origin。Tower 的抢占入口接受普通用户、user-slash 的 skill activation 与 plugin command,排除后台通知和模型触发的 skill activation。

 PromptSubmitted
+  origin: projection.origin

 Tower.onPromptSubmitted
+  userInitiated =
+    origin.kind === 'user' ||
+    origin.kind === 'plugin_command' ||
+    (origin.kind === 'skill_activation' && origin.trigger === 'user-slash')
+  if !userInitiated return
   cancelWakeAsUser()

PromptSubmittedEvent 与 PromptSubmittedPayload 使用同一个必需 PromptOrigin 字段;该事件非 durable,不涉及旧 Wire 记录迁移。PromptQueued、PromptStarted、Task 状态、Tower roster 和真实用户取消/重新唤醒逻辑均不变。另附 CLI patch changeset。

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
Tower 唤醒轮次收到 Task、cron 或 injection 被当作用户提交,以用户原因取消唤醒轮次,可能显示手动终止并停止后续推进 非用户来源不取消,通知继续按原队列语义处理 Tower 的 TUI 与 Desktop 用户;对错误抢占的依赖属于缺陷行为 无;真实用户抢占保留
Tower 唤醒轮次收到普通用户提交、user-slash 的 skill activation 或 plugin command 取消唤醒轮次,并在用户轮次结束后重新唤醒 不变;model-tool/nested-skill 不抢占 Tower 用户及主动使用 slash 命令的用户 不适用
prompt.submitted 载荷 不携带来源,消费者无法区分用户与内部通知 所有来源仍发布事件,并新增完整 origin 监听该事件的客户端与自动化消费者 旧字段和事件顺序不变,消费者可忽略新增字段

覆盖情况:Prompt 生命周期测试校验用户与 Task 的来源以及三个队列项全部启动;Tower 测试覆盖 Task/injection/model-tool skill 不取消,普通用户及两类 user-slash 均取消,并保留后续重新唤醒;Loop、Plan、Tool、Config 快照覆盖新增事件字段。两轮全仓类型检查与标准构建均通过。远程 Linux 测试因 SSH 主机密钥校验失败未能执行,Desktop/真实 Tower 端到端场景也未执行。

验证详情
  • 修复前,目标测试为 2 failed / 214 passed,分别复现事件缺少来源和 Task/injection 触发用户取消。
  • 修复后,同组 Prompt 与 Tower 测试 216/216 通过。
  • Loop、Plan、Tool、Config 相关测试 387/387 通过,本地合计 603/603。
  • agent-core-v2 typecheck、全仓 corepack pnpm run typecheck、全仓 corepack pnpm run build 均通过。
  • 九个实现/测试文件聚焦 lint 为 0 errors / 8 个既有 import warnings。
  • user-slash 补充轮:修改前目标测试 1 failed / 1 passed,修改后 2/2,完整 Tower 文件 183/183;该轮全仓 typecheck 与 build 通过,两个改动文件 lint 为 0 errors / 1 个既有 import warning。
  • 未增加测试声明数。

Checklist

  • I have read the CONTRIBUTING document.
  • No dedicated issue was supplied; the user report and reproduction are included above.
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and the changeset names the erroneous behavior being removed; no escape hatch is provided for that defect because real user preemption is preserved.
  • Added a patch changeset following the gen-changesets rules.
  • No documentation update is needed; this is an additive runtime event field with no documented schema or configuration change.

@changeset-bot

changeset-bot Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0fc0c57

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T03:00:21.145461Z 0fc0c57 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@0fc0c57
npx https://pkg.pr.new/@moonshot-ai/kimi-code@0fc0c57

commit: 0fc0c57

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa6ffb5c30

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if (this.agentCtx.agentId !== 'main') return;
if (!this.isActive) return;
if (event.agentId !== this.agentCtx.agentId) return;
if (event.origin.kind !== 'user') return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve user-initiated slash commands during Tower wakes

When a Tower inbox wake is active, this literal kind !== 'user' check also ignores human-originated submissions whose origins deliberately use other kinds. For example, AgentPluginCommandService.activate() submits a plugin_command with trigger: 'user-slash', and direct skill activation similarly uses skill_activation with trigger: 'user-slash'; previously either submission canceled the background wake, whereas now a plugin command remains queued behind it and a direct skill activation no longer follows the normal user-interruption path. Please distinguish background origins from all user-initiated origins rather than accepting only the user kind.

AGENTS.md reference: AGENTS.md:L110-L112

Useful? React with 👍 / 👎.

@sailist
sailist merged commit 46016ea into bug-370-11-15-release-fixes Nov 15, 2026
15 checks passed
@sailist
sailist deleted the bug-372-11-15-tower-task-manual-termination branch November 15, 2026 03:06
sailist added a commit that referenced this pull request Nov 16, 2026
…#4992)

* fix(agent-core-v2): ignore non-user prompts during Tower wake

* chore: add Tower notification fix changeset

* fix(agent-core-v2): preserve slash prompts during Tower wake
wbxl2000 pushed a commit that referenced this pull request Nov 17, 2026
* fix: resume sessions with removed default models (#4982)

* fix(node-sdk): resume sessions with missing default model

* fix(cli): check auth for the resumed session model

* chore: add changeset for unavailable model recovery

* fix(agent-core-v2): stop rebuilding mismatched session indexes (#4980)

* fix(agent-core-v2): reject repeated model responses (#4977)

* fix(agent-core-v2): reject repeated model responses

* chore: add changeset for repeated model responses

---------

Co-authored-by: 7Sageer <[email protected]>

* fix(agent-core-v2): inline deferred tools without dynamic loading (#4971)

* fix(agent-core-v2): record restored task notifications without model requests (#4949) (#4989)

* fix(agent-core-v2): record restored task notifications without model requests

- queue restored task notifications as prompt-only turns after loop initialization
- preserve interrupted and queued turns during resume and fork
- complete reconciliation before initialization and reset return to keep Wire reads ordered
- run loop and container cleanup when reconciliation fails
- surface restored notification persistence failures

* chore: add changeset for restored task notifications

* fix(agent-core-v2): restore overflow recovery after LLM retries (#4950) (#4990)

* fix(agent-core-v2): restore step state after LLM retries

* test(agent-core-v2): scope retry event to overflow regression

* fix(config): allow sessions with invalid user config (#4951) (#4991)

* fix(agent-core-v2): tolerate config read failures for permission rules

* chore: add changeset for permission config recovery

* docs: document permission config recovery

* docs: qualify permission config recovery scope

* fix(config): surface read error diagnostics

* fix(config): allow sessions with invalid user config

* fix(config): preserve valid values and replay diagnostics

* fix(config): remove startup diagnostic replay

* fix(agent-core-v2): ignore non-user prompts during Tower wake (#4952) (#4992)

* fix(agent-core-v2): ignore non-user prompts during Tower wake

* chore: add Tower notification fix changeset

* fix(agent-core-v2): preserve slash prompts during Tower wake

* fix(agent-core-v2): route foreground shell events by origin (#4954) (#4994)

* fix(agent-core-v2): route foreground shell events by origin

* test(agent-core-v2): expect tool event origins in snapshots

* fix(klient): accept tool events from pre-origin hosts

* fix(agent-core-v2): run external Stop hooks after turn completion (#4956) (#4995)

* fix(agent-core-v2): run external Stop hooks after turn completion

* chore: add changeset for external Stop hooks

* docs: clarify post-turn Stop hook timing

* fix(agent-core-v2): wait for subagent quiescence (#4953) (#4993)

* fix(agent-core-v2): reject incomplete model streams (#5006)

* fix(agent-core-v2): preserve choice-level OpenAI token usage (#5017)

* fix(capability): confirm stopping WebBridge before Windows updates (#4999)

* fix(capability): confirm stopping WebBridge before Windows updates

* fix(capability): harden WebBridge update recovery

* fix(capability): restore WebBridge after startup failure

* fix(capability): wait for WebBridge process exit

* fix(capability): handle WebBridge confirmation edge cases

---------

Co-authored-by: kimi-agent-bot <[email protected]>
Co-authored-by: kimi-agent-bot <[email protected]>

* chore: sync release 2.6.3 back to main

* chore: finish release 2.6.3 backsync

* chore: sync node-sdk lockfile importer

* fix(sdk): preserve main core type dependencies

* fix: complete release 2.6.3 backsync

---------

Co-authored-by: Haozhe <[email protected]>
Co-authored-by: 7Sageer <[email protected]>
Co-authored-by: kimi-agent-bot <[email protected]>
Co-authored-by: kimi-agent-bot <[email protected]>
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