Skip to content

feat: add an experimental Monitor tool - #4085

Open
chengluyu wants to merge 10 commits into
mainfrom
feat/monitor-tool
Open

chengluyu wants to merge 10 commits into
mainfrom
feat/monitor-tool

Conversation

@chengluyu

@chengluyu chengluyu commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator
中文版

需求或 Bug

新功能。目前智能体只能在后台任务结束时收到通知;想在"日志出现某行""服务器就绪""测试失败"时立即做出反应,只能用 Bash sleep 循环轮询,或在 WaitFor 中阻塞。本 PR 新增实验性的 Monitor 工具:在后台运行一条命令,其 stdout 的每一行在智能体继续工作的同时送达。

Bug 复现步骤

N/A(新功能)。

根本原因

N/A(新功能)。

代码变更

 Monitor 工具(agent-core-v2,实验开关 monitor,默认关闭)
+  参数:command、description、timeout(默认 300s,上限 3600s)、persistent
+  仅主智能体可用;需要 TaskStop 可用;在启动命令前检查后台任务数量上限;与 Bash 一样走审批与危险命令检查
+  Plan 模式下被拒绝(TaskStop 在 Plan 模式下被禁用,monitor 将无法停止)
+  以 detached 后台任务运行(task id 前缀 monitor-,kind 仍为 process)
+  会话结束时总会停止,即使设置了 keep_alive_on_exit(AgentTask.stopsWithSession);启动期间调用被中断则终止进程、不注册任务

 AgentTaskService
+  AgentTaskSink.appendEvent:MonitorProcessTask 把 stdout 送入事件流(stderr 只进任务输出)
+  TaskEventStream:按行切分 → 1s 批处理 → 同一 monitor 同时最多一条未消费的通知
+    单行上限 2000 字符(超出部分丢弃到下一个换行);每批保留最新 50 行;每分钟超过 300 行则停止 monitor 并说明原因
+    按批次计数未消费的通知,WaitFor 不会漏掉结束时补发的一批
+    任务结束时先送出剩余行(包括没有换行的最后一行),再发完成通知
+    shell 退出后继续读取 stdout 直到 EOF(后台子进程仍可能输出),被停止或超时时才截断
+  事件通过 loop.notify 送达(与完成通知同一路径:空闲时开启新轮次,忙碌时在下一步送达)
+    origin: { kind: 'task', status: 'running', notificationId: task:<id>:event:<n> }
+    type="task.event",行包在 <event> 块中并转义 & < >;省略的行数写在 <event omitted="N"> 上
+  事件不写入通知去重状态(isTaskOrigin 忽略 status: running)
+  消费时发布 background.task.event(taskId、description、lines、omitted)

 WaitFor
+  传入 monitor 的 task_id 时,该 monitor 有新事件即返回 wait_status: event(event_task_id)
+    调用时已有未消费事件则直接返回
+  不传 task_id 时不等待 monitor:既不因 monitor 事件返回,也不等它结束;
+    只剩 monitor 在运行时返回 no_tasks 与 running_monitors: N,说明只有 monitor 在运行,可传入 monitor 的 task_id
+  monitor 开关打开时,WaitFor 工具说明追加一段 monitor 规则(开关关闭时提示词不变)

 print 模式(kimi -p)
+  drain / steer 不等待 monitor;退出时由 stopAllOnExit 停止

 Bash
~  spawn / stdin / kill 辅助函数移到 shellProcess.ts,供 Monitor 复用(行为不变)

 ACP(acp-server)
+  显式传入 mergeStderr: false 的 spawn(即 Monitor)在本地运行,不进入客户端终端(终端只有合并后的输出流);Bash 路由不变

 TUI
