For agentic workers: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: 收敛 BG06:background subagent 内部启动 background Bash 后,Bash completion 归属于 child runtime 的 cleanup lifecycle,不复活已完成的 child model loop,也不补发 parent Agent result。
Architecture: 不引入全局 agentId -> task owner routing。ZCode 已经通过 main/child AgentRuntime 隔离解决了 runtime 串线问题;本计划只在 child runtime 内增加 terminal/sealed background notification policy、subagent-scope Bash 最大运行时长和取消清理。parent/main background Agent、parent Bash、goal defer/wake 主链路保持现状。
Tech Stack: TypeScript, AgentRuntime, ToolExecutor, RuntimeTaskRegistry, ExecutionPort, Vitest, desktop conversation E2E replay.
deferred 改成新 accepted boundary。output-file provider surface;stdout/stderr 收敛是独立需求。web-remote-replayable 语义;本计划只覆盖 desktop continuous / core runtime。git commit。AgentRuntime,在 apps/zcode-cli/packages/core/src/runtime/methods/subagent.ts 中创建。apps/zcode-cli/packages/core/src/tool/executor/background-tasks.ts 负责;terminal 后会尝试 enqueue <task-notification>。apps/zcode-cli/packages/core/src/runtime/methods/runtime-command-queue.ts 中消费 task-notification,当前会直接执行一轮 executeTurnCommand(...)。RuntimeTaskRegistry 已可记录 local_bash / local_agent / local_workflow,但没有 owner lifecycle 状态。deferred,且文字里还保留旧误解:“child runtime 消费 Bash notification 后再形成最终 Agent result”。本计划先修正文档语义。<task-notification>。RuntimeTaskRegistry terminal 状态;<task-notification> model turn;executeTurnCommand(...);3_600_000ms,超时后 kill/cancel 并落 terminal cleanup。docs/conversation-session-case-catalog.md
deferred 到新 accepted/pruned wording。docs/testing/conversation-session-background-e2e-coverage-matrix.md
docs/testing/conversation-session-e2e-coverage-matrix.md
packages/desktop/test/e2e/conversation-session/manual-review/pending/conversation-session-background-nested-bash.test.ts
apps/zcode-cli/packages/core/src/runtime/agent-runtime.ts
createToolExecutor(...) 传入 notification policy 和 subagent Bash timeout config。apps/zcode-cli/packages/core/src/runtime/internal.ts
AgentRuntimeInternal 字段/方法类型。apps/zcode-cli/packages/core/src/runtime/types.ts
subagents.backgroundBashMaxMs?: number。apps/zcode-cli/packages/core/src/runtime/methods/background-notifications.ts
sealBackgroundTaskNotifications(...) 和 policy 判断 helper。apps/zcode-cli/packages/core/src/runtime/methods/subagent.ts
executeTurn(...) 结束后 seal child runtime。apps/zcode-cli/packages/core/src/runtime/methods/index.ts
apps/zcode-cli/packages/core/src/tool/executor/types.ts
shouldEnqueueBackgroundTaskNotification 与 subagentBackgroundBashMaxMs deps。apps/zcode-cli/packages/core/src/tool/executor/impl.ts
apps/zcode-cli/packages/core/src/tool/executor/background-tasks.ts
stopTracking().apps/zcode-cli/packages/core/tests/runtime-tool-loop.test.ts
apps/zcode-cli/packages/core/tests/subagent-background.test.ts
packages/desktop/test/e2e/conversation-session/background/conversation-session-background.test.ts
Files:
docs/conversation-session-case-catalog.mddocs/testing/conversation-session-background-e2e-coverage-matrix.mddocs/testing/conversation-session-e2e-coverage-matrix.mdInterfaces:
Produces: 新 BG06 accepted semantic contract,供后续 tests 和实现使用。
[x] Step 1: Update BG06 catalog wording
Replace BG06 expectation with:
| BG06 | background 子 agent 内部启动 background Bash | 子 Bash 在 child runtime sealed 后完成 | subagentRuntimeBackgroundTaskCleanup | background subagent 首轮 child turn 结束后可以完成并通知 parent;child 内部 background Bash completion 只更新 child runtime task/artifact/event cleanup,不再驱动 child model turn,不回写 parent Agent output,也不补发 parent notification | accepted |
Change Nested background decision to:
| Nested background | accepted as cleanup-only child lifecycle | child runtime 内 background Bash terminal cleanup、timeout、cancel cleanup | nested Bash result 回写 parent Agent output;main/goal 等待 nested Bash | runtime-local queue 设计 + owner-scoped lifecycle 语义 |
Use this BG06 row:
| BG06 | background subagent 内启动 background Bash;subagent 首轮 child turn 已完成 | 子 Bash 完成或超时 | parent 只收到一次 Agent completion notification;child Bash terminal 不再触发 child provider request;child registry/event/artifact terminal cleanup 完成;UI 不出现 parent fake-running | core runtime tests + manual/replay E2E parent surface | planned |
Run:
rg -n "BG06|Nested background|subagentRuntimeBackgroundTaskCleanup|deferred" docs/conversation-session-case-catalog.md docs/testing/conversation-session-background-e2e-coverage-matrix.md docs/testing/conversation-session-e2e-coverage-matrix.md
Expected:
planned,但不能继续是旧 deferred 语义。Phase 0 exit criteria:
Files:
apps/zcode-cli/packages/core/src/runtime/agent-runtime.tsapps/zcode-cli/packages/core/src/runtime/internal.tsapps/zcode-cli/packages/core/src/runtime/methods/background-notifications.tsapps/zcode-cli/packages/core/src/runtime/methods/index.tsapps/zcode-cli/packages/core/src/tool/executor/types.tsapps/zcode-cli/packages/core/src/tool/executor/impl.tsapps/zcode-cli/packages/core/src/tool/executor/background-tasks.tsapps/zcode-cli/packages/core/tests/runtime-tool-loop.test.tsInterfaces:
AgentRuntime.sealBackgroundTaskNotifications(input: { reason: "subagent_terminal" | "subagent_cancelled"; traceContext?: TraceContext }): voidToolExecutorOptions.shouldEnqueueBackgroundTaskNotification?: (input: BackgroundTaskNotificationPolicyInput) => booleanBackgroundTaskNotificationPolicyInput = { taskId: string; toolName: string; status: string; runtimeScope: ToolRuntimeScope; traceContext: TraceContext }Consumes:
RuntimeTaskRegistry terminal update.enqueueBackgroundTaskNotification sync command enqueue.[x] Step 1: Write failing test for sealed subagent runtime
Add a focused test in runtime-tool-loop.test.ts:
it("does not wake a sealed subagent runtime for background Bash completion", async () => {
const sessionId = createSessionId("sealed-subagent-background-bash");
const eventStore = createTestSessionEventStore();
const sessionStore = new RecordingSessionStore();
const startedAt = new Date(0);
const completedAt = new Date(1);
let modelCallCount = 0;
let backgroundCompleted = false;
const executionPort: ExecutionPort = {
async run() {
throw new Error("run should not be called for explicit background Bash");
},
async start() {
return {
taskId: "child_bash_bg",
status: "running",
startedAt,
outputPath: "/tmp/child-bash.log",
};
},
async getBackgroundTask(taskId) {
if (!backgroundCompleted) {
return { taskId, status: "running", startedAt, outputPath: "/tmp/child-bash.log" };
}
return {
taskId,
status: "completed",
startedAt,
completedAt,
outputPath: "/tmp/child-bash.log",
result: {
status: "completed",
exitCode: 0,
stdout: { text: "done", bytes: 4, truncated: false },
stderr: { text: "", bytes: 0, truncated: false },
durationMs: 1,
timedOut: false,
cancelled: false,
startedAt,
completedAt,
},
};
},
};
const runtime = new AgentRuntime(
sessionId,
{
mode: "yolo",
taskType: "subagent_child",
workingDirectory: "/tmp/zcode-sealed-subagent-bg-bash",
},
{
...mcsCapableModelConnectionDeps(),
eventStore,
executionPort,
modelAdapter: {
async generateText(request: any) {
modelCallCount += 1;
if (modelCallCount === 1) {
return {
finishReason: "tool-calls",
model: request.model,
providerMetadata: undefined,
text: "",
toolCalls: [
{
id: "bash-bg",
name: "Bash",
input: {
command: "node long-running.js",
description: "child long task",
run_in_background: true,
},
},
],
usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 },
};
}
return {
finishReason: "stop",
model: request.model,
providerMetadata: undefined,
text: "child launched background bash",
usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 },
};
},
} as never,
sessionStore,
},
);
await runtime.executeTurn("start child background bash");
runtime.sealBackgroundTaskNotifications({ reason: "subagent_terminal" });
backgroundCompleted = true;
await waitForCondition(async () => {
const projection = await runtime.getProjection();
return projection.backgroundTasks.some(
(task) => task.taskId === "child_bash_bg" && task.status === "completed",
);
});
expect(modelCallCount).toBe(2);
const persisted = await sessionStore.messages({ sessionID: sessionId });
expect(JSON.stringify(persisted)).not.toContain("<task-notification>");
});
Expected before implementation: fails because sealed method does not exist and/or notification still wakes model.
Add private state to AgentRuntime:
private backgroundTaskNotificationsSealed = false;
private backgroundTaskNotificationSealReason?: "subagent_terminal" | "subagent_cancelled";
Add corresponding fields to AgentRuntimeInternal.
In runtime/methods/background-notifications.ts, add:
export function sealBackgroundTaskNotifications(
this: AgentRuntimeInternal,
input: {
reason: "subagent_terminal" | "subagent_cancelled";
traceContext?: TraceContext;
},
): void {
if (this.config.taskType !== "subagent_child") return;
this.backgroundTaskNotificationsSealed = true;
this.backgroundTaskNotificationSealReason = input.reason;
this.logger?.info?.("Subagent runtime background task notifications sealed", {
...traceContextToLogContext(input.traceContext ?? this.rootTraceContext),
event: "runtime.background_task_notifications.sealed",
module: "core.runtime",
reason: input.reason,
});
}
In tool/executor/types.ts, add:
export interface BackgroundTaskNotificationPolicyInput {
runtimeScope: ToolRuntimeScope;
status: string;
taskId: string;
toolName: string;
traceContext: TraceContext;
}
export type ShouldEnqueueBackgroundTaskNotification = (
input: BackgroundTaskNotificationPolicyInput,
) => boolean;
Add shouldEnqueueBackgroundTaskNotification?: ShouldEnqueueBackgroundTaskNotification to options and deps.
In agent-runtime.ts, pass:
shouldEnqueueBackgroundTaskNotification: (input) => {
if (this.config.taskType !== "subagent_child") return true;
if (!this.backgroundTaskNotificationsSealed) return true;
if (input.toolName !== "Bash") return true;
this.logger?.info?.("Suppressed sealed subagent background Bash notification", {
...traceContextToLogContext(input.traceContext),
event: "runtime.background_task_notification.suppressed",
module: "core.runtime",
reason: this.backgroundTaskNotificationSealReason,
taskId: input.taskId,
taskStatus: input.status,
toolName: input.toolName,
});
return false;
},
In BackgroundTaskTracker.maybeEnqueueBackgroundTaskNotification(...), before formatting/enqueue:
if (
this.deps.shouldEnqueueBackgroundTaskNotification?.({
runtimeScope: this.deps.runtimeScope,
status,
taskId,
toolName: toolCall.name,
traceContext,
}) === false
) {
this.deps.logger?.info?.("Background task notification suppressed by runtime policy", {
...traceContextToLogContext(traceContext),
event: "background_task.notification.suppressed",
module: "core.tool.executor",
taskId,
taskStatus: status,
toolName: toolCall.name,
});
return;
}
Do not call markRuntimeBackgroundTaskNotified(...) when policy suppresses notification.
In runtime/methods/index.ts, install:
proto.sealBackgroundTaskNotifications = sealBackgroundTaskNotifications;
Add the method to the public AgentRuntime interface if TypeScript requires childRuntime.sealBackgroundTaskNotifications(...) later.
Run:
../../node_modules/.bin/vitest run packages/core/tests/runtime-tool-loop.test.ts -t "sealed subagent runtime|background Bash"
Expected:
Phase 1 exit criteria:
Files:
apps/zcode-cli/packages/core/src/runtime/methods/subagent.tsapps/zcode-cli/packages/core/tests/subagent-background.test.tsapps/zcode-cli/packages/core/tests/runtime-tool-loop.test.tsInterfaces:
AgentRuntime.sealBackgroundTaskNotifications(...) from Phase 1.Produces: child runtime is sealed after the initial subagent turn returns or throws.
[x] Step 1: Write failing subagent integration test
Add a test that uses a real createDefaultSubagentPort path when practical:
it("seals child runtime after subagent turn completion", async () => {
// Arrange a parent runtime whose Agent tool starts a child runtime.
// Child model: first request starts Bash(run_in_background=true), then stops.
// Background Bash completion occurs after child stop.
// Assert parent receives only the Agent completion notification and child does not issue a later model request.
});
If existing harness cannot easily expose child model call counts, keep this as a runtime-tool-loop.test.ts child-runtime unit and add the direct wiring test in Phase 5 E2E.
In createDefaultSubagentPort(...).runExploreAgent, replace direct return:
return childRuntime.executeTurn(request.prompt, undefined, {
abortSignal: options?.signal,
traceContext: request.traceContext,
});
with:
try {
return await childRuntime.executeTurn(request.prompt, undefined, {
abortSignal: options?.signal,
traceContext: request.traceContext,
});
} finally {
childRuntime.sealBackgroundTaskNotifications({
reason: options?.signal?.aborted ? "subagent_cancelled" : "subagent_terminal",
traceContext: request.traceContext,
});
}
Verify no change to:
finalizeBackgroundCompletion(...)finalizeBackgroundFailure(...)enqueueParentTaskNotification(...)Parent Agent completion remains the only parent-level notification.
Run:
../../node_modules/.bin/vitest run packages/core/tests/subagent-background.test.ts packages/core/tests/runtime-tool-loop.test.ts -t "background|sealed|subagent"
Expected:
Phase 2 exit criteria:
Files:
apps/zcode-cli/packages/core/src/runtime/types.tsapps/zcode-cli/packages/core/src/runtime/agent-runtime.tsapps/zcode-cli/packages/core/src/runtime/methods/subagent.tsapps/zcode-cli/packages/core/src/tool/executor/types.tsapps/zcode-cli/packages/core/src/tool/executor/impl.tsapps/zcode-cli/packages/core/src/tool/executor/background-tasks.tsapps/zcode-cli/packages/core/tests/runtime-tool-loop.test.tsInterfaces:
AgentRuntimeConfig.subagents?.backgroundBashMaxMs?: numberToolExecutorDeps.subagentBackgroundBashMaxMs?: numberConsumes:
ExecutionPort.cancelBackgroundTask(taskId).[x] Step 1: Write failing timeout test
Add:
it("cancels subagent background Bash after the subagent max runtime", async () => {
vi.useFakeTimers();
try {
const sessionId = createSessionId("subagent-background-bash-timeout");
const eventStore = createTestSessionEventStore();
const sessionStore = new RecordingSessionStore();
const startedAt = new Date(0);
const cancelled: string[] = [];
const executionPort: ExecutionPort = {
async run() {
throw new Error("run should not be called");
},
async start() {
return { taskId: "child_bash_timeout", status: "running", startedAt };
},
async getBackgroundTask(taskId) {
return { taskId, status: "running", startedAt };
},
async cancelBackgroundTask(taskId) {
cancelled.push(taskId);
return {
taskId,
status: "cancelled",
startedAt,
completedAt: new Date(10),
};
},
};
const runtime = new AgentRuntime(
sessionId,
{
mode: "yolo",
taskType: "subagent_child",
subagents: { backgroundBashMaxMs: 10 },
workingDirectory: "/tmp/zcode-subagent-bash-timeout",
},
{
...mcsCapableModelConnectionDeps(),
eventStore,
executionPort,
modelAdapter: {
async generateText(request: any) {
modelCallCount += 1;
if (modelCallCount === 1) {
return {
finishReason: "tool-calls",
model: request.model,
providerMetadata: undefined,
text: "",
toolCalls: [
{
id: "bash-bg",
name: "Bash",
input: {
command: "node long-running.js",
description: "child long task",
run_in_background: true,
},
},
],
usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 },
};
}
return {
finishReason: "stop",
model: request.model,
providerMetadata: undefined,
text: "child launched background bash",
usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 },
};
},
} as never,
sessionStore,
},
);
await runtime.executeTurn("launch child bash");
await vi.advanceTimersByTimeAsync(10);
expect(cancelled).toEqual(["child_bash_timeout"]);
} finally {
vi.useRealTimers();
}
});
In AgentRuntimeConfig.subagents, add:
backgroundBashMaxMs?: number;
Do not expose CLI/user config in this phase unless existing runtime config plumbing requires it for tests.
In subagent.ts, when constructing child runtime:
subagents: {
enabled: false,
backgroundBashMaxMs: this.config.subagents?.backgroundBashMaxMs,
},
If undefined, child runtime uses default.
In agent-runtime.ts:
subagentBackgroundBashMaxMs:
this.config.taskType === "subagent_child"
? normalizeSubagentBackgroundBashMaxMs(this.config.subagents?.backgroundBashMaxMs)
: undefined,
Add helper:
const DEFAULT_SUBAGENT_BACKGROUND_BASH_MAX_MS = 3_600_000;
function normalizeSubagentBackgroundBashMaxMs(value: number | undefined): number {
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
return DEFAULT_SUBAGENT_BACKGROUND_BASH_MAX_MS;
}
return Math.trunc(value);
}
In trackBackgroundTask(...), after background task registration and before poll/wait:
let maxRuntimeTimer: ReturnType<typeof setTimeout> | undefined;
if (
toolCall.name === "Bash" &&
this.deps.runtimeScope === "subagent" &&
this.deps.subagentBackgroundBashMaxMs !== undefined
) {
maxRuntimeTimer = setTimeout(() => {
this.deps.logger?.warn("Subagent background Bash exceeded max runtime; cancelling", {
...traceContextToLogContext(traceContext),
event: "background_task.subagent_bash.max_runtime_exceeded",
module: "core.tool.executor",
taskId,
toolName: toolCall.name,
});
void this.deps.executionPort?.cancelBackgroundTask?.(taskId);
}, this.deps.subagentBackgroundBashMaxMs);
maxRuntimeTimer.unref?.();
}
In stopTracking():
if (maxRuntimeTimer) clearTimeout(maxRuntimeTimer);
maxRuntimeTimer = undefined;
Run:
../../node_modules/.bin/vitest run packages/core/tests/runtime-tool-loop.test.ts -t "subagent background Bash|max runtime|background Bash"
Expected:
Phase 3 exit criteria:
Files:
apps/zcode-cli/packages/core/src/runtime/methods/background.tsapps/zcode-cli/packages/core/src/runtime/methods/index.tsapps/zcode-cli/packages/core/src/runtime/internal.tsapps/zcode-cli/packages/core/src/runtime/agent-runtime.tsapps/zcode-cli/packages/core/src/runtime/methods/subagent.tsapps/zcode-cli/packages/core/tests/runtime-tool-loop.test.tsInterfaces:
AgentRuntime.cancelRunningRuntimeBackgroundTasks(input: { reason: "subagent_cancelled"; traceContext?: TraceContext }): Promise<void>Consumes:
runtimeTaskRegistry.all()executionPort.cancelBackgroundTask(taskId)[x] Step 1: Write failing cancellation test
Add:
it("cancels running subagent background Bash tasks when the subagent turn is cancelled", async () => {
const runtimeTaskRegistry = new InMemoryRuntimeTaskRegistry();
const cancelled: string[] = [];
const runtime = new AgentRuntime(
createSessionId("subagent-background-bash-cancel-cleanup"),
{ mode: "yolo", taskType: "subagent_child", workingDirectory: "/tmp/zcode-child-cancel" },
{
...mcsCapableModelConnectionDeps(),
eventStore: createTestSessionEventStore(),
executionPort: {
async run() {
throw new Error("not used");
},
async cancelBackgroundTask(taskId) {
cancelled.push(taskId);
return { taskId, status: "cancelled", startedAt: new Date(0), completedAt: new Date(1) };
},
},
modelAdapter: {
async generateText(request: any) {
return {
finishReason: "stop",
model: request.model,
providerMetadata: undefined,
text: "done",
usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 },
};
},
} as never,
runtimeTaskRegistry,
sessionStore: new RecordingSessionStore(),
},
);
runtimeTaskRegistry.register({
agentId: "child_bash_cancel",
agentType: "local_bash",
description: "child bash",
isBackgrounded: true,
startedAt: new Date(0),
status: "running",
taskId: "child_bash_cancel",
taskType: "local_bash",
type: "local_bash",
});
await runtime.cancelRunningRuntimeBackgroundTasks({
reason: "subagent_cancelled",
});
expect(cancelled).toEqual(["child_bash_cancel"]);
});
In runtime/methods/background.ts, add:
export async function cancelRunningRuntimeBackgroundTasks(
this: AgentRuntimeInternal,
input: { reason: "subagent_cancelled"; traceContext?: TraceContext },
): Promise<void> {
if (this.config.taskType !== "subagent_child") return;
const traceContext = input.traceContext ?? this.rootTraceContext;
const tasks = Object.values(this.runtimeTaskRegistry.all()).filter(
(task) =>
task.type === "local_bash" &&
task.isBackgrounded === true &&
task.status === "running",
);
for (const task of tasks) {
this.logger?.info?.("Cancelling subagent background task during runtime cleanup", {
...traceContextToLogContext(traceContext),
event: "runtime.background_task.cleanup_cancel",
module: "core.runtime",
reason: input.reason,
taskId: task.taskId,
});
await this.cancelBackgroundTask(task.taskId, { traceContext });
}
}
In subagent.ts, extend the finally from Phase 2:
const cancelled = options?.signal?.aborted === true;
try {
return await childRuntime.executeTurn(...);
} finally {
childRuntime.sealBackgroundTaskNotifications({
reason: cancelled ? "subagent_cancelled" : "subagent_terminal",
traceContext: request.traceContext,
});
if (cancelled) {
await childRuntime.cancelRunningRuntimeBackgroundTasks({
reason: "subagent_cancelled",
traceContext: request.traceContext,
});
}
}
Run:
../../node_modules/.bin/vitest run packages/core/tests/runtime-tool-loop.test.ts packages/core/tests/subagent-background.test.ts -t "cancel|background Bash|subagent"
Expected:
Phase 4 exit criteria:
Files:
packages/desktop/test/e2e/conversation-session/background/conversation-session-background.test.tspackages/desktop/test/e2e/fixtures/upstream/conversation-session/conversation-session-background.jsonpackages/desktop/test/e2e/fixtures/cases/conversation-session/conversation-session-background.jsondocs/testing/conversation-session-background-e2e-coverage-matrix.mddocs/testing/conversation-session-e2e-coverage-matrix.mdInterfaces:
Produces: replayable BG06 parent-surface proof.
[x] Step 1: Write replay E2E spec
Spec should drive:
E2E_BACKGROUND_NESTED_BASH:
1. main launches Agent(run_in_background=true)
2. child Agent starts Bash(run_in_background=true)
3. child Agent ends its first turn
4. parent receives exactly one Agent completion notification
5. child Bash later completes
6. parent does not receive a second Agent notification and does not show fake-running
Assertions:
<task-notification>.<task-notification>.<task-notification>.child model-io does not contain nested Bash <task-notification> after child runtime is sealed.
[x] Step 2: Run fixture validation
Run:
python -m json.tool packages/desktop/test/e2e/fixtures/upstream/conversation-session/conversation-session-background.json >/dev/null
python -m json.tool packages/desktop/test/e2e/fixtures/cases/conversation-session/conversation-session-background.json >/dev/null
pnpm --filter @zcode/desktop e2e:fixture:check -- --spec ./test/e2e/conversation-session/background/conversation-session-background.test.ts
Expected:
Fixture contract includes the new BG06 requests.
[x] Step 3: Reuse existing background suite instead of promotion
BG06 is part of the same accepted background surface as BG01-BG03/BG07, so it was added directly to the existing formal background replay suite instead of creating and promoting a separate manual-review spec.
Classify requests:
main: Agent launch request
main: parent Agent completion notification request
ignore: title generation
ignore or synthetic: child-internal provider requests if the spec only asserts parent surface
Case-specific responses were added only to the existing background case-local fixture.
Run:
pnpm --filter @zcode/desktop e2e:fixture:check -- --spec ./test/e2e/conversation-session/background/conversation-session-background.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 --filter @zcode/desktop exec wdio run wdio.conf.ts --spec './test/e2e/conversation-session/background/conversation-session-background.test.ts'
Expected:
Phase 5 exit criteria:
Files:
Update docs only if verification uncovers an intentional scope note.
[x] Step 1: Run core focused tests
Run:
../../node_modules/.bin/vitest run packages/core/tests/runtime-tool-loop.test.ts packages/core/tests/subagent-background.test.ts packages/core/tests/bash-handler.test.ts
Expected:
All focused core tests pass.
[x] Step 2: Run existing background E2E fixture checks
Run:
pnpm --filter @zcode/desktop e2e:fixture:check -- --spec ./test/e2e/conversation-session/background/conversation-session-background.test.ts
Expected:
Existing BG01-BG05/BG07 fixture check remains green.
[x] Step 3: Run typecheck/lint
Run:
pnpm --filter @zcode/desktop typecheck:e2e
pnpm typecheck
pnpm lint
Expected:
If unrelated existing failures appear, record exact failing command and first relevant error.
[x] Step 4: Provider-visible keyword scan
Run:
python - <<'PY'
from pathlib import Path
import subprocess
import sys
paths = subprocess.check_output(
[
"git",
"diff",
"--name-only",
"--",
"apps/zcode-cli/packages/core/src",
"apps/zcode-cli/packages/adapters/src",
"packages/desktop/test/e2e",
"docs/conversation-session-case-catalog.md",
"docs/testing/conversation-session-background-e2e-coverage-matrix.md",
"docs/testing/conversation-session-e2e-coverage-matrix.md",
],
text=True,
).splitlines()
# 用 char code 构造禁用词,避免本计划文件自身包含禁用字面量。
terms = [
"".join(map(chr, [67, 76, 65, 85, 68, 69])),
"".join(map(chr, [67, 108, 97, 117, 100, 101])),
"".join(map(chr, [99, 108, 97, 117, 100, 101])),
]
matches = []
for item in paths:
path = Path(item)
if not path.is_file():
continue
text = path.read_text(errors="ignore")
for line_number, line in enumerate(text.splitlines(), 1):
if any(term in line for term in terms):
matches.append(f"{item}:{line_number}:{line}")
if matches:
print("\n".join(matches))
sys.exit(1)
PY
Expected:
Phase 6 exit criteria:
notified: true.runtimeScope === "subagent" and Bash.