Skip to content

fix(cli): prevent monitor notifications after task_stop - #7573

Merged
yiliang114 merged 1 commit into
QwenLM:mainfrom
yiliang114:cx/fix-7566-monitor-cancel-notification
Jul 23, 2026
Merged

fix(cli): prevent monitor notifications after task_stop#7573
yiliang114 merged 1 commit into
QwenLM:mainfrom
yiliang114:cx/fix-7566-monitor-cancel-notification

Conversation

@yiliang114

Copy link
Copy Markdown
Collaborator

What this PR does

Explicit monitor cancellation now uses the existing silent cancellation path because the synchronous tool result already confirms the action. Session notification queues also retain monitor identity long enough to discard a queued running event when that monitor has since been explicitly cancelled. Natural completion and failure notifications remain unchanged.

Why it's needed

Stopping a monitor could emit a cancelled notification and drain an already queued running event after the original tool turn. Both were recorded as notification user messages and could wake the model again, polluting the conversation and consuming another full-history request.

Reviewer Test Plan

How to verify

  1. In one-shot stream-json mode, ask the model to start a monitor that repeatedly prints a line, immediately stop the returned monitor task, return STOPPED, and return NOTIFICATION_ACK only if a later task notification arrives.
  2. Confirm the model calls both monitor and task stop, returns STOPPED, emits no notification user envelope or monitor task-notification after cancellation, and never returns NOTIFICATION_ACK.
  3. Confirm a naturally completed or failed monitor still reaches the existing notification path.

Evidence (Before & After)

Before: the real reproduction recorded a notification user message after cancellation and made an extra model request with 17,395 input tokens, followed by NOTIFICATION_ACK.

After: a real qwen3.6-max-preview run called monitor once and task stop once, then returned only STOPPED. Its 16-line JSONL contained zero notification user records and zero NOTIFICATION_ACK responses, and the monitored process was absent after exit. Final verification session: 41558468-2323-4df8-a3a9-f98dba1b1279.

Automated verification: full lint and typecheck passed; 299 targeted tests passed with one pre-existing skip; the full repository build passed.

Tested on

OS Status
🍏 macOS
🪟 Windows ⚠️
🐧 Linux ⚠️

Environment (optional)

Local development entrypoint in one-shot stream-json mode, safe mode enabled, approval mode yolo, no sandbox, real qwen3.6-max-preview model through an OpenAI-compatible endpoint.

Risk & Scope

  • Main risk or tradeoff: queued running events are discarded only when the current registry state is explicitly cancelled, so events that race with natural completion or failure remain deliverable.
  • Not validated / out of scope: real interactive TUI behavior and Windows/Linux runtime behavior; those paths are covered by focused unit tests or CI.
  • Breaking changes / migration notes: none.

Linked Issues

Resolves #7566

中文说明

本 PR 做了什么

显式取消 monitor 时改用已有的静默取消路径,因为同步工具结果已经确认了取消动作。会话通知队列也会保留 monitor 标识,以便在消费前发现该 monitor 已被显式取消时,丢弃此前排队的 running 事件。自然完成和失败通知保持不变。

为什么需要

停止 monitor 后,系统可能同时发送 cancelled 通知,并在原始工具回合结束后继续消费一个已经排队的 running 事件。两者都会被记录为 notification 用户消息并再次唤醒模型,污染对话记录并额外消耗一次完整历史请求。

Reviewer Test Plan

如何验证

  1. 在 one-shot stream-json 模式下,让模型启动一个持续输出文本行的 monitor,立即停止返回的 monitor 任务,然后返回 STOPPED;仅当稍后收到任务通知时才返回 NOTIFICATION_ACK
  2. 确认模型实际调用 monitor 和 task stop,返回 STOPPED,取消后不输出 notification 用户 envelope 或 monitor task-notification,也不返回 NOTIFICATION_ACK
  3. 确认自然完成或失败的 monitor 仍会进入现有通知路径。

Before & After 证据

修复前:真实复现会在取消后记录一条 notification 用户消息,并额外发起一次包含 17,395 个输入 token 的模型请求,随后返回 NOTIFICATION_ACK

修复后:真实 qwen3.6-max-preview 调用分别执行了一次 monitor 和 task stop,最终只返回 STOPPED。对应 16 行 JSONL 中 notification 用户记录为 0,NOTIFICATION_ACK 为 0,退出后没有残留的 monitor 进程。最终验证会话:41558468-2323-4df8-a3a9-f98dba1b1279

自动化验证:全仓 lint 和 typecheck 通过;299 个定向测试通过,另有 1 个既有 skip;全仓 build 通过。

测试平台

OS Status
🍏 macOS
🪟 Windows ⚠️
🐧 Linux ⚠️

环境(可选)

本地开发入口,one-shot stream-json 模式,启用 safe mode,approval mode 为 yolo,未启用 sandbox,通过 OpenAI-compatible endpoint 真实调用 qwen3.6-max-preview

风险与范围

  • 主要风险或取舍:仅当 registry 当前状态明确为 cancelled 时才丢弃已排队的 running 事件,因此与自然完成或失败竞态的事件仍可正常投递。
  • 未验证 / 范围外:真实交互式 TUI 行为以及 Windows/Linux 运行时行为;相关路径由定向单测或 CI 覆盖。
  • 破坏性变更 / 迁移说明:无。

关联 Issue

Resolves #7566

@yiliang114

Copy link
Copy Markdown
Collaborator Author

E2E Test Report

  • Branch / commit: cx/fix-7566-monitor-cancel-notification / f081baebe3
  • Entrypoint: local scripts/dev.js, one-shot stream-json mode
  • Model: real qwen3.6-max-preview through the configured OpenAI-compatible endpoint; model and tool protocol were not mocked
  • Scenario: start a monitor running while true; do echo ready; sleep 1; done, immediately stop the returned monitor ID with task_stop, return STOPPED, and return NOTIFICATION_ACK only if a later task notification arrives
  • Expected final state: one monitor call, one task-stop call, STOPPED, no notification user record, no acknowledgement turn, and no remaining monitor process

Baseline failure

The pre-fix real reproduction recorded the cancelled/running monitor notification as a notification user message, made an extra model request with 17,395 input tokens, and returned NOTIFICATION_ACK.

Fixed result

Final session: 41558468-2323-4df8-a3a9-f98dba1b1279

monitor     mon_cc7f4b1d75544b78   success
task_stop  mon_cc7f4b1d75544b78   success
assistant                            STOPPED
result                               success
{
  "lines": 16,
  "notification_users": 0,
  "api_responses": 4,
  "monitor_calls": 1,
  "task_stop_calls": 1,
  "stopped_texts": 1,
  "notification_acks": 0
}

The process table contained no matching monitor command after the CLI exited.

Verdict: PASS

@qwen-code-ci-bot

Copy link
Copy Markdown
Collaborator

Thanks for the PR!

Template looks good ✓

Problem: observed bug with solid evidence — issue #7566 includes reproduction steps, a real model call consuming 17,395 input tokens on the stale notification turn, and example notification XML. Clearly not theoretical.

Direction: aligned. After an explicit task_stop, the synchronous tool result already confirms cancellation; emitting a separate notification turn is redundant and wasteful. The fix correctly suppresses the terminal notification at the source and filters stale queued running events at drain time across all three client paths (interactive, persistent stream-json, one-shot headless).

Size: core path packages/core/src/tools/task-stop.ts touched — 2 production lines (1 add + 1 del). Total production: ~50 lines across 4 source files; test: ~197 lines; docs: 39 lines. Well within bounds.

Approach: scope feels right — every edit serves the stated goal. The { notify: false } option already exists in the monitor registry and is well-tested; reusing it here is the minimal path. The drain-time filter is the correct complement for the race between queue and cancel. No drive-by changes or scope creep.

Moving on to code review. 🔍

中文说明

感谢贡献!

模板完整 ✓

问题:已观测到的 bug,证据充分——issue #7566 包含复现步骤、真实模型调用消耗 17,395 个输入 token 的额外通知回合,以及示例通知 XML。明确不是理论性问题。

方向:对齐。显式 task_stop 后,同步工具结果已确认取消;再发一个通知回合是冗余且浪费的。修复正确地在源头抑制了终态通知,并在三个客户端路径(交互式、持久 stream-json、一次性 headless)的消费时过滤了过期的排队 running 事件。

规模:核心路径 packages/core/src/tools/task-stop.ts 被触及——2 行生产代码(1 增 + 1 删)。总生产代码约 50 行(4 个源文件);测试约 197 行;文档 39 行。在合理范围内。

方案:范围合理——每处改动都服务于既定目标。{ notify: false } 选项在 monitor registry 中已存在且经过充分测试;在此复用是最小路径。消费时过滤是处理排队与取消之间竞态的正确补充。无顺手改动或范围蔓延。

进入代码审查 🔍

Qwen Code · qwen3.8-max-preview

Reviewed at f081baebe31005d49e884ff02ccf206b2ef089fe · re-run with @qwen-code /triage

@qwen-code-ci-bot

Copy link
Copy Markdown
Collaborator

Code Review

Clean implementation. The approach is exactly what I'd propose independently: suppress the terminal notification at the source (task_stopcancel(id, { notify: false })), and filter stale queued running events at drain time in each client path.

The { notify: false } option already exists in monitorRegistry.cancel() and is well-tested — reusing it here is the minimal change. The drain-time filter is the correct complement for the race between a queued running event and explicit cancellation.

All three client paths are covered consistently:

  • Interactive (useGeminiStream.ts): backwards iteration to splice cancelled events from the notification queue before drain
  • Persistent stream-json (session.ts): filter at the top of processMonitorNotificationBatch
  • One-shot headless (nonInteractiveCli.ts): isCancelledMonitorEvent helper applied at both drain points

The config addition to the useGeminiStream effect dependency array is correct — the effect now reads config.getMonitorRegistry().

