状态(2026-07-15):已实施,本文保留为历史修复计划。当前 telemetry 契约以
docs/monitoring/business-monitoring.md、docs/monitoring/performance-telemetry-catalog.md和packages/ui/src/lib/messageTelemetry.ts为准;下文旧useZCodeChat调用路径仅供追溯。For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Make message_completion step and tool counts describe only its active prompt instead of the full task history.
Architecture: Accumulate finalized step metrics in PromptTelemetryState, using the same finalizeAgentStep() path that emits agent_step. Keep loop_index in the existing prompt-reset AgentStepTelemetryState, and remove taskMessages from completion finalization and its callers.
Tech Stack: TypeScript, Vitest, WebdriverIO/Electron E2E.
Files:
Modify: packages/ui/test/messageTelemetry.test.ts
[x] Step 1: Add a two-prompt test on one task. Finalize one generation step in each prompt while passing historical assistant messages to the old API, then assert the second completion reports agent_step_cnt="1" and its emitted step has loop_index="1".
[x] Step 2: Add a current-prompt tool test that finalizes one successful and one failed tool step, then asserts tool_call_total="2", tool_call_failed="1", and the first tool error fallback.
[x] Step 3: Run pnpm vitest run packages/ui/test/messageTelemetry.test.ts and confirm the new message-scope assertion fails against the historical scan.
Files:
Modify: packages/ui/src/lib/messageTelemetry.ts
[x] Step 1: Add prompt-level finalized step count, tool count, failed tool count, and first tool error state initialized by queuePromptTelemetry().
[x] Step 2: Update finalizeAgentStep() to increment those fields exactly once for every emitted step.
[x] Step 3: Make finalizePromptTelemetry() read the prompt counters and remove countAgentSteps(), collectToolCallCompletionMetrics(), TaskChatMessage, and FinalizePromptTelemetryInput.taskMessages.
[x] Step 4: Run the focused Vitest file and confirm GREEN.
Files:
packages/ui/src/hooks/useZCodeChat.tspackages/ui/src/lib/zcodeTaskRuntimeMonitor.tsdocs/monitoring/business-monitoring.mdModify: docs/monitoring/performance-telemetry-catalog.md
[x] Step 1: Remove message-store reads and taskMessages arguments used only by completion telemetry.
[x] Step 2: Document prompt-lifecycle step/tool accumulation and the equality between agent_step_cnt and same-message emitted steps.
[x] Step 3: Run focused unit tests and desktop E2E typecheck.
Files:
docs/testing/conversation-session-e2e-coverage-matrix.mdModify: docs/superpowers/specs/2026-07-02-agent-step-message-scope-e2e-design.md
[x] Step 1: Run the formal message-scope E2E with its case-local replay fixture and confirm the former RED assertion passes.
[x] Step 2: Change R01 from failing to covered and record the GREEN evidence.
[x] Step 3: Run pnpm typecheck, pnpm lint, focused unit tests, git diff --check, and inspect the final diff.
[x] Step 4: Commit with a Conventional Commit message.