{ "version": 1, "caseName": "conversation-session-runtime-restart", "spec": "./test/e2e/conversation-session/runtime/conversation-session-runtime-restart.test.ts", "fixtures": [ { "id": "browser-ambient-next", "metadata": { "kind": "main", "source": "synthetic", "timingPolicy": "fast-text", "syntheticReason": "验证未释放的 Agent 页面在下一轮真实 provider 请求中有 ambient 页数和 URL,不依赖模型判断。" }, "match": { "method": "POST", "pathIncludes": "/messages", "bodyExcludes": ["Generate a concise title"], "lastUserMessageIncludes": ["E2E_BROWSER_AMBIENT_NEXT:"] }, "response": { "statusCode": 200, "text": { "id": "browser-ambient-next", "text": "E2E_BROWSER_AMBIENT_NEXT_DONE" } } }, { "id": "browser-restart-after-ack", "metadata": { "kind": "main", "source": "synthetic", "timingPolicy": "fast-text", "syntheticReason": "真实 BrowserControl 与 Electron 网页跨桌面/手机重启保留,固定模型输出验证同页续用。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "bodyExcludes": ["Generate a concise title"], "lastUserMessageIncludes": ["E2E_BROWSER_RESTART_AFTER_OK"] }, "response": { "statusCode": 200, "text": "E2E_BROWSER_RESTART_AFTER_DONE" } }, { "id": "browser-restart-after-tool", "metadata": { "kind": "main", "source": "synthetic", "timingPolicy": "fast-tool-use", "syntheticReason": "真实 BrowserControl 与 Electron 网页跨桌面/手机重启保留,固定模型输出验证同页续用。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "bodyExcludes": ["Generate a concise title"], "lastUserMessageIncludes": ["E2E_BROWSER_RESTART_AFTER:"] }, "response": { "statusCode": 200, "toolUse": { "id": "toolu_after_browser_restart", "name": "mcp__node_repl__js", "input": { "title": "验证任务重启后的浏览器控制", "code": "const pluginRoot = process.env.ZCODE_PLUGIN_ROOT;\nif (!pluginRoot) throw new Error('Browser plugin root unavailable');\nconst { join } = await import('node:path');\nconst { pathToFileURL } = await import('node:url');\nconst { setupBrowserRuntime } = await import(pathToFileURL(join(pluginRoot, 'scripts', 'browser-client.mjs')).href);\nawait setupBrowserRuntime({ globals: globalThis });\nconst browser = await agent.browsers.get('iab');\nconst tabs = await browser.tabs.list();\nconst existing = tabs.find((tab) => tab.url === '{{browserFixtureUrl}}');\nconst userTab = existing ? undefined : (await browser.user.openTabs()).find((tab) => tab.url === '{{browserFixtureUrl}}');\nconst tab = existing ? await browser.tabs.get(existing.id) : userTab ? await browser.user.claimTab(userTab) : await browser.tabs.new();\nif (!existing && !userTab) await tab.goto('{{browserFixtureUrl}}');\nawait tab.playwright.getByLabel('State').fill('after');\n({ marker: 'E2E_BROWSER_RESTART_AFTER_OK', tabId: tab.id });" } } } }, { "id": "browser-restart-mobile-ack", "metadata": { "kind": "main", "source": "synthetic", "timingPolicy": "fast-text", "syntheticReason": "真实 BrowserControl 与 Electron 网页跨桌面/手机重启保留,固定模型输出验证同页续用。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "bodyExcludes": ["Generate a concise title"], "lastUserMessageIncludes": ["E2E_BROWSER_RESTART_MOBILE_OK"] }, "response": { "statusCode": 200, "text": "E2E_BROWSER_RESTART_MOBILE_DONE" } }, { "id": "browser-restart-mobile-tool", "metadata": { "kind": "main", "source": "synthetic", "timingPolicy": "fast-tool-use", "syntheticReason": "真实 BrowserControl 与 Electron 网页跨桌面/手机重启保留,固定模型输出验证同页续用。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "bodyExcludes": ["Generate a concise title"], "lastUserMessageIncludes": ["E2E_BROWSER_RESTART_MOBILE:"] }, "response": { "statusCode": 200, "toolUse": { "id": "toolu_mobile_browser_restart", "name": "mcp__node_repl__js", "input": { "title": "验证任务重启后的浏览器控制", "code": "const pluginRoot = process.env.ZCODE_PLUGIN_ROOT;\nif (!pluginRoot) throw new Error('Browser plugin root unavailable');\nconst { join } = await import('node:path');\nconst { pathToFileURL } = await import('node:url');\nconst { setupBrowserRuntime } = await import(pathToFileURL(join(pluginRoot, 'scripts', 'browser-client.mjs')).href);\nawait setupBrowserRuntime({ globals: globalThis });\nconst browser = await agent.browsers.get('iab');\nconst tabs = await browser.tabs.list();\nconst existing = tabs.find((tab) => tab.url === '{{browserFixtureUrl}}');\nconst userTab = existing ? undefined : (await browser.user.openTabs()).find((tab) => tab.url === '{{browserFixtureUrl}}');\nconst tab = existing ? await browser.tabs.get(existing.id) : userTab ? await browser.user.claimTab(userTab) : await browser.tabs.new();\nif (!existing && !userTab) await tab.goto('{{browserFixtureUrl}}');\nawait tab.playwright.getByLabel('State').fill('mobile');\n({ marker: 'E2E_BROWSER_RESTART_MOBILE_OK', tabId: tab.id });" } } } }, { "id": "browser-restart-desktop-ack", "metadata": { "kind": "main", "source": "synthetic", "timingPolicy": "fast-text", "syntheticReason": "真实 BrowserControl 与 Electron 网页跨桌面/手机重启保留,固定模型输出验证同页续用。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "bodyExcludes": ["Generate a concise title"], "lastUserMessageIncludes": ["E2E_BROWSER_RESTART_DESKTOP_OK"] }, "response": { "statusCode": 200, "text": "E2E_BROWSER_RESTART_DESKTOP_DONE" } }, { "id": "browser-restart-desktop-tool", "metadata": { "kind": "main", "source": "synthetic", "timingPolicy": "fast-tool-use", "syntheticReason": "真实 BrowserControl 与 Electron 网页跨桌面/手机重启保留,固定模型输出验证同页续用。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "bodyExcludes": ["Generate a concise title"], "lastUserMessageIncludes": ["E2E_BROWSER_RESTART_DESKTOP:"] }, "response": { "statusCode": 200, "toolUse": { "id": "toolu_desktop_browser_restart", "name": "mcp__node_repl__js", "input": { "title": "验证任务重启后的浏览器控制", "code": "const pluginRoot = process.env.ZCODE_PLUGIN_ROOT;\nif (!pluginRoot) throw new Error('Browser plugin root unavailable');\nconst { join } = await import('node:path');\nconst { pathToFileURL } = await import('node:url');\nconst { setupBrowserRuntime } = await import(pathToFileURL(join(pluginRoot, 'scripts', 'browser-client.mjs')).href);\nawait setupBrowserRuntime({ globals: globalThis });\nconst browser = await agent.browsers.get('iab');\nconst tabs = await browser.tabs.list();\nconst existing = tabs.find((tab) => tab.url === '{{browserFixtureUrl}}');\nconst userTab = existing ? undefined : (await browser.user.openTabs()).find((tab) => tab.url === '{{browserFixtureUrl}}');\nconst tab = existing ? await browser.tabs.get(existing.id) : userTab ? await browser.user.claimTab(userTab) : await browser.tabs.new();\nif (!existing && !userTab) await tab.goto('{{browserFixtureUrl}}');\nawait tab.playwright.getByLabel('State').fill('desktop');\n({ marker: 'E2E_BROWSER_RESTART_DESKTOP_OK', tabId: tab.id });" } } } }, { "id": "conversation-session-stop-empty-title-sidecar", "description": "标题旁路取消窗口。", "metadata": { "kind": "common", "source": "synthetic", "timingPolicy": "controlled-stream", "syntheticReason": "延迟标题旁路响应,按实际 pending 请求确认重启发生在标题生成期间,验证关闭会取消旁路而非等待自然完成。" }, "match": { "method": "POST", "pathIncludes": "/messages", "bodyIncludes": ["Generate a concise title"] }, "response": { "statusCode": 200, "statusMessage": "OK", "headers": { "content-type": "application/json; charset=utf-8" }, "body": "{\"id\":\"upstream-e2e-title-fixture\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[{\"type\":\"text\",\"text\":\"{\\\"title\\\":\\\"Upstream E2E Fixture\\\"}\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":125,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":24,\"service_tier\":\"standard\"}}", "delayMs": 45000 } }, { "id": "owned-restart-desktop-launch", "metadata": { "kind": "main", "source": "synthetic", "timingPolicy": "fast-tool-use", "syntheticReason": "通过真实后台 Agent 和受控流验证父 session 重启会关闭所属工作。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "lastUserMessageIncludes": ["E2E_OWNED_RESTART_DESKTOP:"], "bodyExcludes": ["Generate a concise title"] }, "response": { "statusCode": 200, "toolUse": { "id": "toolu_owned_desktop", "name": "Agent", "input": { "description": "Owned restart DESKTOP", "prompt": "E2E_OWNED_RESTART_DESKTOP_CHILD: keep streaming until cancelled.", "subagent_type": "general-purpose", "run_in_background": true } } } }, { "id": "owned-restart-desktop-ack", "metadata": { "kind": "main", "source": "synthetic", "timingPolicy": "fast-text", "syntheticReason": "通过真实后台 Agent 和受控流验证父 session 重启会关闭所属工作。" }, "match": { "method": "POST", "pathIncludes": "/messages", "bodyIncludes": ["E2E_OWNED_RESTART_DESKTOP", "Async agent launched successfully"], "bodyExcludes": ["Generate a concise title"], "lastUserMessageExcludes": ["", "_NEXT"], "lastUserMessageIncludes": ["Async agent launched successfully"] }, "response": { "statusCode": 200, "text": { "id": "owned-ack-desktop", "text": "background agent launched" } }, "maxMatches": 1 }, { "id": "owned-restart-desktop-child", "description": "通过受控慢流验证运行中重启与排队输入结算。", "metadata": { "kind": "subagent", "source": "synthetic", "timingPolicy": "controlled-stream", "syntheticReason": "子代理保持真实在飞请求,父 turn 已结束时由用户重启取消。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "lastUserMessageIncludes": ["E2E_OWNED_RESTART_DESKTOP_CHILD:"], "bodyExcludes": ["Generate a concise title"] }, "response": { "statusCode": 200, "statusMessage": "OK", "headers": { "cache-control": "no-cache", "content-type": "text/event-stream; charset=utf-8" }, "events": [ { "sequence": 0, "offsetMs": 0, "text": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"upstream-e2e-stop-empty-running-slow-stream\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":120,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":0,\"service_tier\":\"standard\"}}}\n\n" }, { "sequence": 1, "offsetMs": 250, "text": "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\n" }, { "sequence": 2, "offsetMs": 700, "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"deep\"}}\n\n" }, { "sequence": 3, "offsetMs": 60000, "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"seek-e2e-ok\"}}\n\n" }, { "sequence": 4, "offsetMs": 60100, "text": "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\n" }, { "sequence": 5, "offsetMs": 60200, "text": "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":120,\"output_tokens\":12,\"service_tier\":\"standard\"}}\n\n" }, { "sequence": 6, "offsetMs": 60300, "text": "event: message_stop\ndata: {\"type\":\"message_stop\"}\n\n" } ] } }, { "id": "owned-restart-mobile-launch", "metadata": { "kind": "main", "source": "synthetic", "timingPolicy": "fast-tool-use", "syntheticReason": "通过真实后台 Agent 和受控流验证父 session 重启会关闭所属工作。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "lastUserMessageIncludes": ["E2E_OWNED_RESTART_MOBILE:"], "bodyExcludes": ["Generate a concise title"] }, "response": { "statusCode": 200, "toolUse": { "id": "toolu_owned_mobile", "name": "Agent", "input": { "description": "Owned restart MOBILE", "prompt": "E2E_OWNED_RESTART_MOBILE_CHILD: keep streaming until cancelled.", "subagent_type": "general-purpose", "run_in_background": true } } } }, { "id": "owned-restart-mobile-ack", "metadata": { "kind": "main", "source": "synthetic", "timingPolicy": "fast-text", "syntheticReason": "通过真实后台 Agent 和受控流验证父 session 重启会关闭所属工作。" }, "match": { "method": "POST", "pathIncludes": "/messages", "bodyIncludes": ["E2E_OWNED_RESTART_MOBILE", "Async agent launched successfully"], "bodyExcludes": ["Generate a concise title"], "lastUserMessageExcludes": ["", "_NEXT"], "lastUserMessageIncludes": ["Async agent launched successfully"] }, "response": { "statusCode": 200, "text": { "id": "owned-ack-mobile", "text": "background agent launched" } }, "maxMatches": 1 }, { "id": "owned-restart-mobile-child", "description": "通过受控慢流验证运行中重启与排队输入结算。", "metadata": { "kind": "subagent", "source": "synthetic", "timingPolicy": "controlled-stream", "syntheticReason": "子代理保持真实在飞请求,父 turn 已结束时由用户重启取消。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "lastUserMessageIncludes": ["E2E_OWNED_RESTART_MOBILE_CHILD:"], "bodyExcludes": ["Generate a concise title"] }, "response": { "statusCode": 200, "statusMessage": "OK", "headers": { "cache-control": "no-cache", "content-type": "text/event-stream; charset=utf-8" }, "events": [ { "sequence": 0, "offsetMs": 0, "text": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"upstream-e2e-stop-empty-running-slow-stream\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":120,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":0,\"service_tier\":\"standard\"}}}\n\n" }, { "sequence": 1, "offsetMs": 250, "text": "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\n" }, { "sequence": 2, "offsetMs": 700, "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"deep\"}}\n\n" }, { "sequence": 3, "offsetMs": 60000, "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"seek-e2e-ok\"}}\n\n" }, { "sequence": 4, "offsetMs": 60100, "text": "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\n" }, { "sequence": 5, "offsetMs": 60200, "text": "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":120,\"output_tokens\":12,\"service_tier\":\"standard\"}}\n\n" }, { "sequence": 6, "offsetMs": 60300, "text": "event: message_stop\ndata: {\"type\":\"message_stop\"}\n\n" } ] } }, { "id": "session-runtime-restart-next", "description": "中断后的最后 user message 可合并上轮未完成正文,按续发标记匹配。", "metadata": { "kind": "main", "timingPolicy": "fast-text", "source": "synthetic", "syntheticReason": "只验证运行实例重建与历史恢复,固定文本排除模型变化。" }, "match": { "method": "POST", "pathIncludes": "/messages", "bodyIncludes": ["E2E_SESSION_RESTART_"], "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"], "lastUserMessageIncludes": ["E2E_SESSION_RESTART_", "_NEXT"] }, "response": { "statusCode": 200, "text": { "id": "upstream-e2e-stop-empty-next", "inputTokens": 128, "outputTokens": 12, "text": "upstream-e2e-ok" } } }, { "id": "session-runtime-restart-running", "description": "通过受控慢流验证运行中重启与排队输入结算。", "metadata": { "kind": "main", "timingPolicy": "controlled-stream", "source": "synthetic", "syntheticReason": "重启必须发生在生成窗口内,固定流避免模型速度改变状态前置。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "bodyIncludes": ["E2E_SESSION_RESTART_RUNNING"], "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"], "lastUserMessageIncludes": ["E2E_SESSION_RESTART_RUNNING"] }, "response": { "statusCode": 200, "statusMessage": "OK", "headers": { "cache-control": "no-cache", "content-type": "text/event-stream; charset=utf-8" }, "events": [ { "sequence": 0, "offsetMs": 0, "text": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"upstream-e2e-stop-empty-running-slow-stream\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":120,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":0,\"service_tier\":\"standard\"}}}\n\n" }, { "sequence": 1, "offsetMs": 250, "text": "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\n" }, { "sequence": 2, "offsetMs": 700, "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"deep\"}}\n\n" }, { "sequence": 3, "offsetMs": 60000, "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"seek-e2e-ok\"}}\n\n" }, { "sequence": 4, "offsetMs": 60100, "text": "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\n" }, { "sequence": 5, "offsetMs": 60200, "text": "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":120,\"output_tokens\":12,\"service_tier\":\"standard\"}}\n\n" }, { "sequence": 6, "offsetMs": 60300, "text": "event: message_stop\ndata: {\"type\":\"message_stop\"}\n\n" } ] } }, { "id": "session-runtime-restart-text", "description": "单任务重启前后用固定回复验证消息传输,不评价模型。", "metadata": { "kind": "main", "timingPolicy": "fast-text", "source": "synthetic", "syntheticReason": "只验证运行实例重建与历史恢复,固定文本排除模型变化。" }, "match": { "method": "POST", "pathIncludes": "/messages", "bodyIncludes": ["E2E_SESSION_RESTART_"], "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"], "lastUserMessageIncludes": ["E2E_SESSION_RESTART_"], "lastUserMessageExcludes": ["E2E_SESSION_RESTART_RUNNING"] }, "response": { "statusCode": 200, "text": { "id": "upstream-e2e-stop-empty-next", "inputTokens": 128, "outputTokens": 12, "text": "upstream-e2e-ok" } } } ] }