No critical blockers. No convention violations. Tests are collocated and cover the new behavior in all three paths plus the core task_stop change.

Real-Scenario Testing

One-shot stream-json mode, real qwen3.8-max-preview model, same prompt for both runs: start a monitor printing "tick" every 2s, immediately task_stop it, respond STOPPED, respond NOTIFICATION_ACK only if a notification arrives later.

Before (installed qwen v0.20.0)

$ qwen -p '<prompt>' --output-format stream-json --yolo

{"type":"system","subtype":"task_notification",...,"data":{"task_id":"mon_2e1a98d1f1414be3",...,"status":"running"}}
{"type":"system","subtype":"task_notification",...,"data":{"task_id":"mon_2e1a98d1f1414be3",...,"status":"running"}}
{"type":"system","subtype":"task_notification",...,"data":{"task_id":"mon_2e1a98d1f1414be3",...,"status":"cancelled"}}
{"type":"assistant",...,"content":[{"type":"text","text":"NOTIFICATION_ACK"}],...}
{"type":"result","subtype":"success",...,"num_turns":5,"result":"NOTIFICATION_ACK","usage":{"input_tokens":130306,...}}

Bug reproduced: 2 stale running notifications + 1 cancelled notification triggered an extra model turn → NOTIFICATION_ACK, 5 turns, 130,306 input tokens.

After (this PR via npm run dev)

$ npm run dev -- -p '<prompt>' --output-format stream-json --yolo

{"type":"assistant",...,"content":[{"type":"text","text":"STOPPED"}],...}
{"type":"result","subtype":"success",...,"num_turns":4,"result":"STOPPED","usage":{"input_tokens":100260,...}}

Fixed: zero notification records, zero NOTIFICATION_ACK, model returned only STOPPED. 4 turns, 100,260 input tokens (~30K saved).

Unit Tests

Test file Result
packages/core/src/tools/task-stop.test.ts 14 passed
packages/cli/src/nonInteractive/session.test.ts 38 passed
packages/cli/src/nonInteractiveCli.test.ts 87 passed, 1 skipped (pre-existing)
packages/cli/src/ui/hooks/useGeminiStream.test.tsx 160 passed

Typecheck: both packages/core and packages/cli pass tsc --noEmit.

中文说明

代码审查

实现干净。方案与我独立提出的完全一致:在源头抑制终态通知(task_stopcancel(id, { notify: false })),并在各客户端路径的消费时过滤过期的排队 running 事件。

{ notify: false } 选项在 monitorRegistry.cancel() 中已存在且经过充分测试——在此复用是最小改动。消费时过滤是处理排队 running 事件与显式取消之间竞态的正确补充。

三个客户端路径均一致覆盖:

  • 交互式useGeminiStream.ts):反向迭代从通知队列中移除已取消的事件
  • 持久 stream-jsonsession.ts):在 processMonitorNotificationBatch 顶部过滤
  • 一次性 headlessnonInteractiveCli.ts):isCancelledMonitorEvent 辅助函数应用于两个消费点

useGeminiStream effect 依赖数组中添加 config 是正确的——effect 现在读取 config.getMonitorRegistry()

无关键阻塞项。无规范违反。测试与源码同目录,覆盖了三个路径和核心 task_stop 改动。

真实场景测试

One-shot stream-json 模式,真实 qwen3.8-max-preview 模型,两次运行使用相同提示:启动一个每 2 秒打印 "tick" 的 monitor,立即用 task_stop 停止,回复 STOPPED,仅在收到通知时回复 NOTIFICATION_ACK

修复前(v0.20.0):2 条过期 running 通知 + 1 条 cancelled 通知触发了额外模型回合 → NOTIFICATION_ACK,5 个回合,130,306 个输入 token。

修复后(本 PR):零通知记录,零 NOTIFICATION_ACK,模型仅返回 STOPPED。4 个回合,100,260 个输入 token(节省约 30K)。

单元测试全部通过(299 个测试,1 个既有 skip)。Typecheck 通过。

Qwen Code · qwen3.8-max-preview

Reviewed at f081baebe31005d49e884ff02ccf206b2ef089fe · re-run with @qwen-code /triage

@qwen-code-ci-bot

Copy link
Copy Markdown
Collaborator

Confidence: 5/5 — clean fix for a real, reproduced bug; minimal change, comprehensive tests, clear before/after evidence.

This is a textbook bug fix. The problem is real and well-documented in #7566 — stale monitor notifications triggering unnecessary model turns after explicit task_stop, consuming tokens and polluting the conversation. The fix is exactly what I'd propose: suppress the terminal notification at the source (the tool result already confirms cancellation), and filter stale queued running events at drain time. Every edit in the diff serves the stated goal — no drive-by changes, no over-engineering.

The before/after run confirms it works: the installed build (v0.20.0) produced NOTIFICATION_ACK across 5 turns and 130K input tokens; the PR code produces only STOPPED across 4 turns and 100K tokens. All 299 targeted tests pass, typecheck is clean.

If I had to maintain this in six months, I'd thank the author — the design doc explains the rationale, the tests cover all three client paths, and the change is small enough to reason about at a glance.

中文说明

置信度:5/5 — 针对真实已复现 bug 的干净修复;最小改动,全面测试,清晰的 before/after 证据。

这是一个教科书式的 bug 修复。问题真实且在 #7566 中有详细记录——过期的 monitor 通知在显式 task_stop 后触发不必要的模型回合,消耗 token 并污染对话。修复方案与我独立提出的完全一致:在源头抑制终态通知(工具结果已确认取消),并在消费时过滤过期的排队 running 事件。diff 中每处改动都服务于既定目标——无顺手改动,无过度工程。

Before/after 运行确认修复有效:安装版本(v0.20.0)产生 NOTIFICATION_ACK,5 个回合,130K 输入 token;PR 代码仅产生 STOPPED,4 个回合,100K token。全部 299 个定向测试通过,typecheck 干净。

如果六个月后维护这段代码,我会感谢作者——设计文档解释了原理,测试覆盖了三个客户端路径,改动小到可以一目了然地推理。

Qwen Code · qwen3.8-max-preview

Reviewed at f081baebe31005d49e884ff02ccf206b2ef089fe · re-run with @qwen-code /triage

@qwen-code-ci-bot qwen-code-ci-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, looks ready to ship. ✅

@wenshao

wenshao commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Maintainer E2E Verification Report

Verified locally on macOS (darwin arm64) using a git worktree build of this PR branch (f081baeb), with a real model call through an OpenAI-compatible endpoint.

Test Setup

  • Build: npm install && npm run build && npm run bundle — all passed
  • Mode: one-shot stream-json, --safe-mode, --approval-mode yolo, no sandbox
  • Model: qwen3.8-max-preview via OpenAI-compatible API
  • Prompt: Start a monitor (while true; do echo tick-7573; sleep 60; done), immediately task_stop it, reply STOPPED; reply NOTIFICATION_ACK only if a later notification arrives.

E2E Result: ✅ PASS

The model executed exactly 4 turns: tool_searchmonitortask_stop"STOPPED".

Check Expected Actual Status
Notification user envelopes after cancel 0 0
task_notification system messages 0 0
NOTIFICATION_ACK in responses 0 0
Monitor tool calls 1 1
task_stop tool calls 1 1
Residual monitor processes 0 0
Final result STOPPED STOPPED
Total JSONL lines 14
Total tokens 71,116
Duration 14.3s

E2E Flow

E2E Flow

Verification Summary

Verification Results

Raw JSONL Output

JSONL Output

Unit Tests (all 4 changed test files)

Test file Result
packages/core/src/tools/task-stop.test.ts 14 passed ✅
packages/cli/src/nonInteractive/session.test.ts 38 passed ✅
packages/cli/src/nonInteractiveCli.test.ts 87 passed, 1 skipped (pre-existing) ✅
packages/cli/src/ui/hooks/useGeminiStream.test.tsx 160 passed ✅
Total 299 passed

Conclusion

The fix works as designed: task_stop cancels the monitor silently ({ notify: false }), and all three notification drain paths (interactive useGeminiStream, persistent session.ts, one-shot nonInteractiveCli.ts) correctly discard queued running events for explicitly cancelled monitors. No spurious notification turn, no extra model request, no residual process.

Evidence artifacts: wenshao/qwen-code@evidence/pr-7573-e2e

中文验证报告

维护者 E2E 验证报告

在 macOS (darwin arm64) 本地使用 git worktree 构建本 PR 分支 (f081baeb),通过 OpenAI-compatible endpoint 进行真实模型调用验证。

测试环境

  • 构建: npm install && npm run build && npm run bundle — 全部通过
  • 模式: one-shot stream-json--safe-mode--approval-mode yolo,无 sandbox
  • 模型: qwen3.8-max-preview,通过 OpenAI-compatible API
  • 提示词: 启动 monitor(while true; do echo tick-7573; sleep 60; done),立即 task_stop 停止,回复 STOPPED;仅在收到后续通知时回复 NOTIFICATION_ACK

E2E 结果: ✅ 通过

模型精确执行 4 个 turn:tool_searchmonitortask_stop"STOPPED"

检查项 预期 实际 状态
取消后通知 user envelope 0 0
task_notification 系统消息 0 0
响应中 NOTIFICATION_ACK 0 0
Monitor 工具调用 1 1
task_stop 工具调用 1 1
残留 monitor 进程 0 0
最终结果 STOPPED STOPPED
JSONL 总行数 14
总 token 数 71,116
耗时 14.3s

单元测试(4 个变更测试文件全部通过)

测试文件 结果
task-stop.test.ts 14 通过 ✅
session.test.ts 38 通过 ✅
nonInteractiveCli.test.ts 87 通过,1 跳过(既有)✅
useGeminiStream.test.tsx 160 通过 ✅
合计 299 通过

