Skip to content

fix(agent-core-v2): show task notifications in live transcript - #4465

Merged
wbxl2000 merged 3 commits into
mainfrom
fix/task-notification-live-prompt
Oct 29, 2026
Merged

wbxl2000 merged 3 commits into
mainfrom
fix/task-notification-live-prompt

Conversation

@kimi-agent-bot

@kimi-agent-bot kimi-agent-bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

修复后台任务完成并自动开启后续回合时,desktop / web 的 live 会话只显示后续工具活动、看不到 NotificationCard 的问题。

Bug Reproduction Steps

  1. 启动一个 detached 后台任务,并让主 Agent 进入空闲状态。
  2. 等待任务完成,观察自动开启的 task-origin 回合。
  3. 回合仍在运行时,模型已经收到完整 <notification>,但 live 时间线没有 NotificationCard;后续 heal 完成后卡片才出现。

Root Cause

TurnStarted 对 task origin 不携带公开 prompt,而 kap-server 的 live 投影又把同任务的 task.notified 当作“本轮 prompt 的重复内容”丢弃。因此,live transcript 既没有通知 prompt,也没有通知 frame,客户端没有数据生成 NotificationCard。冷快照 heal 随后补回 prompt,所以通知又会显示。

本次是根本修复:为 task-origin 的 TurnStarted 增加仅用于 transcript 投影的内部 transcriptPrompt,让完整通知直接进入 live prompt。公开 prompt 和公共 TurnStartedEvent 类型保持原契约,WS / SDK / klient 边界均剥离内部字段,避免原始 XML 泄露给既有客户端。

Code Changes

 TurnStarted
   prompt: 保持原行为(task origin 仍为空)
+  transcriptPrompt: 仅 task origin 携带完整通知
+  公共 TurnStartedEvent 类型排除该内部字段

 kap-server live projector
+  使用 transcriptPrompt ?? prompt 生成 turn.prompt
   同任务通知去重逻辑不变

 公共边界
+  WS / node-sdk / klient memory 均剥离 transcriptPrompt

 回归测试
+  真实 Agent 验证公开 prompt 不变、内部通知完整
+  prompt 与 transcriptPrompt 两种输入均验证 live + heal 不重复
+  WS live 与磁盘 replay 均验证字段不泄露、wire keys 不变
+  SDK 验证公共类型与运行时均不暴露内部字段
+  klient validate:false 验证内部字段不泄露

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
task-origin 回合的 live 通知 仅 heal 后可见 回合运行中即可见 desktop / web 用户 无;这是恢复预期显示
task-origin 的公开 TurnStarted.prompt 为空 仍为空 TUI、print、ACP、external hooks 行为不变
transcriptPrompt 内部字段 不存在 新增并仅在 transcript 投影使用 既有 WS / SDK / klient 客户端 各出口均剥离,公共 SDK 类型也不暴露
live 与 heal 的通知数量 live 可能缺失,heal 后补一张 live 与 heal 均保持一张 desktop / web 历史与实时视图 两种 prompt 输入均有不重复回归
非 task-origin 的 prompt 与其他客户端行为 现有行为 不变 其余客户端与入口 未修改相关分支

受影响模块与验证:

  • agent-core-v2:idle-notification-repro 6 个测试通过;typecheck 通过。
  • kap-server:transcript 与 sessionEventBroadcaster 共 232 个测试通过;typecheck 通过。
  • node-sdk:session-event-wiring 6 个测试通过,包含公共类型断言;typecheck 通过。
  • klient:memory 32 个测试通过,包含 validate:false;typecheck 与 examples typecheck 通过。
  • check-no-comments:1776 个文件通过。
  • 变更文件 oxlint --type-aware --threads=1:77 warnings、0 errors;全仓 pnpm run lint 与其余 CI 检查均已通过(test-windows 按设计 skip)。
  • 不需要文档更新:本 PR 恢复既有通知显示,不新增配置、公开 API 或迁移要求。

UI Evidence

使用真实 kap-server 与随仓库打包的 Kimi Code Web,在两个版本中执行同一受控场景:后台 Bash 完成后自动开启 task-origin 回合。

  • 修复前 d18a7bcd3:回合仍在运行(busy=true),模型已收到完整通知,Skill 卡可见,但 NotificationCard 为 0。
  • 修复后 650415b60:同一 live 阶段 NotificationCard 为 1,通知正文和输出路径可见;heal 完成后仍为 1,没有重复。
  • 两次驱动的全部断言均通过。截图只裁剪空白区域,没有重绘或修改 UI 内容。

Notification 修复前后真实 UI 对比

查看两次实测的机器判定 JSON

Checklist

  • I have read the CONTRIBUTING document.
  • 本次无单独 issue;问题、复现与修复范围已在本文说明。
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 741bd53

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 Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T05:03:04.904063Z 741bd53 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 Oct 27, 2026 •

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

commit: 741bd53

@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: 24b690463b

ℹ️ 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".

export class TurnPrompt extends AgentEvent2<z.infer<typeof turnPromptSchema>> {
static override readonly type = 'turn.prompt';
static override readonly durable = true;
static override readonly observable = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep turn.prompt off public event streams

Setting observable publishes TurnPrompt for every turn, not only task-origin turns. Both kap-server's broadcaster and node-sdk's session wiring forward observable events, but turn.prompt is absent from the public agentEventSchema and the SDK's closed Event union, so schema-validating desktop/web clients can reject or drop every prompt event and exhaustive SDK consumers receive an event their API says is impossible. The event also carries raw input, including hook-injected parts and unprojected media URLs that TurnStarted deliberately filters. Keep this event internal to transcript projection or explicitly filter it at every public boundary. These contracts have external desktop, web, extension, and SDK consumers.

AGENTS.md reference: AGENTS.md:L123-L125

Useful? React with 👍 / 👎.

kimi-agent-bot and others added 3 commits October 28, 2026 12:43
Read the active prompt by turn id instead of adding transcript-only event data.
Prevent duplicate notification frames during cold heals.
Publish turn.prompt on the agent event bus and consume it in live transcript projection.
Forward observable turn prompts through WS, SDK, and klient.
@sailist
sailist force-pushed the fix/task-notification-live-prompt branch from 24b6904 to 741bd53 Compare October 28, 2026 05:01
@wbxl2000
wbxl2000 merged commit 89e07b8 into main Oct 29, 2026
16 checks passed
@wbxl2000
wbxl2000 deleted the fix/task-notification-live-prompt branch October 29, 2026 06:16
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
The behaviour of MoonshotAI#4421 has been in the requester since 94397aa, but its
suite still asserted only that the lowered system message lost its
`tools` field, which a message kept in place would also satisfy. Assert
instead that no system message survives and the history keeps its
length, and rename the case after what it protects.

Also settle ten ledger rows that were already implemented here: MoonshotAI#3733,
MoonshotAI#4413, MoonshotAI#4418, MoonshotAI#4421, MoonshotAI#4435, MoonshotAI#4460, MoonshotAI#4465, MoonshotAI#4516, MoonshotAI#4523, MoonshotAI#4532 and the
MoonshotAI#4558 test calibration, each with a probe over the suite that pins it.
Two rows carried a probe without a test-name selector (MoonshotAI#4557, MoonshotAI#4558),
which aborted `--verify` for every other row; MoonshotAI#4557 is a changelog sync
and now carries a manual probe.
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.

3 participants