Skip to content

feat(trajectory): record native tool execution lifecycles - #13836

Merged
qqqys merged 2 commits into
QwenLM:mainfrom
qqqys:feat/trajectory-tool-lifecycle
Oct 10, 2026
Merged

qqqys merged 2 commits into
QwenLM:mainfrom
qqqys:feat/trajectory-tool-lifecycle

Conversation

@qqqys

@qqqys qqqys commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does

Records versioned tool execution lifecycle metadata for main tools and native Qwen subagents, persists it with the owning session, and exposes bounded SDK state for live updates and replay. Each admitted call receives an independent execution identity. Approval and preparation remain separate from actual execution; execution duration stops when the actual execution settles, while the final call outcome can still reflect a later hook failure.

The metadata travels independently of existing tool cards and results. Replay, compaction, session recovery, usage accounting, channel bridges, the IDE, and daemon consumers preserve their existing behavior when these frames appear.

Why it's needed

Trajectory timing currently cannot reliably distinguish approval waits from execution, identify repeated call IDs across agents, or preserve a late execution result after cancellation. This provides the execution evidence needed for the next trajectory stages without enabling the live trajectory UI in this PR.

Reviewer Test Plan

Verify that a successful or failed execution has one start and one terminal event, while a refused or rejected call is recorded as not started with no execution duration. Approval waits should not increase execution duration. A successful execution followed by a failing post-hook should retain successful execution status and a failed final outcome.

Verify that repeated provider call IDs across native agents remain independently owned. Cancelling the parent after a child starts should preserve the child's actual terminal event without duplicating tool results. Replayed terminal state should match live SDK state, and metadata should not create cards, messages, or usage entries.

The acceptance fix also covers cancellation after execution has settled but before post-processing completes: the terminal event keeps execution success and final cancellation. The independent counterexample passed after failing on the original head, and all 597 AgentCore, scheduler, and lifecycle-helper regressions passed. Workspace build, bundle, typecheck, changed-file lint/format, and the six controlled-provider E2E scenarios were rerun after the fix.

How to verify

Use a daemon session with SDK lifecycle inspection and timing-enabled transcript replay. Exercise successful reads, missing-file errors, approval refusal, cancellation after execution starts, concurrent native agents, and native child cancellation. Compare live metadata, recorded JSONL, and replay state. With timing disabled, lifecycle replay should be omitted.

Local validation completed on the frozen source submitted here: workspace build and typecheck; changed-file lint, formatting, and diff checks; focused core, CLI, ACP, SDK, channel, IDE, and replay regressions. The broad CLI run passed 1,300 tests and identified six outdated late-update count assertions; those assertions were corrected and the eight relevant cases passed on rerun. The final emitter suite passed 72/72. This is incremental package validation, not a claim that the entire repository test suite passed. The workspace build used an 8 GB Node heap after the root script's 4 GB CLI compilation limit ran out of memory.

Independent E2E ran six scenarios through the real daemon, ACP, SDK, and native tools with an isolated workspace and a controlled local OpenAI-compatible provider. All six passed, with 21 lifecycle frames consistent across live transport, recorded JSONL, and replay. A separate comment gives the scenario counts and evidence boundaries.

Evidence (Before & After)

N/A: this PR changes lifecycle transport and persistence, with no visible UI change. Before, timing could include approval and preparation and could not reliably identify execution occurrences. After, actual execution has independent identity and duration, and rejected calls explicitly remain not started.

Tested on

OS Status
🍏 macOS Build, typecheck, focused regressions, and six controlled-provider E2E scenarios passed
🪟 Windows Not tested locally
🐧 Linux Not tested locally; hosted CI is reported separately

Environment (optional)

Node 24.14.1, frozen pnpm dependencies, isolated QWEN_HOME and daemon runtime. The provider is a fixture; tools and the daemon/ACP/SDK path are real. No commercial model validation is claimed.

Risk & Scope

  • Main risk or tradeoff: lifecycle metadata crosses core, CLI, ACP, SDK, channels, and IDE consumers. Compatibility regressions were checked at those boundaries. Native late-result listeners drain for at most 30 seconds; missing terminal evidence then remains unknown. This is a resource cleanup bound, not a tool execution timeout. SDK state is bounded to 256 entries.
  • Not validated / out of scope: live trajectory UI, external or managed agents' internal execution timing, commercial model behavior, Windows/Linux local execution, and full end-to-end coverage of every hook, MCP, code-mode, or session-reset path. Native child replay was verified through the SDK subagent snapshot; child transcript pagination is not implemented by this change and its existing endpoint returns 404.
  • Breaking changes / migration notes: additive versioned metadata; existing end-to-end timing and tool card/result behavior remain supported. No migration is required.

Linked Issues

None.

中文说明

本 PR 做了什么

为主工具和原生 Qwen 子代理记录带版本的工具执行生命周期元数据,按所属会话持久化,并提供有界 SDK 状态供实时更新和回放使用。每次接纳的调用有独立执行标识。审批与准备阶段和真实执行分开;执行耗时在真实执行结束时冻结,最终调用结果仍可体现后续 hook 失败。

元数据独立于既有工具卡片和结果传递。回放、压缩、会话恢复、用量统计、channel 桥接、IDE 和 daemon 消费者在收到这些帧时保持既有行为。

为什么需要

现有轨迹计时无法可靠区分审批等待与执行,无法区分跨代理重复 call ID,也无法在取消后保留迟到的真实执行结果。本 PR 为后续轨迹阶段提供执行证据,本次不启用实时轨迹 UI。

评审者测试计划

验证成功或失败的执行各有一次开始和终态事件;审批拒绝或被拒绝的调用记录为未开始,没有执行耗时。审批等待不应增加执行耗时。执行成功但 post-hook 失败时,应同时保留执行成功状态和最终调用失败结果。

验证不同原生代理重复使用 provider call ID 时归属独立。子代理开始后取消父会话,应保留子代理真实终态且不重复工具结果。回放终态应与实时 SDK 状态一致,元数据不应创建卡片、消息或用量记录。

验收修复还覆盖了执行已结算、后置处理尚未完成时取消:终态保留执行成功和最终取消。独立反例在原提交失败、修复后通过;AgentCore、scheduler 和生命周期 helper 的 597 项回归全部通过。修复后重跑了 workspace build、bundle、typecheck、改动文件 lint/格式检查及六个受控 provider E2E 场景。

如何验证