+  Monitor 工具标题:"Starting a monitor · $ <command>" / "Started a monitor"
+  monitor 事件行:"● monitor event (<description>)" + 最新 6 行,并显示省略的行数(实时与回放一致)
+  monitor 任务显示为 "monitor started / stopped",而不是 "bash task"
+  WaitFor "Wait ended by monitor output (<id>)"、"Nothing to wait for (only monitors running)";审批标题 "Start this monitor?"

行为变化与受影响用户

行为 之前 之后 依赖旧行为的人 退路
Monitor 工具 不存在 开关打开时提供给主智能体 无(默认关闭) 保持开关关闭
任务通知 只有终止状态 新增 type="task.event"、status: running 的通知 只在使用 Monitor 时出现 同上
Notification hook 只在任务结束时触发 每批 monitor 事件也会触发(notification type task.event) hook 脚本 用 matcher 过滤
SDK / kap-server 事件流 — 新增 background.task.event SDK 使用者、WebSocket 客户端 新增类型,可忽略
WaitFor 结果 4 种 wait_status 新增 event(仅在传入 monitor 的 task_id 时) 解析 WaitFor 输出的客户端 只在使用 Monitor 时出现
不传 task_id 的 WaitFor 等待所有运行中的任务 不包括 monitor — 传入 monitor 的 task_id
危险命令检查 只检查 Bash 同样检查 Monitor — —
Plan 模式 — 拒绝 Monitor — 先 ExitPlanMode
print 模式 drain / steer 等待所有运行中的后台任务 不等待 monitor 无(monitor 是新增的) —
keep_alive_on_exit 会话关闭时保留所有后台任务 monitor 仍会停止,其他任务照旧保留 无(monitor 是新增的) —

契约文件:agent-core-v2/src/events.ts(AgentEvent 联合类型)、SDK 的 events.ts 和 kap-server 的 events-zod.ts(WebSocket 事件 schema)只做了新增;API 快照不变。packages/acp-server/ 只改了 spawn 路由:ACP 客户端(如 Zed)不会看到 monitor 的终端,Bash 仍在客户端终端运行。旧版客户端收到 monitor 事件时:desktop / web(code-app)把它显示为普通任务通知卡片;旧版 TUI 回放时显示为 "bash task started"。state-manifest 与 wire-manifest 没有变化。桌面端和 Web 的卡片在单独的 code-app PR 中实现。工具文档与 hooks 文档(中英文)已更新。

测试:taskService.test.ts(设置 keep_alive_on_exit 时 monitor 仍在退出时停止)、taskManager.test.ts(shell 退出后仍送达迟到的行、此时停止仍能结束、行切分、批处理、未消费时暂存、结束时刷新、截断、速率上限;monitor 任务的通知、stderr 不送达、普通 Bash 不产生事件、超限停止)、idle-notification-repro.test.ts(真实智能体:事件唤醒空闲智能体,回放一致)、task-tools.test.ts(WaitFor 被指定 monitor 的事件结束、已有事件立即返回、不传 task_id 时不受 monitor 事件影响、只剩 monitor 时返回 no_tasks)、bash.test.ts(Monitor 默认超时、persistent、子智能体拒绝、无 TaskStop 拒绝、达到任务上限时不启动命令、启动期间中断时终止进程、timeout 上限)、permissionPolicyService.test.ts(Monitor 危险命令)、planGuard.test.ts(Plan 模式拒绝 Monitor)、sessionEventBroadcaster.test.ts(WebSocket schema)、acp-terminal.test.ts(mergeStderr: false 的 spawn 在本地运行)、v2-run-print.test.ts(drain / steer 不等待 monitor);TUI 的回放、实时事件、状态文案、标题和事件行渲染。端到端场景在单独的 PR 中。

Requirement or Bug

A new feature. Today the agent hears from a background task only when it ends. To react to a log line, a server becoming ready or a failing test as it happens, it has to poll with Bash sleep loops or block in WaitFor. This PR adds an experimental Monitor tool: it runs a background command, and each stdout line reaches the agent while it keeps working.

Bug Reproduction Steps