结论

修复按设计工作:task_stop 静默取消 monitor({ notify: false }),三条通知消费路径(交互式 useGeminiStream、持久化 session.ts、一次性 nonInteractiveCli.ts)均正确丢弃已显式取消 monitor 的排队 running 事件。无多余通知 turn、无额外模型请求、无残留进程。

证据文件:wenshao/qwen-code@evidence/pr-7573-e2e

@yiliang114
yiliang114 added this pull request to the merge queue Jul 23, 2026
Merged via the queue into QwenLM:main with commit b7b5ed0 Jul 23, 2026
56 checks passed
@wenshao

wenshao commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Maintainer Verification — Independent Re-run (load-bearing A/B)

Re-verified locally on macOS (darwin arm64) in an isolated detached worktree at the PR head f081baeb, running vitest against the real source (CLI vitest aliases @qwen-code/qwen-code-core → worktree source; the PR touches no package.json, so deps were symlinked from a base-aligned main checkout). This round complements the earlier real-model E2E report by adding a deterministic before/after proof that each fix path is load-bearing.

1. All 4 changed test files pass on the PR head — 299 passed, 1 pre-existing skip

Test file Package Result
packages/core/src/tools/task-stop.test.ts core 14 passed ✅
packages/cli/src/nonInteractive/session.test.ts cli · persistent stream-json 38 passed ✅
packages/cli/src/nonInteractiveCli.test.ts cli · one-shot headless 87 passed, 1 skipped (pre-existing) ✅
packages/cli/src/ui/hooks/useGeminiStream.test.tsx cli · interactive TUI 160 passed ✅
Total 299 passed / 1 skip / 0 failed

prettier --check clean on all 9 changed files.

Independent test run

2. Load-bearing A/B — every fix path is proven necessary

I reverted only the 4 changed source files to their merge-base (dc7427910) content, kept the PR's test files, and re-ran. Exactly 4 tests flip fail→pass — one per changed path — while every other test passes in both configurations, so the change is isolated, not incidental.

Changed source (fix) Discriminating test Base Head
task-stop.tscancel(id,{notify:false}) cancels a running monitor ✗ FAIL ✓ PASS
session.ts — drain-batch filter drops a queued running monitor event after cancellation ✗ FAIL ✓ PASS
nonInteractiveCli.tsisCancelledMonitorEvent drops a queued running monitor event after cancellation ✗ FAIL ✓ PASS
useGeminiStream.ts — queue splice guard drops a queued running monitor event after cancellation ✗ FAIL ✓ PASS

On base, the one-shot headless failure is the bug itself: the queued running event is not dropped, so runNonInteractive drains it and starts a second model turn (surfaced as TypeError: reading Symbol.asyncIterator on the un-mocked 2nd stream) — precisely the extra request described in #7566.

Load-bearing A/B

3. Mechanism reads correctly — no over-suppression

  • Core (monitorRegistry.ts:300-306): task_stop now calls cancel(taskId, { notify: false }), which settles to cancelled, sets notified = true, aborts, and wakes the owner — without emitTerminalNotification(). The default (non-task_stop) branch still aborts-then-notifies, so terminal cancelled notifications from other callers are preserved. notify:false is a pre-existing capability (owner-agent teardown), reused here.
  • All 3 client guards drop a queued event only when status === 'running' and the registry entry is now cancelled. Natural completed/failed events (status !== 'running') and running events of still-running monitors always pass through — matching the PR's stated risk scope.

Conclusion — ✅ merge-ready

The fix is correct, minimal, and every path is load-bearing and regression-guarded. Combined with the earlier real-model E2E (no notification turn after task_stop, session 41558468…), I'm satisfied this resolves #7566. LGTM.

Evidence hosted at QwenLM/qwen-code@pr-assets/pr-7573-verify. Verified head: f081baebe31005d49e884ff02ccf206b2ef089fe.

中文验证报告

维护者验证 — 独立复跑(load-bearing A/B)

在 macOS (darwin arm64) 本地,于独立的 detached worktree(PR head f081baeb)中,针对真实源码运行 vitest(CLI vitest 将 @qwen-code/qwen-code-core 别名指向 worktree 源码;本 PR 未改动任何 package.json,故从与 base 对齐的 main checkout 软链 node_modules)。本轮在此前真实模型 E2E 报告的基础上,补充一份确定性的 before/after 证据,证明每条修复路径都是必要的(load-bearing)

1. 4 个变更测试文件在 PR head 全部通过 — 299 通过,1 个既有 skip

测试文件 结果
task-stop.test.ts core 14 通过 ✅
session.test.ts cli · 持久化 stream-json 38 通过 ✅
nonInteractiveCli.test.ts cli · 一次性 headless 87 通过,1 跳过(既有)✅
useGeminiStream.test.tsx cli · 交互式 TUI 160 通过 ✅
合计 299 通过 / 1 跳过 / 0 失败

prettier --check 对全部 9 个变更文件均通过。

2. Load-bearing A/B — 每条修复路径都被证明是必要的

将 4 个变更 source 文件回退到 merge-base(dc7427910)内容,保留 PR 的 test 文件后复跑。恰好 4 个测试从失败翻转为通过——每条变更路径一个,而其余所有测试在两种配置下都通过,说明改动是精准隔离的,而非偶然。

变更 source(修复) 判别性测试 Base Head
task-stop.tscancel(id,{notify:false}) cancels a running monitor ✗ 失败 ✓ 通过
session.ts — drain-batch 过滤 drops a queued running monitor event after cancellation ✗ 失败 ✓ 通过
nonInteractiveCli.tsisCancelledMonitorEvent 同上 ✗ 失败 ✓ 通过
useGeminiStream.ts — 队列 splice 守卫 同上 ✗ 失败 ✓ 通过

base 上,一次性 headless 的失败正是该 bug 本身:排队的 running 事件没有被丢弃,于是 runNonInteractive 消费它并发起了第二次模型调用(表现为对未 mock 的第二个 stream 读取 Symbol.asyncIteratorTypeError)——正是 #7566 描述的额外请求。

3. 机制正确 — 不会过度抑制

  • Core(monitorRegistry.ts:300-306): task_stop 现在调用 cancel(taskId, { notify: false }),将状态 settle 为 cancelled、置 notified = true、abort 并唤醒 owner,但调用 emitTerminalNotification()。默认(非 task_stop)分支仍先 abort 再 notify,因此其它调用方的终态 cancelled 通知照常投递。notify:false 是既有能力(owner-agent teardown),此处复用。
  • 三条客户端守卫仅在 status === 'running' registry 条目当前为 cancelled 时才丢弃排队事件。自然的 completed/failedstatus !== 'running')以及仍在运行的 monitor 的 running 事件始终放行——与 PR 声明的风险范围一致。

结论 — ✅ 可合并

修复正确、最小化,每条路径都 load-bearing 且有回归保护。结合此前的真实模型 E2E(task_stop 后无通知 turn,会话 41558468…),确认本 PR 解决了 #7566。LGTM。

yiliang114 added a commit to he-yufeng/qwen-code that referenced this pull request Jul 23, 2026
)

* fix(cli): correct queued message display style and ordering

Mid-turn steer messages (user input queued while the model is
responding) had two display bugs:

1. They rendered with notification styling (● icon) instead of
   user-input styling (> prefix) because accept() added them to
   UI history as MessageType.NOTIFICATION.

2. They appeared below the model's reply because accept() was
   only called in the finally block after the entire response
   stream completed, appending the user message after all model
   response items.

Fix: use MessageType.USER with sentToModel: true for steer
messages, and settle the steer input on the first stream event
(after the user-content push lands but before model-response
events are committed to UI history). Pass steer inputs through
to recursive sendMessageStream calls so all takeSteerInput paths
benefit from early settlement. Add a WeakSet guard to
settleSteerInput for idempotency across recursive invocations.

* test(core): add ordering test for early steer settlement

Verify that accept() is called after the first stream event is
pulled but before subsequent events reach the consumer, pinning
the settle-before-content timing that ensures queued user
messages render above the model's reply.

* fix(cli): use sentToModel: false for steer messages, address review

- Use sentToModel: false instead of true: steer messages are injected
  into an existing tool-result turn, not standalone user turns.
  sentToModel: true would make isRealUserTurn() count them as real
  turns, inflating the rewind turn index.
- Remove unnecessary as HistoryItemWithoutId cast.
- Add post-cleanup assertion in ordering test to verify the WeakSet
  guard prevents double-settlement.