使用 daemon 会话、SDK 生命周期检查和开启 timing 的 transcript 回放。覆盖成功读取、文件不存在错误、审批拒绝、真实执行开始后取消、原生代理并发和原生子代理取消。比较实时元数据、实际 JSONL 和回放状态。关闭 timing 时不应回放生命周期。

本次提交的冻结源代码已完成本地验证:workspace build 与 typecheck;改动文件 lint、格式和 diff 检查;core、CLI、ACP、SDK、channel、IDE 与回放的定向回归。较大范围 CLI 测试通过 1,300 项,并发现六项旧的迟到更新数量断言;修正后相关八项重跑通过。最终 emitter 全文件测试 72/72 通过。这是分包增量验证,不代表全仓测试全部通过。根脚本的 CLI 编译在 4 GB 堆限制下内存不足,随后使用 8 GB Node 堆完成 workspace build。

独立 E2E 在隔离工作区使用受控本地 OpenAI-compatible provider,通过真实 daemon、ACP、SDK 和原生工具执行六个场景,全部通过。21 个生命周期帧在实时传输、实际 JSONL 和回放三层一致。单独评论列出场景数量与证据边界。

证据(前后对比)

不适用:本 PR 修改生命周期传输与持久化,没有可见 UI 变化。之前,计时可能包含审批与准备,不能可靠识别每次执行。之后,真实执行具有独立标识与耗时,被拒绝的调用明确保持未开始。

测试平台

OS 状态
🍏 macOS Build、typecheck、定向回归与六个受控 provider E2E 场景通过
🪟 Windows 未做本地验证
🐧 Linux 未做本地验证;托管 CI 单独报告

环境(可选)

Node 24.14.1、冻结 pnpm 依赖、隔离 QWEN_HOME 和 daemon runtime。Provider 为 fixture;工具及 daemon/ACP/SDK 链路真实。未宣称商业模型验证。

风险与范围

  • 主要风险或取舍:生命周期元数据跨越 core、CLI、ACP、SDK、channel 和 IDE 消费者,已在这些边界检查兼容性。原生迟到结果监听最多 drain 30 秒,届时缺失的终态证据保持 unknown。这是资源清理上限,不是工具执行超时。SDK 状态最多保留 256 项。
  • 未验证或范围之外:实时轨迹 UI、外部或 managed agent 内部执行计时、商业模型行为、Windows/Linux 本地执行,以及所有 hook、MCP、code-mode 或会话重置路径的完整 E2E。原生子代理回放通过 SDK 子会话快照验证;本次不实现子会话 transcript 分页,其现有端点返回 404。
  • 破坏性变更或迁移说明:新增带版本元数据;既有端到端 timing 和工具卡片/结果行为继续支持。不需要迁移。

关联 Issue

无。

@qqqys

qqqys commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

E2E test report / E2E 验收报告

All six scenarios passed on macOS with Node 24.14.1, an isolated QWEN_HOME/runtime/workspace, and a controlled local OpenAI-compatible provider. The daemon, ACP transport, SDK, read/shell tools, and native agents were real; provider responses were fixtures. This does not establish commercial model behavior, deployment, or hosted CI results.

六个场景全部通过。环境为 macOS、Node 24.14.1、隔离 QWEN_HOME/runtime/工作区及受控本地 OpenAI-compatible provider。Daemon、ACP、SDK、read/shell 工具和原生代理真实执行,provider 响应为 fixture。该结果不代表商业模型、部署或托管 CI 验证。

Scenario / 场景 Live frames / 实时帧 Recorded JSONL / 实际落盘 SDK replay frames / 回放帧 SDK occurrences / 调用次数(含未执行)
Successful execution / 执行成功 2 2 2 1
Execution error / 执行错误 2 2 2 1
Approval refusal / 审批拒绝 1 1 1 1
Main tool cancellation after start / 主工具开始后取消 2 2 2 1
Concurrent native agents and repeated IDs / 原生并发与重复 ID 10 10 10 6
Parent cancellation after native child starts / 原生 child 开始后取消父会话 4 4 4 2

The 21 lifecycle frames matched complete ownership and payload across live transport, disk, and replay. SDK terminal states matched. Every recorded frame was checked with timing enabled and disabled; every live frame was checked against normalization and the existing transcript store so it did not modify tool cards.

21 个生命周期帧的完整归属与 payload 在实时、落盘和回放三层一致,SDK 终态一致。每个落盘帧都检查了 timing 开关,每个实时帧都检查了 normalizer 与既有 transcript store,未改变工具卡片。

The native concurrency case executed two parent agent calls and two child reads. Two later child calls reused provider IDs and were rejected by existing duplicate-call protection; their lifecycle state was not_started/error. They are occurrences, not additional executions. Parent replay used transcript pages; child replay used the SDK subagent snapshot. Child transcript pagination is not covered: the existing virtual child endpoint returns 404.

原生并发场景实际执行两个父 agent 调用和两个 child read。Child 后续两次重用 provider ID 的调用被既有去重保护拒绝,生命周期为 not_started/error,不能计为执行。父会话使用 transcript 分页回放;子会话使用 SDK 子会话快照。子会话分页未覆盖,现有虚拟子会话端点返回 404。

Build artifacts used for final verification / 最终验收构建 SHA256:

  • CLI: 154b06e91b5f86905811bd46ed82260d7359f975b2e2e3335b41f5ca40f5a95f
  • SDK daemon entry: d296592b303b69c8332cd15f9ae6336e2c6477a1d9134b1667faafa91bc1e83b
  • ACP transcript replay: 37ab87fe952bc0b5ef6df498666a5aaf00d7f9f691e4babdb4a4dce18f937db3

The 47 submitted source files were checked against the final source SHA256 manifest before commit and again after the commit hooks. Fixture provider and daemon processes were cleaned up. No visible UI changed, so before/after screenshots are not applicable.

47 个提交源文件在提交前与提交 hook 后均核对了最终源 SHA256 清单。测试自有 provider 和 daemon 进程已清理。本次没有可见 UI 变化,不适用前后截图。

Acceptance fix verification / 验收修复复测

Updated head: 6f294b35093dd41d8d066acfa83a8abf9912586d. Cancellation after actual execution settles now emits exactly one terminal lifecycle with execution success and final cancellation. The original independent counterexample failed before the fix and passed afterward; 597/597 related regressions passed. Workspace build, bundle, typecheck, lint/format, and six controlled-provider daemon/ACP/SDK E2E scenarios passed again (21 frames). Updated CLI artifact SHA256: 2d11288ceeddb220c6b570d3331d010d123e1c8c1e3e3058afc88a66fb32c061; SDK/ACP hashes above are unchanged. The specific post-processing cancellation race is covered by the independent regression test; the six daemon scenarios cover the existing behavior. Hosted CI is separate and pending.