N/A (new feature).

Root Cause

N/A (new feature).

Code Changes

 Monitor tool (agent-core-v2, experimental flag `monitor`, off by default)
+  args: command, description, timeout (default 300s, max 3600s), persistent
+  main agent only; needs TaskStop; checks the background task limit before running the command; goes through approval and the dangerous-command check like Bash
+  refused in Plan mode (TaskStop is blocked there, so the monitor could not be stopped)
+  runs as a detached background task (task id prefix monitor-, kind stays process)
+  always stops when the session ends, even with keep_alive_on_exit (AgentTask.stopsWithSession); a call aborted during spawn kills the process and registers nothing

 AgentTaskService
+  AgentTaskSink.appendEvent: MonitorProcessTask feeds stdout to an event stream (stderr only goes to the task output)
+  TaskEventStream: split into lines → 1s batches → at most one unconsumed notification per monitor
+    line cap 2000 chars (the rest is dropped up to the next newline); a batch keeps the newest 50 lines; more than 300 lines a minute stops the monitor with a reason
+    undelivered notifications are counted per batch, so WaitFor does not miss a final batch sent at close
+    at task end, remaining lines (including an unterminated last line) are sent before the completion notification
+    after the shell exits, stdout is read until EOF (a descendant may still write), cut off only when the task is stopped or times out
+  events go through loop.notify (same path as completion notices: an idle agent starts a turn, a busy one gets it at the next step)
+    origin: { kind: 'task', status: 'running', notificationId: task:<id>:event:<n> }
+    type="task.event"; lines are wrapped in an <event> block with & < > escaped; the omitted count goes on <event omitted="N">
+  events stay out of the notification dedup state (isTaskOrigin ignores status: running)
+  on consumption, background.task.event is published (taskId, description, lines, omitted)

 WaitFor
+  with a monitor's task_id, returns wait_status: event (event_task_id) as soon as that monitor has a new event
+    returns at once if one is already waiting to be consumed
+  without a task_id, monitors are left out: their events do not end the wait and their end is not waited for;
+    with only monitors running it returns no_tasks with running_monitors: N, says only monitors are running and that a monitor's task_id can be passed
+  with the monitor flag on, the WaitFor description gains a short section on monitors (unchanged with the flag off)

 Print mode (kimi -p)
+  drain / steer do not wait for monitors; exit stops them via stopAllOnExit

 Bash
~  spawn / stdin / kill helpers moved to shellProcess.ts for Monitor to reuse (no behavior change)

 ACP (acp-server)
+  spawns that explicitly pass mergeStderr: false (i.e. Monitor) run locally instead of in the client terminal, which only has a combined stream; Bash routing unchanged

 TUI
