Status: implemented and archived. This file records the final scope, phase outcomes, verification commands, and intentionally deferred capabilities for future work.
为已经进入 background 的 local_bash 和 local_agent 提供用户可触发的 stop/cancel 控制能力,并实现 provider-visible TaskStop tool。实现必须复用现有 RuntimeTaskRegistry、background notification、runtime command queue、session projection 和 session/cancelBackgroundTask 链路,不新增第二套 background manager、poller、wake 或 UI stop path。
TaskStop tool 和 UI/session cancel 共用同一个 dispatcher。local_bash stop 分发到 ExecutionPort.cancelBackgroundTask(taskId)。local_agent stop 分发到 SubagentPort.stopTask(taskId)。TaskStop.command 语义:local_bash 使用实际命令,local_agent 使用短 description;完整 subagent prompt 不得进入 stop result。AgentToolCallBlock 只负责 background Agent 详情展示,不复制 stop 请求逻辑。TaskStop contract: apps/zcode-cli/packages/contracts/src/tools/task-stop.tsTaskStop model-facing handler: apps/zcode-cli/packages/core/src/tool/handlers/task-stop.tsapps/zcode-cli/packages/core/src/runtime/methods/background.tssession/cancelBackgroundTask in packages/shared/src/zcode-protocol/index.tsapps/zcode-cli/packages/adapters/src/exec/node-execution-adapter-lifecycle.tsapps/zcode-cli/packages/core/src/subagent/runner.tslocal_bash / local_agent stop control plus provider-visible TaskStop.TaskOutput, and non-shared task types out of this round.TaskStop validation errors.SubagentPort.stopTask() for running background local_agent.notified is only marked after notification enqueue succeeds.RuntimeTaskRegistry running background tasks rather than UI projection.TaskStop contract and handler.task_id and deprecated shell_id alias.command 对 local_agent 取 runtime task 的短 description,成功消息括号内复用同一值,不暴露完整 prompt。KillShell / KillBash aliases are supported through runtime lookup without becoming provider-visible tools.TaskStop for runtime-local background tasks; custom profiles still use existing allow/disallow filtering.session/cancelBackgroundTask protocol name to avoid protocol churn.workspaceIdentity / workspacePath semantics.TaskStop Agent path.pnpm typecheck.pnpm lint.git diff --check.Commands run during implementation and cleanup:
pnpm exec oxfmt --check apps/zcode-cli/packages/core/src/tool/executor/impl.ts apps/zcode-cli/packages/core/tests/task-stop-tool.test.ts apps/zcode-cli/packages/core/tests/tool-contracts.test.ts packages/desktop/test/e2e/conversation-session/background/conversation-session-background.test.ts
pnpm --filter @zcode/core exec vitest run tests/task-stop-tool.test.ts tests/background-task-control.test.ts tests/tool-contracts.test.ts tests/subagent-explore.test.ts -t "TaskStop|background task control|orders shared provider-visible|runs through Agent"
pnpm exec vitest --run packages/ui/test/zcodeSessionProjection.test.ts packages/ui/test/agentToolCallBlock.test.ts -t "task notification|background Agent|single background task"
pnpm exec vitest --run packages/services/test/zcodeLegacyTaskCompatTaskIndex.test.ts -t "task notification|background Agent"
pnpm exec vitest --run packages/shared/test/backgroundBashJobs.test.ts packages/ui/test/chatViewSummaryPanel.test.ts packages/ui/test/zcodeBackgroundTaskControl.test.ts -t "background Agent|background task|background Bash|running task"
pnpm exec vitest --run packages/shared/test/backgroundBashJobs.test.ts packages/ui/test/chatViewSummaryPanel.test.ts packages/ui/test/backgroundTaskSnapshotSync.test.ts packages/ui/test/zcodeBackgroundTaskControl.test.ts packages/ui/test/longRunningToolCalls.test.ts
pnpm exec vitest --run packages/ui/test/zcodeBackgroundTaskControl.test.ts packages/ui/test/chatViewSummaryPanel.test.ts
E2E_PROVIDER_REPLAY_FIXTURE_PATH=packages/desktop/test/e2e/fixtures/upstream/common.json,packages/desktop/test/e2e/fixtures/upstream/conversation-session/conversation-session-background.json pnpm --filter @zcode/desktop exec wdio run wdio.conf.ts --spec './test/e2e/conversation-session/background/conversation-session-background.test.ts'
pnpm typecheck
pnpm lint
git diff --check
These are known adjacent capabilities, but they were intentionally not implemented in this plan:
background_tasks foreground-to-background command.TaskOutput / output retrieval.workspaceIdentity / workspacePath boundaries, but mobile replayable promotion remains a separate validation item.local_bash and local_agent stop through one runtime dispatcher.