更新提交:6f294b35093dd41d8d066acfa83a8abf9912586d。真实执行结束后取消,现在只发一次生命周期终态,同时保留执行成功和最终调用取消。独立原反例修复前失败、修复后通过,相关回归 597/597 通过。Workspace build、bundle、typecheck、lint/格式及六场景受控 provider daemon/ACP/SDK E2E 再次通过(21 帧)。更新 CLI 构建 SHA256 如上,SDK/ACP 哈希未变。后置处理取消的特定时序由独立回归测试覆盖;六个 daemon 场景检查既有行为。托管 CI 单独验证,尚未完成。

@qwen-code-review-bot

qwen-code-review-bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

🩺 serve daemon A/B

Built the PR base vs this PR head 6f294b3, drove a fixed endpoint set against each, and diffed the JSON responses. Only fields that changed are shown.

health-deep-with-session

field PR base (before) this PR (after)
activeWorkStaleMs 6 5

— Qwen Code · serve A/B

@qwen-code-review-bot

qwen-code-review-bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Qwen Triage finished — view run. See the stage comments in this thread for the result.

✅ Qwen Triage 已完成 —— 查看运行。结果见本线程中的各阶段评论。

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Thanks for the PR!

Template looks good ✓ — every required heading is present, and the Risk & Scope section is unusually honest about what was not validated.

Problem: grounded, not theoretical. The trajectory surface already ships in packages/web-shell/client/components/artifacts/ (Overview, Waterfall, Inspector, Panel), and today those views can only see end-to-end timing, so an approval wait is indistinguishable from execution. That is a real defect in an existing product surface rather than a hypothesis. Two caveats worth stating plainly: there is no linked issue, and no before/after capture of an actual wrong number — the case rests on the design argument plus your own E2E report. For feature groundwork I'm fine with that, but it does mean the central claim is not independently substantiated yet.

Direction: aligned. This mirrors an existing, accepted pattern in the repo — request_lifecycle already travels the same producer → JSONL → replay → SDK path, and transcript-replay.ts / sdk-typescript/.../execution-lifecycle.ts already split exactly the way this PR splits tool_lifecycle. No direct reference in the reference CHANGELOG, but the area is clearly relevant. Shipping the data layer without turning on a live UI is the right sequencing.

Size: 2709 changed lines across 47 files and 6 packages, breaking down as 1070 production lines / 27 files (410 of those on core paths), 1639 test lines / 20 files, 0 generated/schema. Core paths and a cross-package span both trip the Stage 0 gate, but this is a feat, not a refactor, so the large-core-refactor hard block does not apply. You're a CODEOWNER for /packages/core/, so under AGENTS.md the maintainer exemption applies and I'm not raising a separate maintainer-awareness escalation — that would just be escalating the change to its own author. The 1000+ production-line advisory does apply, so: is all of this one PR? See Approach.

Approach: the producer side and the compatibility guards feel correctly scoped — I could not find a consumer you missed. My one scope question is the SDK reducer. sdk-typescript/src/daemon/ui/tool-lifecycle.ts (204 lines) is a new public export surface (createToolLifecycleState / extractToolLifecycle / reduceToolLifecycle) with no in-repo consumer, landing in a PR that explicitly does not enable the live trajectory UI. I checked, and execution-lifecycle set that same precedent, so this is consistent rather than wrong — but publishing an API shape before its consumer exists means the shape is hard to change later. Worth considering whether the SDK half could land with the UI PR instead, which would cut the reviewable core down to producer + guards.

Risk: Stage 1e matched — packages/cli/src/acp-integration/ is on the high-risk path list (4 files: Session.ts, SubAgentTracker.ts, emitters/tool-call-emitter.ts, types.ts), the same area correlated with post-merge reverts. That is not a block, but it means full review depth and CI evidence before any approval, and it is where my one substantive code question landed (see Stage 2).

Moving on to code review. 🔍

中文说明

感谢贡献!

模板完整 ✓ —— 所有必需小节齐全,Risk & Scope 对"未验证内容"的说明相当坦诚。

问题: 真实存在,不是理论性加固。轨迹视图已经在 packages/web-shell/client/components/artifacts/(Overview、Waterfall、Inspector、Panel)上线,而目前这些视图只能看到端到端耗时,审批等待与真实执行无法区分。这是既有产品界面上的真实缺陷,不是假设。两点需要说明:没有关联 issue,也没有给出"数字算错了"的 before/after 证据 —— 目前依据是设计论证加上你自己的 E2E 报告。对于功能铺垫类 PR 这可以接受,但确实意味着核心主张尚未被独立验证。

方向: 对齐。这个做法与仓库中已被接受的既有模式一致 —— request_lifecycle 走的就是同样的 生产者 → JSONL → 回放 → SDK 链路,且 transcript-replay.ts 与 sdk-typescript/.../execution-lifecycle.ts 的拆分方式与本 PR 拆分 tool_lifecycle 的方式完全相同。参考 CHANGELOG 中没有直接对应条目,但这个领域显然相关。先落数据层、不开实时 UI,顺序是对的。

规模: 47 个文件、6 个 package、共 2709 行改动,其中 生产代码 1070 行 / 27 文件(核心路径 410 行)、测试 1639 行 / 20 文件、生成/schema 0 行。核心路径与跨 package 都触发了 Stage 0 门槛,但这是 feat 而非 refactor,因此大规模核心重构的硬性拦截不适用。你是 /packages/core/ 的 CODEOWNER,按 AGENTS.md 的维护者豁免,我不再单独发起"维护者知会"升级 —— 那等于把改动升级给它自己的作者。1000+ 生产行的大 PR 提示确实适用,所以:这些一定要放在同一个 PR 里吗?见"方案"。

方案: 生产者侧与兼容性防护的范围划分是合理的 —— 我没有找到你漏掉的消费者。唯一的范围疑问是 SDK reducer。sdk-typescript/src/daemon/ui/tool-lifecycle.ts(204 行)是新的公开导出面(createToolLifecycleState / extractToolLifecycle / reduceToolLifecycle),仓库内暂无消费者,而本 PR 明确不启用实时轨迹 UI。我确认过 execution-lifecycle 也是同样的先例,所以这是一致而非错误 —— 但在消费者出现之前就公开 API 形态,后续调整会变难。可以考虑把 SDK 这部分随 UI PR 一起落地,这样本次需要评审的核心就只剩生产者 + 防护。

