conversation-session-context-window-cold-resume.json 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. {
  2. "version": 1,
  3. "caseName": "conversation-session-context-window-cold-resume",
  4. "spec": "./test/e2e/conversation-session/context/conversation-session-context-window-cold-resume.test.ts",
  5. "fixtures": [
  6. {
  7. "id": "cw-create-history",
  8. "description": "真实创建 1M 目标会话并持久化一轮正文。",
  9. "metadata": {
  10. "kind": "main",
  11. "timingPolicy": "fast-text",
  12. "source": "synthetic",
  13. "syntheticReason": "通过真实 UI 请求创建目标会话,替代直接写 sqlite 的伪冷历史。"
  14. },
  15. "maxMatches": 1,
  16. "match": {
  17. "method": "POST",
  18. "pathIncludes": "/chat/completions",
  19. "lastUserMessageIncludes": ["E2E_CW_CREATE_HISTORY"],
  20. "bodyIncludes": ["E2E_CW_CREATE_HISTORY", "\"max_completion_tokens\":64000", "model-1m"],
  21. "bodyExcludes": ["Generate a concise title", "create a detailed summary"]
  22. },
  23. "response": {
  24. "statusCode": 200,
  25. "statusMessage": "OK",
  26. "headers": {
  27. "content-type": "text/event-stream; charset=utf-8"
  28. },
  29. "body": "data: {\"id\":\"chatcmpl-cw-create-history\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-cw-create-history\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"cw-history-created-ok\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-cw-create-history\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}],\"usage\":{\"prompt_tokens\":42,\"completion_tokens\":4,\"total_tokens\":46}}\n\ndata: [DONE]\n\n"
  30. }
  31. },
  32. {
  33. "id": "cw-create-parking",
  34. "description": "真实创建第二个 parking 会话并保持其为重启时选中项。",
  35. "metadata": {
  36. "kind": "main",
  37. "timingPolicy": "fast-text",
  38. "source": "synthetic",
  39. "syntheticReason": "确保目标会话在重启后首次点击前仍未被 Agent 恢复。"
  40. },
  41. "maxMatches": 1,
  42. "match": {
  43. "method": "POST",
  44. "pathIncludes": "/chat/completions",
  45. "lastUserMessageIncludes": ["E2E_CW_PARKING"],
  46. "bodyIncludes": ["E2E_CW_PARKING", "\"max_completion_tokens\":64000", "model-1m"],
  47. "bodyExcludes": ["Generate a concise title", "create a detailed summary"]
  48. },
  49. "response": {
  50. "statusCode": 200,
  51. "statusMessage": "OK",
  52. "headers": {
  53. "content-type": "text/event-stream; charset=utf-8"
  54. },
  55. "body": "data: {\"id\":\"chatcmpl-cw-create-parking\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-cw-create-parking\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"cw-parking-ok\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-cw-create-parking\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}],\"usage\":{\"prompt_tokens\":24,\"completion_tokens\":4,\"total_tokens\":28}}\n\ndata: [DONE]\n\n"
  56. }
  57. },
  58. {
  59. "id": "cw-high-usage-tool-call",
  60. "description": "1M 模型首轮返回 157762 provider input usage 和 readonly Bash(pwd) 工具调用。",
  61. "metadata": {
  62. "kind": "main",
  63. "timingPolicy": "fast-text",
  64. "source": "synthetic",
  65. "syntheticReason": "确定性复现用户日志中的 157762 provider usage,无需生成真实 15 万 token 历史。"
  66. },
  67. "maxMatches": 1,
  68. "match": {
  69. "method": "POST",
  70. "pathIncludes": "/chat/completions",
  71. "lastUserMessageIncludes": ["E2E_CW_HIGH_USAGE_TOOL"],
  72. "bodyIncludes": ["E2E_CW_HIGH_USAGE_TOOL", "\"max_completion_tokens\":64000", "model-1m"],
  73. "bodyExcludes": ["call_cw_pwd", "Generate a concise title", "create a detailed summary"]
  74. },
  75. "response": {
  76. "statusCode": 200,
  77. "statusMessage": "OK",
  78. "headers": {
  79. "content-type": "text/event-stream; charset=utf-8"
  80. },
  81. "body": "data: {\"id\":\"chatcmpl-cw-tool\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-cw-tool\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{\"tool_calls\":[{\"index\":0,\"id\":\"call_cw_pwd\",\"type\":\"function\",\"function\":{\"name\":\"Bash\",\"arguments\":\"{\\\"command\\\":\\\"pwd\\\",\\\"description\\\":\\\"Read current workspace path\\\"}\"}}]},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-cw-tool\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"tool_calls\"}],\"usage\":{\"prompt_tokens\":157762,\"completion_tokens\":0,\"total_tokens\":157762}}\n\ndata: [DONE]\n\n"
  82. }
  83. },
  84. {
  85. "id": "cw-tool-result-followup",
  86. "description": "Bash tool_result 后直接进入同一 product turn 的第二个 main_turn。由 bodyIncludes 的标记 + call_cw_pwd 与 maxMatches 唯一定位,不依赖最后一条 user 消息的内容(token 预算提醒打开时,tool batch 后的请求末尾会多一条提醒 user 消息,见 apps/zcode-cli/docs/design/v2/loop/meta-user-context.md)。",
  87. "metadata": {
  88. "kind": "main",
  89. "timingPolicy": "fast-text",
  90. "source": "synthetic",
  91. "syntheticReason": "稳定证明高 usage 后没有错误插入 Compact,而是直接消费 readonly tool result。"
  92. },
  93. "maxMatches": 1,
  94. "match": {
  95. "method": "POST",
  96. "pathIncludes": "/chat/completions",
  97. "bodyIncludes": [
  98. "E2E_CW_HIGH_USAGE_TOOL",
  99. "call_cw_pwd",
  100. "\"max_completion_tokens\":64000",
  101. "model-1m"
  102. ],
  103. "bodyExcludes": ["Generate a concise title", "create a detailed summary"]
  104. },
  105. "response": {
  106. "statusCode": 200,
  107. "statusMessage": "OK",
  108. "headers": {
  109. "content-type": "text/event-stream; charset=utf-8"
  110. },
  111. "body": "data: {\"id\":\"chatcmpl-cw-tool-followup\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-cw-tool-followup\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"cw-tool-followup-ok\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-cw-tool-followup\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}],\"usage\":{\"prompt_tokens\":157900,\"completion_tokens\":8,\"total_tokens\":157908}}\n\ndata: [DONE]\n\n"
  112. }
  113. },
  114. {
  115. "id": "cw-literal-continue",
  116. "description": "用户在同一冷恢复 session 输入字面量“继续”后直接进入第三个 main_turn。",
  117. "metadata": {
  118. "kind": "main",
  119. "timingPolicy": "fast-text",
  120. "source": "synthetic",
  121. "syntheticReason": "复现用户日志中的“继续”恢复链路,并让任何意外 Compact 因无 fixture 而 fail-closed。"
  122. },
  123. "maxMatches": 1,
  124. "match": {
  125. "method": "POST",
  126. "pathIncludes": "/chat/completions",
  127. "lastUserMessageIncludes": ["继续"],
  128. "bodyIncludes": [
  129. "E2E_CW_HIGH_USAGE_TOOL",
  130. "继续",
  131. "\"max_completion_tokens\":64000",
  132. "model-1m"
  133. ],
  134. "bodyExcludes": ["Generate a concise title", "create a detailed summary"]
  135. },
  136. "response": {
  137. "statusCode": 200,
  138. "statusMessage": "OK",
  139. "headers": {
  140. "content-type": "text/event-stream; charset=utf-8"
  141. },
  142. "body": "data: {\"id\":\"chatcmpl-cw-continue\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-cw-continue\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"cw-continue-ok\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-cw-continue\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}],\"usage\":{\"prompt_tokens\":158000,\"completion_tokens\":8,\"total_tokens\":158008}}\n\ndata: [DONE]\n\n"
  143. }
  144. },
  145. {
  146. "id": "cw-manual-compact-summary",
  147. "description": "CW04 手动 compact 返回固定 summary,供热态与冷恢复 usage 水位对比。",
  148. "metadata": {
  149. "kind": "main",
  150. "timingPolicy": "fast-text",
  151. "source": "synthetic",
  152. "syntheticReason": "固定 compact summary 并保留高 provider usage,使 CW04 可确定性验证冷恢复读取压缩后 boundary,而不是压缩前 assistant usage。"
  153. },
  154. "maxMatches": 1,
  155. "match": {
  156. "method": "POST",
  157. "pathIncludes": "/chat/completions",
  158. "bodyIncludes": [
  159. "E2E_CW_HIGH_USAGE_TOOL",
  160. "cw-continue-ok",
  161. "CRITICAL: Respond with TEXT ONLY",
  162. "\"stream\":true",
  163. "model-1m"
  164. ],
  165. "bodyExcludes": ["Generate a concise title"]
  166. },
  167. "response": {
  168. "statusCode": 200,
  169. "statusMessage": "OK",
  170. "headers": {
  171. "content-type": "text/event-stream; charset=utf-8"
  172. },
  173. "body": "data: {\"id\":\"chatcmpl-cw-manual-compact\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-cw-manual-compact\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"<summary>CW04 compacted the target session after a high-usage tool turn and a literal continue turn. No further business turn followed the compact operation.</summary>\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-cw-manual-compact\",\"object\":\"chat.completion.chunk\",\"created\":0,\"model\":\"model-1m\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}],\"usage\":{\"prompt_tokens\":180000,\"completion_tokens\":64,\"total_tokens\":180064}}\n\ndata: [DONE]\n\n"
  174. }
  175. }
  176. ]
  177. }