+  Monitor tool header: "Starting a monitor · $ <command>" / "Started a monitor"
+  monitor event row: "● monitor event (<description>)" + the latest 6 lines and the omitted count (live and on replay)
+  monitor tasks read "monitor started / stopped" instead of "bash task"
+  WaitFor "Wait ended by monitor output (<id>)", "Nothing to wait for (only monitors running)"; approval header "Start this monitor?"

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
Monitor tool does not exist offered to the main agent when the flag is on none (off by default) keep the flag off
Task notifications terminal states only adds type="task.event" notifications with status: running appear only when Monitor is used same
Notification hook fires when a task ends also fires for each monitor event batch (notification type task.event) hook scripts filter with a matcher
SDK / kap-server event stream — adds background.task.event SDK users, WebSocket clients additive; ignore it
WaitFor result 4 wait_status values adds event (only with a monitor's task_id) clients that parse WaitFor output appears only when Monitor is used
WaitFor without task_id waits on every running task monitors left out — pass a monitor's task_id
Dangerous-command check Bash only also Monitor — —
Plan mode — refuses Monitor — ExitPlanMode first
Print mode drain / steer waits for every running background task does not wait for monitors none (monitors are new) —
keep_alive_on_exit keeps every background task when the session closes monitors still stop; other tasks are kept as before none (monitors are new) —

Contract files: agent-core-v2/src/events.ts (the AgentEvent union), the SDK's events.ts and kap-server's events-zod.ts (the WebSocket event schema) only gain members; the API snapshot is unchanged. In packages/acp-server/ only spawn routing changes: ACP clients such as Zed get no terminal for a monitor, while Bash still runs in the client terminal. Older clients that receive a monitor event: desktop and web (code-app) show it as an ordinary task notification card, and an older TUI replays it as "bash task started". state-manifest and wire-manifest are unchanged. The desktop and web card comes in a separate code-app PR. Tool and hook docs (en/zh) updated.

Tests: taskService.test.ts (monitors still stop at exit with keep_alive_on_exit), taskManager.test.ts (late lines after the shell exits still delivered, stopping in that window still settles, line splitting, batching, holding while unconsumed, flush at close, truncation, rate cap; monitor task notifications, stderr not delivered, plain Bash produces no events, stopped over the limit), idle-notification-repro.test.ts (real agent: an event wakes an idle agent, resume replay matches), task-tools.test.ts (WaitFor ended by the named monitor's event, immediate return when one is pending, a WaitFor without task_id unaffected by monitor events, no_tasks when only monitors run), bash.test.ts (Monitor default timeout, persistent, refused in a subagent, refused without TaskStop, command never started at the task limit, killed when aborted during spawn, timeout cap), permissionPolicyService.test.ts (Monitor dangerous command), planGuard.test.ts (Plan mode refuses Monitor), sessionEventBroadcaster.test.ts (WebSocket schema), acp-terminal.test.ts (a spawn with mergeStderr: false runs locally), v2-run-print.test.ts (drain / steer do not wait for monitors); TUI replay, live events, status wording, headers and the event row. End-to-end scenarios come in a separate PR.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • 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.

Copilot AI balanced review requested due to automatic review settings September 29, 2026 15:03
@changeset-bot

changeset-bot Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1c67949

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 Minor

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 Sep 29, 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-09-29T20:24:59.347554Z 1c67949 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 Sep 29, 2026 •

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

commit: 1c67949

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Event chunking, queued-batch tracking, and TUI replay currently produce incorrect behavior for several supported output cases.

Review effort: Balanced
Findings: 1 High severity · 3 Medium severity · 2 Low severity

Open (6)
What changed in this PR

Adds an opt-in Monitor tool that streams background command output to the main agent.

Changes:

  • Implements monitored processes, batching, rate limits, notifications, and WaitFor integration.
  • Exposes monitor events through the SDK and renders them in the TUI.
  • Adds comprehensive tests, bilingual documentation, and a changeset.
File Description
.changeset/​monitor-tool.md Records the experimental feature.
packages/​node-sdk/​src/​events.ts Exports the monitor event type.
packages/​node-sdk/​test/​session-event-types.test.ts Covers the new event union member.
packages/​agent-core-v2/​src/​index.ts Registers and exports Monitor.
packages/​agent-core-v2/​src/​events.ts Adds monitor delivery events.
packages/​agent-core-v2/​src/​app/​telemetry/​events.ts Adds the event wait outcome.
packages/​agent-core-v2/​src/​session/​agentLifecycle/​profile/​profiles.ts Enables Monitor for the main profile.
packages/​agent-core-v2/​src/​agent/​tools/​mainAgentOnly.ts Adds the main-agent restriction message.
packages/​agent-core-v2/​src/​agent/​tools/​task/​monitor/​flag.ts Defines the experimental flag.
packages/​agent-core-v2/​src/​agent/​tools/​task/​monitor/​monitor.ts Defines Monitor arguments and limits.
packages/​agent-core-v2/​src/​agent/​tools/​task/​monitor/​monitor.md Provides model-facing usage guidance.
packages/​agent-core-v2/​src/​agent/​tools/​task/​monitor/​monitorTool.ts Implements monitored process startup.
packages/​agent-core-v2/​src/​agent/​tools/​task/​task-wait/​taskWaitTool.ts Lets events interrupt WaitFor.
packages/​agent-core-v2/​src/​agent/​tools/​os/​bash/​shellProcess.ts Extracts reusable shell helpers.
packages/​agent-core-v2/​src/​agent/​tools/​os/​bash/​process-task.ts Forwards selected stdout as events.
packages/​agent-core-v2/​src/​agent/​tools/​os/​bash/​bashTool.ts Uses the extracted shell helpers.
packages/​agent-core-v2/​src/​agent/​task/​task.ts Extends the task service contract.
packages/​agent-core-v2/​src/​agent/​task/​types.ts Adds the event sink callback.
packages/​agent-core-v2/​src/​agent/​task/​taskEvents.ts Implements line buffering and batching.
packages/​agent-core-v2/​src/​agent/​task/​taskOps.ts Defines the observable delivery event.
packages/​agent-core-v2/​src/​agent/​task/​taskService.ts Delivers and publishes monitor events.
packages/​agent-core-v2/​src/​agent/​permissionPolicy/​policies/​dangerous-command-ask.ts Applies dangerous-command checks.
packages/​agent-core-v2/​test/​os/​backends/​node-local/​tools/​bash.test.ts Tests Monitor startup constraints.
packages/​agent-core-v2/​test/​agent/​task/​tools/​task-tools.test.ts Tests event-driven waits.
packages/​agent-core-v2/​test/​agent/​task/​taskManager.test.ts Tests event stream behavior.
packages/​agent-core-v2/​test/​agent/​task/​idle-notification-repro.test.ts Tests idle-agent wake-up.
packages/​agent-core-v2/​test/​agent/​permissionPolicy/​permissionPolicyService.test.ts Tests dangerous Monitor commands.
apps/​kimi-code/​src/​tui/​types.ts Adds monitor status presentation data.
apps/​kimi-code/​src/​tui/​utils/​monitor-event.ts Parses and formats monitor events.
apps/​kimi-code/​src/​tui/​utils/​background-task-status.ts Labels monitor task IDs.
apps/​kimi-code/​src/​tui/​controllers/​session-replay.ts Replays monitor notifications.
apps/​kimi-code/​src/​tui/​controllers/​session-event-handler.ts Handles live monitor events.
apps/​kimi-code/​src/​tui/​components/​messages/​background-agent-status.ts Renders recent event lines.
apps/​kimi-code/​src/​tui/​components/​messages/​tool-call.ts Adds Monitor tool headers.
apps/​kimi-code/​src/​tui/​components/​messages/​tool-renderers/​wait-for.ts Renders event-ended waits.
apps/​kimi-code/​src/​tui/​components/​dialogs/​approval-panel.ts Adds Monitor approval text.
apps/​kimi-code/​test/​tui/​message-replay.test.ts Tests replay rendering.
apps/​kimi-code/​test/​tui/​controllers/​session-event-handler-background-task.test.ts Tests live event handling.
apps/​kimi-code/​test/​tui/​components/​messages/​tool-call.test.ts Tests Monitor and wait headers.
apps/​kimi-code/​test/​tui/​components/​messages/​background-agent-status.test.ts Tests event-line rendering.
apps/​kimi-code/​test/​tui/​background-task-status.test.ts Tests monitor task wording.
docs/​en/​reference/​tools.md Documents Monitor in English.
docs/​zh/​reference/​tools.md Documents Monitor in Chinese.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/agent-core-v2/src/agent/task/taskEvents.ts
Comment thread apps/kimi-code/src/tui/utils/monitor-event.ts Outdated
Comment thread packages/agent-core-v2/src/agent/task/taskEvents.ts
Comment thread docs/en/reference/tools.md Outdated
Comment thread docs/zh/reference/tools.md Outdated

@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: 81391ebc83

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

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/utils/monitor-event.ts Outdated
Comment thread packages/agent-core-v2/src/agent/task/taskService.ts
Comment thread packages/agent-core-v2/src/agent/task/taskEvents.ts
Comment thread packages/agent-core-v2/src/agent/tools/task/monitor/monitorTool.ts
Comment thread packages/agent-core-v2/src/events.ts
@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 03c1f35bdc

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

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: 7c95f634e0

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

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agent-core-v2/src/agent/task/taskService.ts Outdated
Comment thread packages/agent-core-v2/src/agent/tools/task/monitor/monitorTool.ts
@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@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: 6c74038e1d

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

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agent-core-v2/src/agent/tools/task/task-wait/taskWaitTool.ts Outdated
Comment thread packages/agent-core-v2/src/agent/tools/task/monitor/monitorTool.ts Outdated
@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@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: 588eed7a7e

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

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agent-core-v2/src/agent/tools/task/monitor/monitor.md
Comment thread packages/agent-core-v2/src/agent/tools/task/monitor/monitorTool.ts Outdated
@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@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: de6ff0e8fd

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

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agent-core-v2/src/agent/tools/task/monitor/monitorTool.ts
Comment thread packages/agent-core-v2/src/agent/tools/os/bash/process-task.ts
Comment thread .changeset/monitor-tool.md Outdated
@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@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: b7c3c92130

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

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agent-core-v2/src/agent/tools/task/monitor/monitorTool.ts
Comment thread apps/kimi-code/src/cli/v2/run-v2-print.ts Outdated
@chengluyu

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@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: 1c6794960f

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

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +985 to +986
export const backgroundTaskEventDeliveredEventSchema = z.object({
type: z.literal('background.task.event'),

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 Sync the web bundle for monitor events

When an experimental Monitor runs through the built-in web UI, kap-server now sends this new event, but the committed apps/kimi-code/dist-web bundle is unchanged from the parent commit and contains no background.task.event handler, while only the TUI gained a renderer. Web users therefore cannot see the monitored lines that the new card is meant to expose; sync and commit the corresponding code-app bundle with this protocol change.

AGENTS.md reference: AGENTS.md:L18-L18

Useful? React with 👍 / 👎.

Comment on lines +3 to +4
export const MONITOR_FLAG_ID = 'monitor';
export const MONITOR_FLAG_ENV = 'KIMI_CODE_EXPERIMENTAL_MONITOR';

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 Add the Monitor flag to the environment-variable reference

Users who rely on the environment-variable reference cannot discover this newly supported switch: the exhaustive runtime-switch table in both docs/en/configuration/env-vars.md and its Chinese mirror lists the other KIMI_CODE_EXPERIMENTAL_* variables and the master flag, but omits KIMI_CODE_EXPERIMENTAL_MONITOR. Add the variable and its accepted truthy/falsy values to both pages so the new opt-in path is documented consistently.

Useful? React with 👍 / 👎.

Comment on lines +23 to +30
timeout: z
.number()
.int()
.positive()
.max(MONITOR_MAX_TIMEOUT_S)
.optional()
.describe(
`Seconds before the monitor is stopped. Default ${String(MONITOR_DEFAULT_TIMEOUT_S)}, max ${String(MONITOR_MAX_TIMEOUT_S)}. Ignored when persistent is 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.

P2 Badge Ignore timeout validation for persistent monitors

When a call sets persistent: true, the field description says timeout is ignored, but this unconditional .max(MONITOR_MAX_TIMEOUT_S) still rejects values above one hour before MonitorTool.start() can discard them. Thus an otherwise valid persistent monitor such as { persistent: true, timeout: 7200 } fails argument validation despite the advertised contract; make the upper-bound check conditional on persistent !== true or accept and ignore the field.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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.

2 participants