风险: Stage 1e 命中 —— packages/cli/src/acp-integration/ 在高风险路径清单上(4 个文件:Session.ts、SubAgentTracker.ts、emitters/tool-call-emitter.ts、types.ts),该区域与合并后回滚存在相关性。这不是拦截,但意味着需要完整评审深度、且在任何批准前要有 CI 证据;我唯一的实质性代码疑问也正落在这里(见 Stage 2)。

进入代码审查 🔍

— Qwen Code · qwen3.8-max-2026-09-02

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

@qwen-code-review-bot

qwen-code-review-bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Code review

I wrote my own baseline before opening the diff: mint a per-execution UUID at the point the scheduler actually calls execute(), emit two immutable events rather than a mutable record, carry them out-of-band in _meta so no card renderer has to learn about them, validate strictly at each trust boundary, and reuse the request_lifecycle plumbing instead of inventing record types. That is essentially what this PR does, so I have no simpler alternative to argue for. The executionStatus (what the tool actually did) vs outcome (how the call finally resolved) split is the right model, and the PostToolUse-stop case — executionStatus: success with outcome: error — is precisely the distinction a trajectory view needs and cannot derive today.

The compatibility sweep holds up. That is the load-bearing part of a change that adds a new frame type to three transports, so I did not take it on faith. I enumerated every production consumer independently: all 16 tool_call_update branch sites, all 3 TOOL_OUTPUT_UPDATE agent-event listeners, and all 6 ui_telemetry JSONL readers. Eight sites are explicitly guarded; every remaining one is inert by construction because it requires status, content, rawOutput, mcp_app/A2UI meta, or executionStartTime, none of which a lifecycle-only frame carries. Two I checked closely because they looked dangerous and are not: normalizeToolCallType in the compaction engine would rewrite a lifecycle frame into a tool_call card start, but your new guard runs earlier in the same case body and pushes the un-normalized event to a misc slot, so it is never reached; and agent-interactive.ts has an unguarded TOOL_OUTPUT_UPDATE listener, but it only reads executionStartTime. Empty-chunk output updates are already an established nudge pattern there, so reusing that channel was a good call rather than a new event type.

Two things I want to raise, neither a blocker on its own.

1. The SubAgentTracker abort-guard relaxation goes past metadata, and the new test doesn't cover it. In createToolResultHandler the guard changes from if (abortSignal.aborted) return; to if (abortSignal.aborted && !this.toolStates.has(this.toolKey(event))) return;. That handler does not emit lifecycle frames — it calls emitResult, which sends a full card with status and content. Cleanup runs via cleanupSubAgentTracking() from cleanupAgentToolResources(), which fires on the cancel path only when errorResponse is built, so there is a real window where the parent has aborted, onToolResult is still attached, and the call is still in toolStates. In that window a late TOOL_RESULT now renders a card where the base dropped it silently. I'm not claiming a duplicate — I can't establish that statically — but it is a user-visible change to cancellation behaviour in ACP clients, and it isn't needed for the stated goal, since the terminal event already reaches the client through the separate onLifecycle listener with its own 30s drain. The added test (forwards lifecycle metadata after cancellation for an admitted tool without replacing output) calls cleanups[0]() before emitting TOOL_RESULT, which detaches onToolResult first, so it pins the lifecycle path and never exercises the relaxed guard. Is the late card intended? If yes, a test that emits TOOL_RESULT after abort with the listener still attached would settle it; if no, keeping the early return and letting onLifecycle carry the terminal is the smaller change.

2. approvalNotified is still keyed by the raw callId. toolStates correctly moved to JSON.stringify([subagentId, round, callId]) — and I verified all four event interfaces (AgentToolCallEvent, AgentToolResultEvent, AgentToolOutputUpdateEvent, AgentApprovalRequestEvent) carry those three fields, so the composite key is consistent everywhere it's used. But approvalNotified was left on the raw key, so within one subagent a callId reused across rounds suppresses the second round's "Waiting for permission" parent progress message. Pre-existing, not a regression, and cosmetic — just now visibly inconsistent with the map two lines above it.

Also checked and found fine, so you don't have to re-verify: the executionStartedAt = performance.now() reassignment inside execute() shifts the existing elapsedExecutionMs() reference point by microseconds only (execute() is invoked synchronously, once, in every path including the EXEC/code-mode wrappers), so no existing duration regresses; reduceToolLifecycle's prior! non-null assertion is safe because conflicts requires prior !== undefined; the 512-entry dedupe set and 256-entry SDK map both evict in insertion order; and the duplicated parseToolLifecycle across acp-bridge and sdk-typescript mirrors the existing execution-lifecycle split rather than inventing a new one.

sequenceDiagram
    participant P1 as CoreToolScheduler
    participant P2 as AgentCore
    participant P3 as SubAgentTracker
    participant P4 as ToolCallEmitter
    participant P5 as ChatRecordingService
    participant P6 as transcript replay
    participant P7 as ACP consumers
    Note over P1: approval and preparation happen earlier, outside this window
    P1->>P2: onToolExecutionStarted (callId, epoch)
    P2->>P2: lifecycle.start mints executionId and freezes startedAt
    P2->>P3: TOOL_OUTPUT_UPDATE (empty chunk, lifecycle started)
    P3->>P4: emitLifecycle (started)
    P4->>P7: tool_call_update with _meta.toolLifecycle, no status and no content
    P4->>P5: recordUiTelemetryEvent (tool_lifecycle)
    P1->>P1: invocation.execute settles
    P1->>P2: onToolExecutionSettled (callId, status, durationMs)
    Note over P2: executionDurationMs freezes here, a later hook failure cannot change it
    P2->>P3: TOOL_RESULT (lifecycle ended)
    P3->>P4: emitLifecycle (ended)
    P4->>P7: terminal frame, executionStatus kept separate from outcome
    P6->>P7: replay re-emits both frames only when includeTiming is set