* fix(cli): align resumed mid-turn steer display with live session (#7381)

Resume path now renders mid_turn_user_message as MessageType.USER with
sentToModel: false, matching the live-session styling. Add a comment
documenting the intentional sentToModel: false choice.

* fix(cli): exclude steer messages from user-turn filters (#7381)

Steer messages (sentToModel: false) were counted as real user turns by
five downstream consumers that filter on type === 'user' without checking
sentToModel, breaking cancel auto-restore, telemetry turn count, prompt
recall, away-recap thresholds, and resume collapse boundaries.

Add sentToModel !== false guards at each site.

* test(cli): add coverage for sentToModel !== false guards (#7381)

* test(cli): add coverage for sentToModel !== false guard in input-history filter (#7381)

* test(cli): add coverage for sentToModel !== false guard in YOLO turn-count telemetry (#7381)

* fix(cli): restore corrupted docs and classify steer items as synthetic (#7381)

* fix(docs): restore corrupted autogenerated input names in GitHub Action docs (#7381)

* fix(cli): deduplicate findLastUserItemIndex and add steerInput forwarding test (#7381)

* fix(cli): keep code-block copy numbering continuous across steer items (#7381)

* test(core): add Hook continuation steerInput forwarding test

Verify that steerInput is forwarded through the Stop-hook
continuation path and settled early on the first content event
of the continuation turn, matching the existing Steer
continuation coverage.

* fix(cli): sync selection test fixtures with ink FrameCell/ReadonlyFrame types (#7381)

* fix(core): align cron day wildcard semantics (#7464)

Co-authored-by: destire-mio <248462155+destire-mio@users.noreply.github.com>

* feat(core): keep completed background agents resident (#7426)

* feat(core): keep background agents resident

* fix(core): harden background continuation boundaries

* docs(core): move per-spawn cleanup comment to subagentDispose

The comment describing the per-spawn cleanup (which stays undefined on
the fork-resume path) had drifted above the launchModel declaration,
where it no longer applied and could mislead readers. Relocate it to the
subagentDispose assignment in the non-fork branch it actually documents.

* fix(core): close finishing window and release resident on error in background GOAL path

- Non-worktree GOAL completion drained the message queue but never called
  registry.beginFinishing(), unlike the worktree path. A send_message racing
  the terminal transition could be accepted (status still running,
  finishingAgents empty) and then orphaned by complete(). Call beginFinishing()
  after the empty drain to reject the racing message instead.
- The completion catch block never reset keepResident, so a throw from
  patchAgentMeta/registry.complete left the runtime resident but finalized as
  failed — a zombie that cleanupRuntime never reclaimed. Reset keepResident in
  the catch so the finally block disposes it.

---------

Co-authored-by: Claude <noreply@anthropic.com>

* ci(autofix): continue environment-specific fixes (#7444)

* ci(autofix): continue environment-specific fixes

* docs(autofix): align verification wording

* docs(autofix): require bundle before integration tests

* docs(autofix): scope surrogate verification rules

* docs(autofix): require focused tests before integration checks

* docs(autofix): clarify review verification guidance

* fix(acp-bridge): close prompt-terminal follow-ups from the PR #7400 self-review (#7453)

* fix(acp-bridge): close prompt-terminal follow-ups from PR #7400 self-review

Keep a removed RUNNING prompt visible to the teardown flush via a removed flag so its terminal still publishes when the session closes before the agent cooperates; gate broadcastTurnError's session turn-state mutation to running prompts; propagate the typed PromptDeadlineExceededError from the pre-dispatch abort check; document the deadline FIFO-release overlap trade-off, the trailing prompt_cancelled after flush, and the result.then/finally ordering invariant; route the dedup log to the debug channel; drop the prompt-deadline re-export that pulled the bridge into a leaf module.

Fixes #7451

* test(acp-bridge): cover promote-then-remove-then-settle duplicate completed guard (#7453)

---------

Co-authored-by: Qwen Code Bot <qwen-code-bot@users.noreply.github.com>

* fix(core): strip Qwen-internal daemon secrets from agent-spawned child env (#7256)

* fix(core): strip Qwen-internal daemon secrets from agent-spawned child env

Shell subprocesses (and the monitor tool and stdio MCP servers) inherited
the full daemon process.env, including QWEN_SERVER_TOKEN (the serve-daemon
bearer credential), so an agent-run command like printenv QWEN_SERVER_TOKEN
could read an internal secret. Add a shared sanitizeChildEnv() that removes
Qwen-internal daemon/server tokens (QWEN_SERVER_TOKEN, QWEN_DAEMON_TOKEN)
before spawning, and apply it at the shell child_process + PTY paths,
monitor.ts, and the mcp-client stdio transport.

The denylist is deliberately narrow: it does NOT strip third-party
credentials (GH_TOKEN, AWS_*, NPM_TOKEN, ...) that real shell workflows
legitimately inherit -- only Qwen-internal secrets. Exported from the
package root so the desktop denylists can consolidate onto it later.

Fixes #6601.

* test(core): cover daemon-secret stripping on monitor and mcp-client spawn sites

* test(core): replace process.env instead of mutating in shell sanitization tests

The file restores process.env by reference in afterEach, so in-place key
mutations leaked into later tests. Use the replacement pattern already used
by setupConflictingPathEnv.

* docs(core): align JSDoc @param names with actual function signatures (#7492)

Fix 6 instances where JSDoc @param tags had drifted from their
corresponding function signatures — parameters were renamed, removed,
or undocumented over time but the doc blocks were not updated.

Closes #7446

* feat(serve): support forced MCP reconnects (#7488)

* feat(serve): support forced MCP reconnects

* test(serve): cover forced MCP reconnect options

---------

Co-authored-by: 克竟 <dingbingzhi.dbz@alibaba-inc.com>

* fix(cli): insert newline on Shift+Enter and stop streaming thinking-block flicker (#7397)

* fix(cli): re-push Kitty keyboard flags onto the alternate screen in VP mode

In VP mode the app renders on the alternate screen (`alternateScreen: true`),
but the Kitty keyboard progressive-enhancement flags were pushed only once at
startup on the main screen. The Kitty spec tracks these flags per screen
buffer, so the alternate screen's stack stays empty and the terminal never
reports modifiers: Shift+Enter arrives as a bare Enter (submit) or, when the
terminal emits an ESC-prefixed variant, as an orphaned Escape that trips the
empty-buffer double-Esc rewind prompt — so Shift+Enter can never insert a
newline in VP mode even on Kitty-capable terminals (e.g. cmux).

Re-push the flags onto the alternate screen right after Ink enters it (Ink
writes the enter-alt-screen sequence synchronously inside render(), so the
push is correctly ordered). Ink discards the alternate screen and its flag
stack on unmount, leaving the startup main-screen push balanced by the
existing disableKittyProtocol() on cleanup.

Generated with AI

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): stabilize streaming thinking block height to stop flicker

The pending "Thinking…" block renders the tail of the reasoning stream in a
content-sized box. As the model emits paragraph separators, a blank line
enters and leaves the tail window (and `trimEnd` drops trailing blanks), so the
visible line count oscillates and the block flickers 2→3→5 rows during
streaming.

Track the tallest height the block has reached for the current thought and
never render fewer rows than that (capped at the streaming window size),
padding at the top so the newest line stays pinned to the bottom. The tracker
resets when streaming ends or when the buffer shrinks (a new thought replaced
it), so height is monotonic within a thought without leaking across thoughts.

Generated with AI

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): decode xterm modifyOtherKeys Shift/Ctrl/Alt+Enter so it inserts a newline

Terminals such as Ghostty report Shift+Enter as the xterm modifyOtherKeys
sequence `ESC [ 27 ; <mods> ; <key> ~` (e.g. `ESC [ 27 ; 2 ; 13 ~`) when the
Kitty keyboard protocol is not negotiated — which is the default, since Kitty
detection does not always succeed. Two bugs kept this from inserting a newline:

1. The CSI-u parser read the leading `27` marker as the key code (matching the
   Escape key code 27) instead of the real key code in the third parameter, so
   with Kitty enabled Shift+Enter was mistaken for Escape and tripped the
   double-Esc rewind prompt.
2. The reassembly path that stitches readline's shredded CSI fragments back
   together was gated behind `kittyProtocolEnabled`, so with Kitty disabled the
   `ESC [ 27 ; 2 ;` head plus the stray `13~` tail leaked into the composer as
   literal text and no newline was inserted.

Decode the third parameter as the real key code for the `27;…~` form, and route
those sequences through the reassembly buffer even when Kitty is off (only the
`ESC [ 27` marker opts in, so keys readline already parses cleanly are
untouched). Shift/Ctrl/Alt+Enter now insert a newline in both VP and non-VP
mode regardless of Kitty negotiation.

Generated with AI

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): anchor VP viewport to the top until a conversation turn exists

On a fresh VP-mode session the virtualized list holds the banner plus startup
notices (tips / MOTD / info), so it is longer than one item. Keying the initial
scroll anchor off list length alone selected scroll-to-end, which pinned the
banner to the bottom of the full-height viewport and left the top half of the
screen blank.

Anchor to the top until there is an actual conversation turn (a user/user_shell
history item or a pending response), then resume scroll-to-end so the latest
output stays in view. Startup notices no longer count as content that forces
bottom alignment.

Generated with AI

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): stabilize streaming thinking window against availableTerminalHeight drift

The grow-only streaming thinking window still flickered because its line cap was
derived from availableTerminalHeight. While a thought streams the terminal keeps
constrainHeight on, so availableTerminalHeight (and the derived maxLines) drifts
up and down as sibling pending content grows, and the grow-only clamp
`min(maxLines, …)` shrank the block whenever it dipped.

Use a constant window height (MAX_STREAMING_THINKING_VISUAL_LINES) for the
pending window instead. The window is only a few lines, so a fixed cap cannot
meaningfully overflow (VP scrolls anyway), and the height stays stable while
still growing monotonically within a thought.

Generated with AI

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* Revert "fix(cli): anchor VP viewport to the top until a conversation turn exists"

This reverts commit fbe86a9e159b75ea1f5b689cc327599c9dc91090.

* fix(cli): guard modifyOtherKeys detection against keypresses without a sequence

The modifyOtherKeys prefix check ran on every keypress, but some synthetic
keypresses (and the useKeypress test harness) emit a key with no `sequence`,
so `key.sequence.startsWith(...)` threw an unhandled rejection. Use optional
chaining so a missing sequence is simply not a modifyOtherKeys start.

Generated with AI

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* test(cli): mock pushKittyProtocolFlags in gemini.test.tsx kitty mock

The kittyProtocolDetector mock omitted the newly added pushKittyProtocolFlags
export. Add it so the mock stays in sync with the real module and a VP-mode
startup path exercised through this suite cannot hit an undefined call.

Generated with AI

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

---------

Co-authored-by: 秦奇 <gary.gq@alibaba-inc.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(web-shell): open singleton subagent details (#7495)

Co-authored-by: ytahdn <ytahdn@gmail.com>

* fix(web-shell): avoid redundant git status requests (#7496)

Co-authored-by: ytahdn <ytahdn@gmail.com>

* fix(agent): ignore empty working_dir placeholders (#7343)

* fix(agent): ignore empty working_dir placeholders

* test(agent): align empty working_dir expectations

* feat(prompts): allow overriding core identity via QWEN_SYSTEM_IDENTITY_MD (#7478)

* feat(prompts): update prompts.ts for QWEN_SYSTEM_IDENTITY_MD

* feat(prompts): update prompts.test.ts for QWEN_SYSTEM_IDENTITY_MD

* fix(prompts): address CR on QWEN_SYSTEM_IDENTITY_MD

Keep getDefaultCoreIdentitySentence private, fail loud on path
resolution errors, use trimEnd, and resolve identity only on the
default-prompt branch.

* test(prompts): align identity override tests with CR feedback

Sample default identity from live prompt, cover trimEnd trailing
whitespace, and assert homedir resolution failures throw.

---------

Co-authored-by: 易良 <1204183885@qq.com>

* fix(cli): yield to single-slot background agents (#7258)

Co-authored-by: hogeheer <267467744+hogeheer499-commits@users.noreply.github.com>

* docs(autofix): require evidenced pre-commit verification, not a bare "verified" (#7486)

* docs(autofix): require evidenced pre-commit verification, not a bare "verified"

The skill already said to run build/typecheck/lint/Vitest before
committing, but softly — and #7408 committed a fix with a TS error the
gate then rejected while its summary claimed "verified all 3 commits".
A self-assessment the gate contradicts wastes a whole round.

Strengthens the address-review contract from "run the checks" to:
- actually run them, do not assert them from reading the diff;
- if typecheck or a touched-package test fails, do NOT commit — treat
  the feedback as unresolved (failure.md);
- end address-summary.md with a `## Verification` section listing each
  command run and its result; a bare "verified" is not acceptable.

The framing is structural, not etiquette: the deterministic gate re-runs
the same commands and discards the round on any failure, so skipping them
only moves the rejection later. Pinned by a test so it cannot soften back.

This is the checkable half of "audit before committing" — the
undirected/reverse-audit-until-clean practice does not transfer to an
unsupervised agent (no verifiable stopping condition, and it worsens the
timeouts seen on large PRs), but "run the gate's own checks first and
show the evidence" does.

* fix(autofix): clarify Verification section precedes collapsed Chinese translation (#7486)

---------

Co-authored-by: wenshao <wenshao@example.com>
Co-authored-by: qwen-code-ci-bot <qwen-code-ci-bot@users.noreply.github.com>
Co-authored-by: Qwen Code Bot <qwen-code-bot@users.noreply.github.com>

* feat(autofix): stop a PR that fails to push for N rounds in a row (#7482)

* feat(autofix): stop a PR that fails to push for N rounds in a row

Under takeover the round cap is 100, which is right for a PR that needs
many PRODUCTIVE rounds. It is wrong for one that fails every round: #6723
ran 7 consecutive failed rounds (3 agent timeouts at 50 min, 4 gate
rejections whose fix broke tests) over 8 hours, heading for round 100,
because it is a 5700-line, 47-file, 5-day-old PR racing a fast-moving
main — every round re-resolves a conflict it cannot finish or that fails
the gate. Retrying at the same per-round budget will not converge; a
human has to rebase or split it.

Adds CONSECUTIVE_FAILURE_CAP (5), distinct from the total round cap. The
handoff step already runs only when a round did NOT push, so it counts
the unbroken run of prior failure markers — stopping at the first push
("Addressed the latest review feedback") or legitimate no-op ("no
changes needed"), either of which proves progress and resets the streak.
At the cap it forces the terminal round even under takeover, with a
handoff that names the real fix (rebase/split, then /retry). Cause-
agnostic: a timeout and a gate rejection both count.

* fix(autofix): address review feedback on consecutive-failure circuit breaker (#7482)

- Fix misleading comment: the walk is oldest-first (API order) with
  reset-on-success, not newest-first with early stop
- Prefer the already-fetched ic.json over a redundant gh api call,
  falling back to the API only when the file is missing
- Filter eval markers by re-arm window (win=) so pre-re-arm failures
  do not immediately re-terminate a re-armed PR
- Add test coverage for the MARK_ROUND == MAX_ROUNDS guard and for
  window-scoped streak counting

* fix(autofix): exempt transient model errors from consecutive-failure breaker (#7482)

---------

Co-authored-by: wenshao <wenshao@example.com>
Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>

* feat(core): restore background agent roster (#7459)

* feat(core): restore background agent roster

* fix(web-shell): add list_agents to TOOL_DISPLAY_NAMES

The new list_agents core wire tool was added to core's ToolNames but not
to the web-shell TOOL_DISPLAY_NAMES map, causing toolFormatting.drift.test.ts
to fail (expected ['list_agents'] to deeply equal []). Add the missing
'ListAgents' display-name entry so the browser panel shows a friendly name
instead of the raw wire name and the drift guard passes.

* fix(cli): reload old-session background agents on failed resume rollback

When /resume fails after core has swapped but before the UI swap, the catch
block rolls core back to the old session via startNewSession(oldSessionId).
However the forward path already called resetBackgroundStateForSessionSwitch,
which cleared the old session's in-memory background agents. The rollback did
not reload them, so list_agents returned empty for the old session (whose
sidecars are still on disk) until the next process start or successful resume.

Reload the old session's paused background agents after rolling core back, so
the restored roster matches on-disk state. Placed after startNewSession so the
loadPausedBackgroundAgents current-session guard is satisfied; best-effort via
.catch so it never blocks the rollback path.

* fix(web-shell): add zh translation for list_agents tool name

The toolFormatting test 'has a zh translation for every tool in the
display-name map' failed with expected ['list_agents'] to deeply equal []
because list_agents was added to TOOL_DISPLAY_NAMES without a matching
toolName.list_agents zh-CN entry. Add the translation to restore parity.

* fix(cli): resolve CI failures for background-agent roster restore

- Add toolDisplayName.ListAgents translations (en, zh, zh-TW, ca) so the
  new list_agents tool has a zh entry; fixes i18n/index.test.ts.
- Add loadPausedBackgroundAgents and consumePendingRecoveredAgentsNotice
  to the acpAgent worktree test config mock, which loadSession now calls
  via #restoreBackgroundAgentsOnResume; fixes acpAgent.worktree.test.ts.

* refactor(core): extract incompatible-isolation blocked reason to a const

Move the incompatible-isolation blocked-reason string out of an inline
literal into a module-level INCOMPATIBLE_ISOLATION_BLOCKED_REASON const,
matching its four sibling reasons so the text is discoverable by
constant-name grep and edited alongside the others.

* fix(core): preserve retained activity state on failed agent revive

Address review feedback on the background-agent roster restore:

- On a failed completed-agent revive, restore UI state with a non-empty
  guard instead of `??`. Because `restorePausedEntry` resets the paused
  entry's `recentActivities` to `[]`, the previous `failedEntry?.field ??
  completedEntry.field` kept that empty array and dropped the pre-revive
  snapshot (the UI Progress section rendered empty). Applied consistently
  to pendingMessages, recentActivities, and pendingApprovals.

Add regression coverage for previously untested paths:

- failed revive preserves pre-revive recentActivities
- terminal-agent cap admits only the newest MAX_RETAINED_TERMINAL_AGENTS
  completed sidecars on restore
- /resume rollback reloads the old session's background agents
- headless resume prepends the recovered-agents notice to the prompt

* test(cli): cover interrupted-turn continuation not consuming recovered-agents notice

Add ACP and headless regression tests asserting an interrupted-turn
continuation does not consume the one-shot recovered-agents notice
(the !isContinue / !continueInterrupted guards), so it is delivered on
the user's next ordinary prompt. Mirrors the existing slash-command
coverage.

---------

Co-authored-by: Claude <noreply@anthropic.com>

* feat(cli): support custom skill directories via settings (#7395)

* feat(cli): support custom skill directories via settings (#7394)

Add skills.directories setting that accepts an array of additional
directory paths to scan for skills (SKILL.md files). Paths support
~ expansion. Directories are scanned recursively at user level,
after the default ~/.qwen/skills/ directory.

Example settings.json:
{
  "skills": {
    "directories": ["~/.agent/skills", "~/.claude/skills"]
  }
}

Changes:
- settingsSchema.ts: add skills.directories array setting
- core Config: add customSkillDirs param and getCustomSkillDirs()
- SkillManager: append custom dirs to user-level skill base dirs
- CLI config: read skills.directories and pass to core Config

* fix(cli): regenerate settings schema for skills.directories (#7394)

* fix(core): address review feedback for custom skill directories (#7395)

- Use optional chaining for getCustomSkillDirs() to prevent TypeError
  on partial Config mocks (workspace-skill-management, workspace-skills-status)
- Reuse expandHomeDir utility instead of inline tilde expansion
- Fix inaccurate 'scanned recursively' wording to 'one level deep'
- Correct JSDoc: paths are raw, expansion happens in SkillManager
- Trim whitespace from custom dir entries in CLI layer
- Add tests for custom dir expansion, dedup, and partial config safety

* fix(core): address review feedback for custom skill directories (#7395)

* fix(core): address review feedback for custom skill directories (#7395)

* test(core): add relative path resolution test for custom skill dirs (#7395)

* fix(cli): add Array.isArray guard for skills.directories and safe mode test (#7395)

* fix(skills): address review feedback on custom skill directories (#7395)

- Add bare mode test for skills.directories guard
- Include resolved absolute path in relative directory warning
- Clarify that dedup applies to default user dirs, not bundled skills
- Regenerate settings schema

---------

Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
Co-authored-by: qwen-code-ci-bot <qwen-code-ci-bot@users.noreply.github.com>
Co-authored-by: Qwen Code Bot <qwen-code-bot@users.noreply.github.com>
Co-authored-by: Qwen Code Autofix <qwen-code-autofix@users.noreply.github.com>

* fix(core): add image modality support for qwen3.8-max and kimi-k3 models (#7491)

* fix(core): add image modality support for qwen3.8-max models

qwen3.8-max-preview supports image input but was falling through to the
catch-all text-only rule because no pattern matched it. This caused the
vision bridge to unnecessarily transcribe images via a secondary model
instead of sending them directly to the primary model.

* fix(core): also add image modality for kimi-k3

Kimi K3 officially supports image + video input but was falling through
to the catch-all text-only rule, same issue as qwen3.8-max.

* fix(dingtalk): preserve non-bot mention context (#7473)

* fix(dingtalk): preserve non-bot mention context

* test(dingtalk): cover plural mentions, staffId fallback, and edge cases (#7473)

---------

Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>

* fix(core): harden the usage salvage around session deletion (#7425)

Post-merge review follow-ups on #7391 (three findings):

- Salvage the archived transcript in the active-branch deletion too:
  when both copies co-exist (an interrupted archive) and the fresh
  active transcript carries no telemetry, the archived copy holds the
  session's usage history and was deleted unsalvaged. The dedup guard
  makes the extra call a no-op whenever the active copy already wrote.
- Enforce the "never blocks deletion" contract at the call site: a
  salvageUsageBestEffort wrapper catches and warns, so the guarantee is
  structural rather than an implementation detail of
  persistUsageBeforeTranscriptDeletion. The new failure-tolerance test
  (salvage rejects -> deletion still succeeds) fails without the
  wrapper — the bare await let the rejection escape through
  removeSessionFiles' rethrowing catch.
- Clear the salvage module mock in beforeEach so the wiring test's
  invocationCallOrder assertions can never read stale calls.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* fix(core): make fork subagents discoverable (#7460)

* test(core): cover Shell truncation without an artifact (#7470)

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(ci): autofix route checks existing labels on non-trigger label events (#7481)

* fix(ci): autofix route checks existing labels on non-trigger label events

When triage adds multiple labels in sequence, per-issue concurrency
cancels earlier runs. If the last label is not a trigger label
(e.g. scope/build-system), the surviving run skips the issue phase
even though the issue already has autofix/approved +
status/ready-for-agent.

Before ignoring a non-trigger label event, check ISSUE_LABELS_JSON
for both required labels. If present and the issue is open, proceed
with the issue phase. Trust was already established when the trigger
labels were applied (both require triage+ permission).

* fix(ci): require trusted sender for label fallback

* feat(cli): preserve semantic text when copying VP selections (#7286)

* docs(cli): define semantic copy fidelity scope

* docs(cli): address semantic frame review gaps

* docs(cli): preserve soft-wrap source separators

* feat(cli): preserve semantic selection copy

* fix(cli): address semantic copy review findings

* fix(cli): preserve clipped semantic boundaries

* fix(cli): limit separator carrier joiner to visible width in wrap metadata

The greedy /\s+/ match in wrapTextWithMetadata could capture more
source whitespace than the separator carrier row actually consumed
(e.g. a tab following a space), causing duplicated whitespace in
semantic copy. Limit the match to visibleLine.length characters and
add a mixed space/tab regression test.

---------

Co-authored-by: 秦奇 <gary.gq@alibaba-inc.com>

* test(core): stub the registry methods agent.ts actually calls (#7538)

The shared stubRegistry in agent.test.ts was missing six methods that
agent.ts reaches: bridgeApprovalEvents, getQueuedCount,
registerResidentAgent, restartCompletedAgent, unregisterResidentAgent and
waitForMessages.

That is not a benign omission. The background body wraps its work in a
try/catch that routes any throw into registry.fail(), so a missing method
never surfaces as 'not a function' — it silently converts a successful
run into a failed one. On the GOAL completion path
unregisterResidentAgent is called immediately before complete(), so the
TypeError replaced the completion entirely:

  registry.fail('fork-...', 'registry2.unregisterResidentAgent is not a
  function', ...)

That is what broke 'runs a non-interactive fork through the background
registry' on main. #7460 added the registry.complete assertion, which
exposed the incomplete stub — before it, nothing checked whether the
background body finished successfully and the TypeError was swallowed.

Stub all six with their real return shapes (unregisterResidentAgent
returns boolean, bridgeApprovalEvents returns the unsubscribe callback
agent.ts later invokes, waitForMessages resolves to a list) and assert
registry.fail was not called before asserting completion, so a future
gap reports the actual error instead of 'complete: 0 calls'.

* perf(startup): lazy-load Google GenAI SDK on first use (#7512)

* perf(startup): lazy-load Google GenAI SDK on first use

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* codex: address PR review feedback (#7512)

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* codex: address PR review feedback (#7512)

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

---------

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(vscode): use file picker image paths for vision input (#7493)

* fix(vscode): use image paths from file picker

* fix(vscode): keep image picker paths raw

* fix(vscode): resolve image picker paths on submit

* fix(vscode): send picked images as vision context

* fix(vscode): encode prompt image file URIs

* fix(vscode): address image path review comments

* test(vscode): cover image file reference edge cases

* fix(cli): open the actual serve fallback port (#7501)

* fix(cli): open actual serve fallback port

* test(cli): match serve URL to fallback listener

* docs(cli): clarify serve listen error handling

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>

* fix(ci): don't let one failing scenario sink the whole visual preview (#7511)

The web-shell visuals render runs every screenshot and flow in a single
`test:e2e:visuals`, and that step had no `continue-on-error`, while the compose
and upload steps had no `if: always()`. So one failing or timing-out scenario
failed the job, the artifact was never uploaded, and the publish workflow had
nothing to post — the entire preview vanished even when every other scenario
passed and its PNG was already on disk. A flow (a long multi-click sequence) is
the most fragile scenario kind, so the fragile one silently takes down the
deterministic screenshots. PR #7498 hit exactly this: 29 scenarios passed, one
new channel-management flow timed out, and the PR got no preview and no comment
at all.

Make the after-capture step `continue-on-error` so the passing captures survive
and the later steps still compose and upload them. The publish job only runs on
a `success` conclusion, so the job must stay green — but a masked failure must
not read as a clean preview. Ship the step's real `.outcome` (which
continue-on-error does NOT mask, unlike `.conclusion`) to the publisher as
`render-status.txt`, and have the comment builder use it: an empty preview whose
render failed says "one or more scenarios failed to render" and is explicitly
NOT the reassuring green check or the coverage-gap prompt (both imply the render
ran); a partial preview is labelled partial above the shots that did render. A
missing status file (older run) defaults to complete, so this only ever adds a
warning, never suppresses a real preview.

The failing scenario still needs fixing — it's now surfaced in the comment
rather than by silently deleting everyone else's preview.

Co-authored-by: wenshao <wenshao@example.com>

* feat(web-shell): add selective shadow DOM isolation (#7551)

Co-authored-by: 钉萁 <dingqi.jww@alibaba-inc.com>

* feat(web-shell): add renderChatHeader slot for custom session header (#7553)

* fix(cli): say review coverage gaps in the author's units, not chunk ids (#7550)

The posted review body rendered coverage disclosures with the run's own
bookkeeping as subjects: bare chunk ids, unsorted, one per subject. On a
run that certified nothing (PR #7268) the body enumerated all 49 chunk ids
across two sentences while opening with "Reviewed. Suggestions are
inline." — the opener certified the exact thing every following sentence
took back, and nothing on the PR page maps a chunk id to code.

Three changes, all render-time — the structural entries, the caps, the
caller-echo dedup and the stderr remediation still key on chunk ids, which
is where the id is the selector a reader can act on:

- Coverage now returns the plan's chunk→files table (DiffChunk.files was
  already in the plan JSON; the coverage type slice dropped it).
- compose-review renders chunk gaps through describeChunkGap: every
  planned chunk collapses to "the entire diff", a narrow gap with known
  files names the files, and anything wider is counted against the plan's
  total. Applied to the receipt sentence, the uncoverable sentence (bare
  CLI entries only — caller-authored entries render verbatim) and the
  grouped per-cause sentences.
- The COMMENT opener may no longer say "Reviewed." over a disclosure set
  that denies it: when no chunk is both covered and undisclosed — or no
  chunk universe could be read at all — it opens with a zero-certified
  warning instead. A rewritten launch demonstrably read its chunk, so
  coverage alone is not the test; certified is covered with no disclosure
  against it.

Co-authored-by: verify <verify@local>

* fix(autofix): retry a skipped-Prepare instead of stranding the PR terminal (#7490)

* fix(autofix): retry a skipped-Prepare instead of stranding the PR terminal

A base/infra failure BEFORE the agent runs was misread as an agent crash
and terminated the PR forever. When an early step fails — installing or
building the trusted base, checkout, node setup — the `Prepare branch and
feedback` step is skipped, so NEWEST is empty, and the report step's
"crashed before reading feedback" branch fired: MARK_ROUND=MAX_ROUNDS,
terminal, scan skips it on every future tick.

Observed: a web-shell TypeScript break on `main` failed `Install
dependencies and build` (which builds the trusted base) across a whole
scan batch, and SIX healthy PRs were stranded terminal at round=100 in
one run — including ones at round 9 and 11 that had nothing to do with
the break. `round=100` there is a terminal sentinel, not 100 attempts.

NEWEST-empty now splits on steps.prepare.outcome:
- 'skipped' (an earlier step failed, the agent never ran) is infra/base
  and transient: retry with a sentinel ts so the feedback stays live,
  incrementing the round so a PERSISTENTLY broken base is still bounded
  and stops at the cap (recoverable with /retry).
- 'success'/'failure' (Prepare ran, no feedback produced) is a genuine
  pre-read agent crash: unchanged terminal behaviour.

This is the reverse of the asymmetry #7482 addresses: that bounds a
crash AFTER reading that retried forever; this stops a transient failure
BEFORE reading from going terminal after one.

* docs(autofix): note a pre-Prepare cancel also retries intentionally (#7490)

* fix(autofix): also retry a cancelled/empty prepare outcome, not just skipped

A previous review comment on this PR noted that a job cancelled before
Prepare should retry too. It was right about the intent but the code did
not do it: `steps.prepare.outcome` is 'cancelled' for a cancel and '' for
a job that stopped before Prepare entered the step context — both DISTINCT
from 'skipped', so `== 'skipped'` sent them to the terminal branch, the
same over-termination this PR exists to fix.

Match on "not a real Prepare run" (`!= 'success' && != 'failure'`)
instead, so skipped, cancelled, and empty all retry; only a Prepare that
actually ran to a verdict (success/failure) with no feedback stays
terminal — the genuine pre-read agent crash. Test extended to drive the
cancelled and empty cases (retry) and both real-run outcomes (terminal);
mutation-verified that reverting to `== 'skipped'` reddens the cancelled
case.

* test(autofix): update the pre-read-crash case for the broadened retry

The prior commit broadened NEWEST-empty retry to skipped/cancelled/empty
but left the older 'replays the handoff decision' test asserting the old
terminal behaviour for an unset PREPARE_OUTCOME (which now retries). That
test's terminal cases now set PREPARE_OUTCOME=success/failure explicitly —
the only outcomes that still terminate — so it exercises the genuine
pre-read agent crash rather than the infra/cancel path.

* test(autofix): anchor the skipped-Prepare extraction past the CONSEC block

CI reddened `retries a skipped-Prepare` after main's consecutive-failure
cap (#7482) merged into this branch: that block was inserted between this
decision block and the report `{`, and it calls `gh api`. The test's
`{`-anchored regex over-captured through it, so the extracted script ran
the unstubbed `gh api` and failed. Anchor the end on the same
`# Consecutive-failure` comment the sibling gate-crash test already uses,
so the extraction stops at this decision block's own closing `fi`.

* fix(autofix): exempt skipped-Prepare from the consecutive-failure breaker

A broken base build skips Prepare, producing no API error file — so the
consecutive-failure breaker ran on the new retry path and, after 5
scans, re-introduced the exact mass-stranding this PR exists to prevent.
Exempt pre-agent infra failures (skipped/cancelled/empty outcome) from
the breaker, mirroring the transient 429/5xx exemption: same failure
class (not the PR's fault, self-heals, hits the whole batch). The round
cap + sentinel-ts /retry recovery already bounds a persistently broken
base.

Also trim "checkout" from the retry headlines (checkout failures do not
land in this branch) and hoist the duplicated MARK_TS assignment.

* fix(autofix): reset the consecutive-failure streak on prior infra-failure markers

The streak walker counted prior infra-failure headlines ("AutoFix could
not start —…") as failures, inflating the consecutive-failure count on
subsequent rounds.  A PR with 3 real agent failures, then 3 rounds of
base-build infra failures, then 1 more real failure would trip the
cap-5 breaker even though only 4 rounds were the PR's fault.

Add the two infra-failure headline patterns as reset strings in the
streak walker, alongside the existing push and no-op resets.  The
genuine agent-crash headline ("AutoFix could not start evaluation —…")
is deliberately excluded — it is a real failure and must still count.

* fix(autofix): clarify infra-failure headlines and else-branch comment (#7490)

Address review nits: the retry headline now mentions cancelled runs,
the cap headline says 'reached the round cap' instead of overstating
'could not start for N rounds', the else-branch comment says 'prepare
itself crashed' instead of 'agent crash', and the streak-reset pattern
is simplified now that both infra headlines share the same prefix.

---------

Co-authored-by: wenshao <wenshao@example.com>
Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
Co-authored-by: qwen-code-ci-bot <qwen-code-ci-bot@users.noreply.github.com>

* fix(cli): keep role codenames and brief paths out of the posted review body (#7560)

The posted body still carried two operator registers #7550 left in place:
roster role subjects rendered their internal codenames ("Agent 1c:
Cross-file tracer", "Test coverage matrix (whole-diff)"), and an unread
brief's disclosure interpolated its filesystem path. And when verify and
the reverse audit failed the same way, the body said it twice, in two
near-identical sentences.

- Every Brief now carries a publicLabel — the dimension said as what it
  checks ("the cross-file consistency pass") — and coverage's structural
  disclosures carry it as publicSubject beside the internal subject, plus
  a path-free publicReason for unread briefs. The internal label and the
  path stay on stderr, where they are the selector an operator acts on;
  every dedup and certification check still keys on the internal subject.
- compose-review renders the public fields and groups by the reason the
  body PRINTS, so two unread briefs share one path-free sentence instead
  of repeating it per role.
- verificationGaps merges verify and reverse-audit failures of the same
  delivery shape into one sentence with both subjects and both
  consequences; mixed shapes keep their precise per-role texts, and the
  per-role rebuild commands stay on stderr either way.

Co-authored-by: verify <verify@local>

* fix(autofix): retry an agent timeout instead of advancing past its feedback (#7563)

A timeout evaluated NOTHING — the agent ran out of budget before finishing,
so nothing was committed and the feedback is unaddressed. It was treated as
an evaluated verdict (real ts, watermark advances), which strands that
feedback: the next scan sees "nothing new" and never retries. Observed on
#7471 (round 13/100), a heavily-reviewed 1871-line PR: rounds 11 and 13
timed out, but round 12 pushed — so a timeout is transient far more often
than not, and advancing past it left the round-13 feedback unhandled.

run-agent.mjs now drops an `agent-timeout` signal on result.timedOut, and
the handoff routes it like a pre-verdict crash: sentinel ts (feedback stays
live) and a retry, with a headline that names the real fix at the cap
(split the PR or raise the budget). A PR that PERSISTENTLY times out is
bounded by the round cap and the consecutive-failure cap, so this cannot
loop forever — it just stops treating a one-off budget blip as a verdict.

The loop guard stays terminal (a tool-call loop is a real defect, not a
budget blip). An API error still routes to its own model-key handoff; the
timeout signal is written only when NOT an API error.

Co-authored-by: wenshao <wenshao@example.com>

* feat(serve): add workspace-level generation (#7552)

* feat(serve): add workspace-level generation

* docs(serve): document workspace generation capability

* fix(serve): align workspace generation contracts

---------

Co-authored-by: ytahdn <ytahdn@gmail.com>

* ci: matrix ECS runner update + sudo install + repository_dispatch trigger (#7513)

* ci: matrix ECS runner update with sudo install

- Use matrix strategy (ecs-update-sg, ecs-update-64c) to update both
  physical ECS hosts in parallel (fail-fast: false).
- Always use sudo npm install -g so the package lands in /usr/local
  (system-wide PATH) instead of the runner user's home directory.
- Move concurrency to job level (matrix context not available at
  workflow level per actionlint).
- Add repository_dispatch trigger for release-driven updates.
- Register new runner labels in actionlint.yaml.

* fix(ci): use dispatch version for runner update

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>

* fix(web-shell): include managed id in artifact open requests (#7570)

Co-authored-by: 钉萁 <dingqi.jww@alibaba-inc.com>

* feat(serve): persist workspace channel configuration (#7514)

* feat(serve): persist workspace channel configuration

* fix(serve): harden channel settings snapshots

* fix(serve): validate startup channel names

* fix(serve): reserve all channel name

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>

* fix(sdk-python): require canonical form in validate_session_id (#7532)

uuid.UUID() accepts several non-canonical spellings — braced
{...}, urn:uuid:..., and dash-less hex — so validate_session_id let them
through after the RFC 4122 variant check. The value is then forwarded to
the CLI verbatim as --session-id/--resume, producing a malformed session
id downstream rather than a clear error at the SDK boundary.

Reject anything whose canonical form differs from the input. Case is
deliberately not part of the comparison: UUID() lowercases, and an
all-uppercase spelling is still valid canonical input.

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>

* fix(web-shell): sync background agent status (#7561)

* fix(web-shell): sync background agent status

* fix(web-shell): harden background agent reconciliation

---------

Co-authored-by: ytahdn <ytahdn@gmail.com>

* feat(core): propagate trusted daemon invocation context (#7279)

* feat(core): propagate trusted daemon invocation context

* test(cli): update ACP startup expectation

* refactor(core): centralize ACP capability env key

* test(cli): update worktree ACP core mock

* test(integration): run daemon context smoke on PRs

* test(ci): update no-AK smoke expectation

* test(core): cover invocation context isolation

* fix(cli): compare ACP capability safely

* fix(docs): restore GitHub action input names

* fix(core): sanitize private ACP capability from child env

* fix(core): reuse private ACP capability env constant

* test(cli): cover malformed trusted invocation context

* test(acp-bridge): assert exact child environment

---------

Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: 易良 <1204183885@qq.com>

* fix(feishu): await stream cancels in media download teardown (#7465)

* fix(feishu): await stream cancels in media download teardown

downloadMedia left two reject paths' stream teardown unawaited:

- the oversize-stream path called reader.cancel() without awaiting, so a
  cancel error during teardown became an unhandled rejection (fatal under
  Node's default --unhandled-rejections=throw);
- the Content-Length reject path returned without cancelling resp.body,
  leaving the connection pinned until GC.

Both were already fixed for the sibling DingTalk downloader in #7361 (which
was itself modelled on this Feishu code), so this brings Feishu to parity.
Adds a regression test that pins the reader.cancel() await via a rejecting
cancel, plus an assertion that the Content-Length path releases the body.

* test(feishu): cover a rejecting body.cancel() on the Content-Length path

Mirrors the existing reader.cancel() teardown test for the other reject
path, per review feedback. Removing the await on resp.body?.cancel()
flips execution onto the 'rejected: size ... exceeds' branch and the
test fails.

* fix(autofix): make the review-address report wrapper lines bilingual (#7569)

The agent's address-summary.md / no-action.md already ends with a
collapsed Chinese translation, but the workflow-appended wrapper lines
around it — the "Addressed/Reviewed the latest feedback" lead-in, the
"Base-conflict check" line, and the "Re-review when you have a moment"
footer — were English-only and sat outside that block. So the posted
comment was only half translated, unlike the takeover-ack comments
(full collapsed Chinese block) and the "model/模型" sign-off in this
same report (already inline-bilingual).

Give each wrapper line an inline Chinese translation, matching the
model/模型 idiom. The English halves are preserved verbatim — the
streak-reset detector globs on "Addressed the latest review feedback"
and "no changes needed", and a test extracts these lines — so behaviour
is unchanged and old English-only comments still match. A new test pins
each English-Chinese pair so a future reword that drops the Chinese
fails. The terminal handoff/failure comment is left English-only for
now (SKILL.md keeps it so by design); that is a separate change.

Co-authored-by: wenshao <wenshao@example.com>

* feat(cli): post the review body bilingually when the PR description is Chinese (#7564)

When the PR author writes Chinese, the posted /review body was
English-only. fetch-pr now records whether the PR description contains
Han characters (prDescriptionHasHan, detected from the same gh pr view
call and stamped into the plan report), and compose-review renders the
body bilingually off that flag: the English body leads, the complete
Chinese version rides collapsed in a <details><summary>中文说明</summary>
block, and the model footer stays outside the fold. The signal is the
CLI's own — the caller cannot toggle the register of a certified body —
and a local plan has no field, so nothing changes for terminal-only
reviews.

Every deterministic body fragment carries an en/zh pair end to end:
compose-review's clause templates and describeChunkGap phrases, the
coverage disclosures (reasons, publicLabel role subjects via a new
publicLabelZh, the path-free unread-brief reason) and the Step 4/5 gap
texts including the combined same-shape sentence. Fragments with no
deterministic translation — model-written findings, caller echoes,
interpolated errors — ride verbatim in both halves. verificationGaps now
returns structural {subject, reason, subjectZh, reasonZh} entries, which
also removes compose-review's last recover-the-boundary-from-prose parse.

SKILL.md instructs the same format for the model-authored inline
comments: English finding first (marker and suggestion block stay in the
English half — tooling filters on them), full Chinese translation
collapsed beneath, footer last.

Co-authored-by: verify <verify@local>

* feat(autofix): auto-rerun a check that died on infrastructure, once (#7562)

* feat(autofix): auto-rerun a check that died on infrastructure, once

A failed check can be red because the machine died, not the code — a
self-hosted runner losing the server, the disk filling. #7490's E2E
failed with "runner lost communication with the server" and went green
on a rerun. The scan now reruns such a check's failed jobs automatically.

Detection is a conservative annotation whitelist (INFRA_FAILURE_SIGNATURES)
— only unambiguous machine failures, never a test-level timeout, which
could be a real regression. The one-shot guard is run_attempt, not a
marker: a run already retried to attempt 2 and still infra-failing is
persistent, so it is left for a human; after a rerun the attempt
increments, so the next scan will not rerun it. Every step is fail-safe
(any API error → no rerun), it runs only when the PR actually has a
failed check, and the gate carries the same review-address carve-out as
the other check selectors so the loop never reruns its own runs.

This is the transient-infra sibling of #7554 (stale-base): that merges
current main when a check is base-inherited; this reruns when a check
died on the runner. Neither touches a check that is a genuine failure.

Note: rerun-failed-jobs needs the PAT to hold `actions: write`.

* fix(autofix): use POSIX ERE groups in infra-failure regex, cover all signatures in tests (#7562)

* fix(autofix): also treat a git fetch/clone transport death as infra

#6506's checkout died mid-transfer — "fetch-pack: invalid index-pack
output" and "RPC failed; curl 92 ... CANCEL" — which then hung the job
into the 20m limit. That is infra, not the PR (it only touches a doc),
and a re-run made it green. But the infra-signature whitelist did not
cover it, so the auto-rerun did not fire and it waited on a human.

Add `invalid index-pack output` and `RPC failed` — the two canonical
git-transport-death phrases — to INFRA_FAILURE_SIGNATURES. A co-present
job-timeout line does not block the match (one matching line classifies
the run), and a BARE timeout with no transport signature is still left
alone, since it can be a real regression. Both new signatures are pinned
in the test's per-signature loop, plus a case on #6506's real composite
annotation and a bare-timeout-is-not-rerun guard.

* fix(autofix): paginate annotations and filter Autofix runs in infra-rerun loop (#7562)

---------

Co-authored-by: wenshao <wenshao@example.com>
Co-authored-by: Qwen Code Bot <qwen-code-bot@users.noreply.github.com>
Co-authored-by: qwen-code-ci-bot <qwen-code-ci-bot@users.noreply.github.com>

* fix(serve): detect stale SSE cursors across daemon restarts via epoch token; preserve turn attribution and surface compaction failures in replay (#7458)

* fix(daemon): epoch-token restart detection, compaction attribution, and degraded-snapshot signaling (DAEMON-001/007/008)

* fix(acp-bridge): field-level turn attribution merge and replayDegraded bridge test (#7458)

* fix(serve): skip bus epoch lookup for virtual subagent SSE streams (#7458)

The REST SSE route looked up the bus epoch for every session id, but
virtual subagent sessions ride their own bus and their compound ids are
not in the bridge's byId map, so the lookup threw and aborted the
subscription — breaking subagent event streams. Skip the lookup for the
virtual path and degrade a torn-down real session to a headerless stream
(mirrors the /acp route). Also bumps the daemon browser SDK bundle budget
(167KB -> 168KB) for the epoch fields and declares eventEpoch on
DaemonSession so the create/attach path drops its inline type cast.

* fix(serve): stamp eventEpoch on accepted continuations and surface replayDegraded in the SDK (#7458)

Address three review suggestions:
- POST /session/:id/continue now returns eventEpoch alongside lastEventId,
  mirroring the prompt 202 envelope so continuation-seeded SSE cursors
  detect daemon restarts (DAEMON-001)
- DaemonSessionClient exposes replayDegraded from the load response so SDK
  consumers can prefer the full transcript over a degraded snapshot
- add /acp dispatch-level regression test for the degraded-snapshot stderr
  breadcrumb (fires only when snapshot.degraded is set)

* test(cli): fix load-reply race in the degraded-breadcrumb transport test

Await each session/load reply frame before opening the session stream so
the GET cannot race conn.ownSession() into a 403; addresses the review
Critical on the deg-0 arm.

* fix(serve): allow and expose X-Qwen-Event-Epoch in CORS headers

Cross-origin SSE clients must send the epoch header through preflight and
read it from the response, or stale-cursor detection (DAEMON-001) is
silently disabled for every CORS client.

---------

Co-authored-by: qwen-code-bot <qwen-code-bot@users.noreply.github.com>
Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen Autofix <qwen-autofix[bot]@users.noreply.github.com>

* feat(core): Align GenAI telemetry with ARMS (#7536)

* feat(core): align GenAI telemetry with ARMS

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(core): remove estimated token usage splits

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(core): address GenAI telemetry review feedback

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

---------

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>

* fix(serve): avoid TOCTOU race dropping live sessions from list response (#7556)

* Initial plan

* fix(serve): avoid TOCTOU race dropping live sessions from list response

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: 易良 <1204183885@qq.com>

* fix(cli): prevent monitor turns after task_stop (#7573)

---------

Co-authored-by: 秦奇 <gary.gq@alibaba-inc.com>
Co-authored-by: Qwen Code Autofix <qwen-code-autofix@users.noreply.github.com>
Co-authored-by: Qwen Code Bot <qwen-code-bot@users.noreply.github.com>
Co-authored-by: qwen-code-ci-bot <qwen-code-ci-bot@users.noreply.github.com>
Co-authored-by: Qwen Code Autofix <qwen-code-autofix[bot]@users.noreply.github.com>
Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
Co-authored-by: destire-mio <qppque@gmail.com>
Co-authored-by: destire-mio <248462155+destire-mio@users.noreply.github.com>
Co-authored-by: Dragon <52599892+DragonnZhang@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: 易良 <1204183885@qq.com>
Co-authored-by: jinye <djy1989418@126.com>
Co-authored-by: chinesepowered <nlai@rediffmail.com>
Co-authored-by: ovochouovo <18212194+ovochouovo@users.noreply.github.com>
Co-authored-by: Edenman <67549719+BZ-D@users.noreply.github.com>
Co-authored-by: 克竟 <dingbingzhi.dbz@alibaba-inc.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: ytahdn <1294726970@qq.com>
Co-authored-by: ytahdn <ytahdn@gmail.com>
Co-authored-by: Truraly <94105924+Truraly@users.noreply.github.com>
Co-authored-by: zjgzx1988 <zjgzx1988@hotmail.com>
Co-authored-by: hogeheer499-commits <hogeheer499@gmail.com>
Co-authored-by: hogeheer <267467744+hogeheer499-commits@users.noreply.github.com>
Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
Co-authored-by: wenshao <wenshao@example.com>
Co-authored-by: qwen-code-dev-bot <qwen-code-dev@service.alibaba.com>
Co-authored-by: Nothing Chan <chenliu.cl@alibaba-inc.com>
Co-authored-by: 钉萁 <dingqi.jww@alibaba-inc.com>
Co-authored-by: yuanyuanAli <135116774+yuanyuanAli@users.noreply.github.com>
Co-authored-by: verify <verify@local>
Co-authored-by: qqqys <qys177@gmail.com>
Co-authored-by: callmeYe <512217680@qq.com>
Co-authored-by: Qwen Autofix <qwen-autofix[bot]@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
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.

Stopping a monitor triggers an automatic notification turn

3 participants