Loading
Files changed (30 of 47 shown)
File What changed
packages/core/src/telemetry/tool-lifecycle.ts New producer. Mints a UUID executionId per admitted call, captures the owning session and recorder at creation so a late terminal still lands in the original JSONL after session rotation, and refuses to fabricate startedAt or executionDurationMs for a not_started call.
packages/core/src/core/coreToolScheduler.ts Adds the two observer hooks at the real invocation boundary and reports settled status plus duration, wrapping both in try/catch so a throwing observer cannot break tool execution.
packages/core/src/agents/runtime/agent-core.ts Owns a lifecycle per call, republishes start and terminal over TOOL_OUTPUT_UPDATE with an empty chunk, and skips its own liveOutputs handler for lifecycle frames.
packages/core/src/agents/runtime/agent-events.ts Optional lifecycle field on the tool result and output update events.
packages/core/src/agents/agent-transcript.ts Persists each transition once, keyed by executionId and phase, with a bounded dedupe set and a drain window so a late terminal still reaches disk after cleanup.
packages/core/src/services/chatRecordingService.ts Widens the ui_telemetry payload union to accept the new record type.
packages/core/src/services/session-transcript-reader.ts Keeps lifecycle frames out of the two restored ui telemetry projections, matching the existing request_lifecycle exclusion.
packages/core/src/services/sessionService.ts Remaps the owning session on fork without inventing a promptId, and excludes the frames from telemetry replay.
packages/core/src/services/usageHistoryService.ts Excludes the frames from usage rebuild and salvage so they cannot count as usage events.
packages/core/src/index.ts Public core exports for the factory, the drain constant, and the three types.
packages/cli/src/acp-integration/session/Session.ts Primary ACP producer. Wraps execute to observe the real boundary, keeps execution duration frozen at settle while the final outcome can still move, and exposes isDisposed. High-risk path.
packages/cli/src/acp-integration/session/SubAgentTracker.ts Composite toolStates key so repeated call IDs stay independently owned, a separate lifecycle listener with its own drain, and the relaxed abort guard I question above. High-risk path.
packages/cli/src/acp-integration/session/emitters/tool-call-emitter.ts emitLifecycle sends metadata with no status or content, and a discarded preparation now closes its lifecycle as not_started even when delivery fails. High-risk path.
packages/cli/src/acp-integration/session/types.ts Optional isDisposed on the session context. High-risk path.
packages/acp-bridge/src/transcript-replay.ts The strict parser and the frame builder, plus pending-call rebinding so a replayed terminal maps to the right occurrence across page boundaries.
packages/acp-bridge/src/compactionEngine.ts Routes metadata-only frames to a misc slot before tool call normalization can turn them into a card.
packages/sdk-typescript/src/daemon/ui/tool-lifecycle.ts New public SDK reducer. Duplicates the parser per the existing execution-lifecycle convention, marks contradictory arrivals as conflicted rather than guessing, and bounds state to 256 entries.
packages/sdk-typescript/src/daemon/ui/normalizer.ts Drops metadata-only frames so they never become a Chat card, while a frame that also carries status, title, kind or content still renders.
packages/sdk-typescript/src/daemon/index.ts Re-exports the new SDK surface.
packages/sdk-typescript/src/daemon/ui/index.ts Re-exports the new SDK surface.
packages/channels/base/src/AcpBridge.ts Breaks out of tool update handling for metadata-only frames, leaving known tool kinds untouched.
packages/channels/base/src/DaemonChannelBridge.ts Same guard on the daemon channel path, so no channel emits a phantom tool call.
packages/cli/src/serve/session-agents/adapters/qwen-acp.ts Skips the frames instead of creating or repeating a session agent step, and widens the update type to expose _meta.
packages/cli/src/ui/daemon/daemon-tui-adapter.ts Returns no history item for a metadata-only frame, which also covers the second call site that delegates here.
packages/cli/src/external-agents/acp-subagent-executor.ts Ignores the frames so an external agent's lifecycle metadata cannot resurrect a finished tool.
packages/vscode-ide-companion/src/services/qwenSessionUpdateHandler.ts Breaks before the tool call callback for metadata-only frames.
packages/vscode-ide-companion/src/services/qwenAgentManager.ts Omits the frames from JSONL chat history alongside request_lifecycle.
packages/core/src/core/coreToolScheduler.test.ts Pins the observer ordering as started then execute then settled across success, sync throw and async rejection, and pins that an abort-ignoring tool leaves the observer unsettled until it actually returns.
packages/core/src/agents/runtime/agent-core.test.ts Covers the acceptance case: cancelled after settle keeps execution success with final cancellation, and no second tool result is emitted.
packages/cli/src/acp-integration/session/Session.test.ts Pins that a 30s approval wait does not enter execution duration while end-to-end _meta timing still reports the full 30020ms.
…and 17 more files Remaining test coverage across acp-bridge, channels, sdk, serve adapter, TUI adapter and IDE companion.

Test evidence

This is an unattended CI run, so per the gate rules I did not build, run, or execute anything from this PR — the evidence below is the PR's own CI, read through the API for commit 6f294b35093dd41d8d066acfa83a8abf9912586d. Nothing is red, but the suite that matters has not finished: Test (ubuntu-latest, Node 22.x) is still in_progress, and two further runs are queued. Test (macos-latest) and Test (windows-latest) are skipped, which is this repo's normal shape — the unit suite runs on ubuntu only — so there is no cross-platform signal here, and your own report says Windows and Linux were not tested locally either. Lint & Static, Serve A/B, Real daemon E2E, TUI parity snapshots, OpenTUI no-flicker gate and both Desktop Shell jobs are green. The duplicated label check (one cancelled, one success) is orchestration noise, not a failure.

I have not re-run your numbers. The 597 AgentCore/scheduler/lifecycle regressions, the 1300-test CLI run, the 72/72 emitter suite and the six controlled-provider E2E scenarios are your claims, not evidence I verified — and the six outdated late-update assertions you found and corrected are exactly the kind of thing that only a full suite run would surface, which is still in flight.

Final CI results for 6f294b3 (auto-updated by the triage finalize job after CI completed):

Check Conclusion
Classify PR ✅ success
Desktop Shell (ubuntu-22.04) ✅ success
Desktop Shell (windows-2022) ✅ success
Flyway migration version uniqueness ✅ success
Hosted process fault gates / MySQL 8.4 / Java 21 ✅ success
Integration Tests (no-AK, No Sandbox) ✅ success
Lint & Static (ubuntu-latest, Node 22.x) ✅ success
macos-latest / Java 21 ✅ success
OpenTUI no-flicker gate ✅ success
Real daemon E2E / Java 11 ✅ success
Runtime Broker and Managed Agent MariaDB / Java 21 ✅ success
Serve A/B (ubuntu-latest, Node 22.x) ✅ success
Test (ubuntu-latest, Node 22.x) ✅ success
TUI parity snapshots (ink vs opentui) ✅ success
ubuntu-latest / Java 11 ✅ success
ubuntu-latest / Java 17 ✅ success
ubuntu-latest / Java 21 ✅ success
web-shell E2E Smoke (ubuntu-latest, Node 22.x) ✅ success
windows-latest / Java 21 ✅ success

One row per check name (latest run); skipped checks omitted; failures sort first. / 每个检查名一行(取最新一次运行),省略 skipped,失败项排在最前。

Not verified: whether the late post-cancellation tool card from finding 1 actually renders in a client. That is the one claim here that neither the diff nor the suite settles, and your own test detaches the listener before it fires. Sandboxed verification would settle it: @qwen-code /verify — an A/B against the base build with the relaxed SubAgentTracker abort guard as the load-bearing element would show whether a cancelled native subagent tool produces a card the base does not, which is not observable from the diff and is not pinned by the current test. Since this is a TUI-adjacent surface, @qwen-code /tmux would additionally show whether a cancelled subagent turn leaves a stray tool card on screen. You have write access, so both are directly available rather than sponsored runs.

Real-scenario tmux testing: N/A — unattended CI run, and the gate forbids executing PR-derived code here. Live behaviour belongs to the isolated @qwen-code /tmux job above.

中文说明

代码审查

在读 diff 之前我先写了自己的基线方案:在调度器真正调用 execute() 处为每次执行生成 UUID、发两个不可变事件而非可变记录、通过 _meta 带外传递以免任何卡片渲染器需要改动、在每个信任边界严格校验、并复用 request_lifecycle 链路而不是新造记录类型。本 PR 基本就是这么做的,所以我没有更简方案可主张。executionStatus(工具实际做了什么)与 outcome(调用最终如何收场)的拆分是正确的模型,PostToolUse 停止那种情形 —— executionStatus: success 配 outcome: error —— 正是轨迹视图需要、而今天无法推导出的区分。

兼容性排查站得住脚。 这是给三种传输新增帧类型时最关键的部分,所以我没有采信而是自己核了一遍:我独立枚举了全部 16 处 tool_call_update 分支、3 处 TOOL_OUTPUT_UPDATE 事件监听、6 处 ui_telemetry JSONL 读取点。其中 8 处有显式防护;其余每一处都因结构上必然无效 —— 它们要求 status、content、rawOutput、mcp_app/A2UI meta 或 executionStartTime,而纯元数据帧这些都不带。有两处看着危险、实际没问题,我特意确认过:压缩引擎里的 normalizeToolCallType 本会把生命周期帧改写成 tool_call 卡片起点,但你的新防护在同一 case 体内更早执行,把未改写的事件推入 misc 槽,因此根本走不到;agent-interactive.ts 有一个未加防护的 TOOL_OUTPUT_UPDATE 监听,但它只读 executionStartTime。空 chunk 的输出更新在那里本就是既有的 nudge 模式,所以复用这个通道是好的选择,而不是新增事件类型。

有两点要提,单独看都不是拦截项。

1. SubAgentTracker 放宽 abort 判断超出了元数据范围,且新增测试没有覆盖到。 createToolResultHandler 里的判断从 if (abortSignal.aborted) return; 改成 if (abortSignal.aborted && !this.toolStates.has(this.toolKey(event))) return;。这个 handler 并不发生命周期帧 —— 它调用 emitResult,会发出带 status 和 content 的完整卡片。清理经由 cleanupAgentToolResources() 调 cleanupSubAgentTracking(),而在取消路径上它只在构造 errorResponse 时才触发,所以确实存在一个窗口:父会话已 abort、onToolResult 仍挂着、调用仍在 toolStates 里。在这个窗口内,一个迟到的 TOOL_RESULT 现在会渲染出卡片,而基线是静默丢弃。我没有断言这是重复 —— 静态分析无法确定 —— 但这是 ACP 客户端上取消行为的可见变化,而且它对既定目标并非必需,因为终态事件已经能通过独立的 onLifecycle 监听(自带 30 秒 drain)送达客户端。新增测试(forwards lifecycle metadata after cancellation for an admitted tool without replacing output)在发出 TOOL_RESULT 之前先调了 cleanups[0](),这会先摘掉 onToolResult,因此它钉住的是生命周期路径,从未真正跑到被放宽的那个判断。这张迟到卡片是有意的吗?如果是,补一个"abort 后、监听仍挂着"时发 TOOL_RESULT 的测试就能定论;如果不是,保留原来的提前返回、让 onLifecycle 承载终态,是更小的改动。

2. approvalNotified 仍以原始 callId 为键。 toolStates 已正确改为 JSON.stringify([subagentId, round, callId]) —— 我核对了四个事件接口(AgentToolCallEvent、AgentToolResultEvent、AgentToolOutputUpdateEvent、AgentApprovalRequestEvent)都带这三个字段,所以复合键在各使用处是一致的。但 approvalNotified 留在了原始键上,于是同一个子代理内跨 round 复用 callId 时,第二轮的 "Waiting for permission" 父级进度消息会被抑制。这是既有行为、不是回归,且只是观感问题 —— 只是现在跟它上面两行的那个 map 明显不一致了。

以下我也查过、确认没问题,你不必重复验证:execute() 内重新赋值 executionStartedAt = performance.now() 只把既有 elapsedExecutionMs() 的基准点移动了微秒级(execute() 在包括 EXEC/code-mode 包装在内的所有路径上都是同步、单次调用),所以既有耗时不会回归;reduceToolLifecycle 里的 prior! 非空断言是安全的,因为 conflicts 要求 prior !== undefined;512 项去重集合与 256 项 SDK map 都按插入顺序淘汰;acp-bridge 与 sdk-typescript 之间重复的 parseToolLifecycle 是沿用既有 execution-lifecycle 的拆分方式,而非新造一套。

测试证据

这是无人值守的 CI 运行,按门槛规则我没有构建、运行或执行本 PR 的任何代码 —— 下面的证据来自 PR 自己的 CI,通过 API 读取 commit 6f294b35093dd41d8d066acfa83a8abf9912586d 的结果。没有红灯,但真正关键的那条还没跑完:Test (ubuntu-latest, Node 22.x) 仍是 in_progress,另有两个 run 在排队。Test (macos-latest) 与 Test (windows-latest) 是 skipped,这是本仓库的正常形态 —— 单元测试只在 ubuntu 上跑 —— 所以这里没有跨平台信号,而你自己的报告也说 Windows 和 Linux 未在本地验证。Lint & Static、Serve A/B、Real daemon E2E、TUI parity snapshots、OpenTUI no-flicker gate 和两个 Desktop Shell 作业为绿。重复出现的 label 检查(一个 cancelled、一个 success)是编排噪音,不是失败。

我没有复跑你的数字。597 项 AgentCore/scheduler/lifecycle 回归、1300 项 CLI 测试、72/72 emitter 套件、六个受控 provider E2E 场景,都是你的声明,不是我验证过的证据 —— 而你发现并修正的那六条过期的 late-update 断言,恰恰是只有完整套件跑一遍才会暴露的东西,而它还在跑。

未验证:finding 1 中那张取消后的迟到工具卡片是否真的会在客户端渲染出来。 这是本 PR 中唯一一个 diff 和测试套件都无法定论的主张,而你自己的测试在它触发前就摘掉了监听。沙箱验证可以定论:@qwen-code /verify —— 以被放宽的 SubAgentTracker abort 判断为承重点、对基线构建做 A/B,就能看出被取消的原生子代理工具是否会产生基线没有的卡片,这一点从 diff 看不出来、当前测试也没钉住。由于这属于贴近 TUI 的界面,@qwen-code /tmux 还能进一步显示取消子代理轮次后屏幕上是否留下多余的工具卡片。你有写权限,因此两者都可直接触发,不需要赞助运行。

真实场景 tmux 测试:N/A —— 无人值守 CI 运行,且门槛规则禁止在此执行 PR 派生代码。实时行为应由上面那个隔离的 @qwen-code /tmux 作业承担。

— Qwen Code · qwen3.8-max-2026-09-02

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

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Confidence: 3/5 — the design and the compatibility work are genuinely solid, but I have one cancellation-behaviour question I cannot resolve from the diff, and the suite that would surface it is still running.

Stepping back: this is not a PR I'm approving because I ran out of objections. The hard part of adding a frame type to three transports is proving that nothing else renders it, and that proof holds — I enumerated the consumers myself rather than trusting the diff, and every unguarded one is inert by construction. The executionStatus / outcome separation is the right abstraction and it's the thing the existing web-shell trajectory views actually need. Test coverage is proportionate to the risk: 1639 test lines against 1070 production lines, and the tests pin semantics rather than call counts — the approval-timing test asserting that a 30s permission wait stays out of executionDurationMs while end-to-end _meta still reports 30020ms is exactly the right oracle. In six months I'd thank whoever wrote this rather than curse them.

What keeps me at 3 rather than 4 is finding 1 in Stage 2. Relaxing the abort guard in SubAgentTracker.createToolResultHandler re-enables full result-card emission after cancellation for tracked subagent calls, on a path Stage 1e already flags as high-risk, and the test added for that scenario detaches the listener before it fires. I'm not asserting a defect — I'm saying the PR's own claim ("without duplicating tool results") is not pinned by anything I can read, and the change is not required for the stated goal because the terminal event already has its own listener and drain. That is a genuine open question, not a hygiene nit, so per the re-run rule it's the kind of thing I should defer on rather than wave through.

The secondary reason is simply timing: Test (ubuntu-latest, Node 22.x) is still in progress with two runs queued, so approving now would attest to a result that doesn't exist yet. I'm deliberately not leaving a deferred-approval instruction behind either, because my verdict is defer rather than approve — CI landing green should not convert that into an approval on its own.

@qqqys you own packages/core and you wrote this, so the call is yours rather than a third-party maintainer's — I could not resolve an eligible owner other than you (the PR carries no area labels and has no human reviewer yet), so I'm not escalating over your head. Two things would move me to approve: an answer on whether the late post-cancellation card is intended, and a test that emits TOOL_RESULT after abort with onToolResult still attached. If the answer is "yes, intended", a @qwen-code /verify A/B against base would settle whether it changes what a client renders. The approvalNotified key inconsistency and the question of whether the public SDK reducer should land with the UI PR instead are both non-blocking — note them or defer them as you see fit.

⏸️ Not approving on this run.

中文说明

Confidence: 3/5 —— 设计与兼容性工作确实扎实,但我有一个从 diff 无法定论的取消行为疑问,而能暴露它的测试套件还在跑。

退一步看:这不是一个"因为找不到反对理由所以批准"的 PR。给三种传输新增帧类型,最难的部分是证明其它地方都不会渲染它,而这个证明成立 —— 消费者是我自己枚举核实的,不是采信 diff,每一处未加防护的都在结构上必然无效。executionStatus / outcome 的拆分是正确的抽象,也正是既有 web-shell 轨迹视图真正需要的东西。测试覆盖与风险相称:1070 行生产代码对应 1639 行测试,且测试钉的是语义而不是调用次数 —— 那个审批计时测试断言 30 秒权限等待不进入 executionDurationMs、同时端到端 _meta 仍报告 30020ms,正是恰当的判据。半年后回看,我会感谢写这段代码的人,而不是骂他。

让我停在 3 分而不是 4 分的,是 Stage 2 的 finding 1。放宽 SubAgentTracker.createToolResultHandler 的 abort 判断,会让已被追踪的子代理调用在取消之后重新恢复完整结果卡片的发送,而这正好落在 Stage 1e 已标记为高风险的路径上;为该场景新增的测试又在监听触发前先把它摘掉了。我没有断言存在缺陷 —— 我是说本 PR 自己的主张("不重复工具结果")没有任何我能读到的东西钉住它,而这个改动对既定目标也并非必需,因为终态事件本来就有自己独立的监听和 drain。这是一个真实的待解问题,不是卫生类小瑕疵,所以按 re-run 规则,这种情况我应该 defer 而不是放行。

次要原因就是时机:Test (ubuntu-latest, Node 22.x) 仍在进行、另有两个 run 排队,此时批准等于为一个还不存在的结果背书。我也刻意没有留下任何延迟批准指令,因为我的结论是 defer 而非 approve —— CI 变绿本身不应该把它转成一次批准。

@qqqys 你是 packages/core 的 owner,也是这段代码的作者,所以这个判断该由你来做,而不是交给第三方维护者 —— 我没能解析出除你之外的合格 owner(本 PR 没有 area 标签,也还没有人类 reviewer),所以我不会越过你去升级。有两件事能让我转为批准:一是回答取消后那张迟到卡片是否有意为之,二是补一个"abort 之后、onToolResult 仍挂着"时发出 TOOL_RESULT 的测试。如果答案是"是,有意的",那么对 base 做一次 @qwen-code /verify A/B 就能定论它是否改变了客户端的渲染结果。approvalNotified 的键不一致,以及"公开 SDK reducer 是否应随 UI PR 一起落地"的疑问,都是非拦截项 —— 按你的判断处理或延后都可以。

⏸️ 本次运行不予批准。

— Qwen Code · qwen3.8-max-2026-09-02

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

@qqqys
qqqys enabled auto-merge October 10, 2026 13:16

@chiga0 chiga0 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.

Review — feat(trajectory): record native tool execution lifecycles

Tier: Deep (new persisted telemetry format, concurrency + lifecycle state machine, cross-package contract)

Verdict: APPROVE — no blockers. One minor finding rides along.


What was checked

Dimension Result
Core state machine (start/finish idempotency, ended flag) ✅ clean
Dual-finish race (onToolExecutionSettled vs TOOL_RESULT handler) ✅ clean
Clock-skew guard (Math.max(startedAt ?? 0, Date.now())) ✅ clean
Drain timer logic (TOOL_LIFECYCLE_DRAIN_MS, drainTimer.unref()) ✅ clean
Consumer frame exclusion (event.name === 'tool_lifecycle') ✅ clean
Wire-bridge frame exclusion (meta.toolLifecycle + !status + !content) ✅ clean
Fork session remap (sessionId updated, no promptId remap for tool events) ✅ clean
SDK type contract vs core type (3-variant discriminated union) ✅ symmetric
SubAgentTracker toolKey uniqueness ([subagentId, round, callId]) ✅ clean
LRU eviction in reduceToolLifecycle ✅ correct
Approval refused path (Session.ts + agent-core.ts: finish('error','not_started')) ✅ clean
persist: false path (transcript writer receives events via emitter, not direct DB) ✅ clean

Dual-finish race resolution

The interaction between onToolExecutionSettled and the TOOL_RESULT batch handler is correct:

  • Normal flow: onToolExecutionSettled records results but skips finish (emittedCallIds.has = false) → TOOL_RESULT handler calls finish with execution info.
  • Cancellation-while-running: TOOL_RESULT emitted first → handler sees startedLifecycles.has && !execution, skips finish, adds to emittedCallIds → onToolExecutionSettled sees emittedCallIds.has = true, calls finish('cancelled', status, durationMs).
  • Guard in tool-lifecycle.ts: if (ended) return undefined makes all subsequent finish() calls no-ops regardless of race order.

R1-1 (minor) — recordedLifecycle FIFO eviction breaks dedup past 256 tool calls

The dedup set evicts the oldest key once it exceeds 512 entries. Since each execution produces two keys (uuid:started and uuid:ended), the limit is effectively 256 complete tool executions per session. Past that point, a re-delivered started event (e.g. from a replay or transport retry) for an evicted execution would pass the has() check and be double-appended to the JSONL transcript.

This doesn't affect drain correctness — pendingLifecycle is a separate Set and is never evicted. The risk is low for typical sessions, but the 512 cap and TOOL_LIFECYCLE_DRAIN_MS are uncoordinated: a 30-second drain window could stay open through more than 512 events in a high-throughput subagent scenario.

Suggestion: Track dedup by executionId only (one entry per execution, removed on ended) rather than per phase, which halves the effective entry count and makes the cleanup natural.


Informational — normalizer.ts applies stricter lifecycle-frame filter

All other lifecycle-frame consumers (sse.ts, compactionEngine.ts, channel bridges) check two conditions to skip: meta.toolLifecycle && !status && !content. The normalizer adds !title && !kind — a superset that's slightly more conservative and avoids discarding a tool_call_update that coincidentally carries both a lifecycle token and real display content. This is a positive divergence, not a bug.

if (event.phase === 'started') pendingLifecycle.add(event.executionId);
else pendingLifecycle.delete(event.executionId);
if (recordedLifecycle.size > 512)
recordedLifecycle.delete(recordedLifecycle.values().next().value!);

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.

R1-1 (minor): FIFO eviction at 512 entries can break phase-level dedup past 256 complete tool executions in a session. A re-delivered started event for an evicted execution would pass the has() check and be appended twice to the JSONL transcript.

The pendingLifecycle Set (which governs drain correctness) is separate and unaffected. The practical risk is low for typical sessions, but the 512 cap and 30-second drain window are uncoordinated.

Suggestion: Track by executionId only (remove on ended phase) rather than by executionId:phase, halving the effective slot usage and making cleanup self-evident.

@yiliang114 yiliang114 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.

Approving — CI is green on 6f294b3 (the ubuntu test run that was still in flight during triage has since passed), and the one open question from the triage review resolves in this PR's favor.

On the relaxed abort guard in SubAgentTracker.createToolResultHandler (abortSignal.aborted && !this.toolStates.has(this.toolKey(event))): I traced the cancel path at this head. Abort fires propagateAbort, but tracker cleanup only runs later via earlyErrorResponse / the normal completion path. In that window a subagent tool that actually completed emits TOOL_RESULT while still tracked, and the relaxed guard lets emitResult close the card exactly once — the key is deleted on first emit, so it cannot render twice, and a call whose TOOL_CALL arrived after abort was never inserted into toolStates at all. Base behavior dropped that result and left the card dangling in_progress for the rest of the transcript. The lifecycle terminal cannot replace this close either: those frames are metadata-only (status/content undefined, pinned by the added test), so the only user-visible card close comes from emitResult. Reads as intended behavior to me, and reverting the guard would reintroduce the dangling card.

Non-blocking: approvalNotified is still keyed by raw callId while toolStates moved to the composite key two lines above — pre-existing and cosmetic (worst case one suppressed "Waiting for permission" progress update on cross-round callId reuse), but worth aligning at some point.

One disclosure: my bounded security pass over the diff (frame parsers / transport surface) failed to produce output, so that dimension is not independently covered by this review. CI Lint & Static is green and the strict frame parsers do reject malformed not_started frames carrying timing fields, but I am not claiming a full security sweep.

@qqqys
qqqys added this pull request to the merge queue Oct 10, 2026
Merged via the queue into QwenLM:main with commit c34b842 Oct 10, 2026
74 of 75 checks passed
@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Released in v0.25.1.

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.

5 participants