conversation-session-activity-subagent-retention.json 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. {
  2. "version": 1,
  3. "caseName": "conversation-session-activity-subagent-retention",
  4. "spec": "./test/e2e/conversation-session/subagents/conversation-session-activity-subagent-retention.test.ts",
  5. "fixtures": [
  6. {
  7. "id": "activity-rewind-edit-controlled",
  8. "description": "编辑后新响应受控结算",
  9. "metadata": {
  10. "kind": "main",
  11. "timingPolicy": "controlled-stream",
  12. "source": "synthetic",
  13. "syntheticReason": "隔离本次编辑响应,证明旧回复不能满足完成屏障;放行后再核对在线及重启计数。"
  14. },
  15. "maxMatches": 1,
  16. "match": {
  17. "method": "POST",
  18. "pathIncludes": "/messages",
  19. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"],
  20. "lastUserMessageIncludes": ["E2E_ACTIVITY_REWIND_EDITED"]
  21. },
  22. "response": {
  23. "statusCode": 200,
  24. "headers": {
  25. "content-type": "text/event-stream; charset=utf-8"
  26. },
  27. "releaseAfterChunks": 3,
  28. "chunks": [
  29. {
  30. "text": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"upstream-e2e-activity-rewind\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":32,\"output_tokens\":0}}}\n\n"
  31. },
  32. {
  33. "text": "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\n"
  34. },
  35. {
  36. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_ACTIVITY_REWIND_RUNNING\"}}\n\n"
  37. },
  38. {
  39. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_ACTIVITY_REWIND_DONE\"}}\n\n"
  40. },
  41. {
  42. "text": "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\n"
  43. },
  44. {
  45. "text": "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"output_tokens\":12}}\n\n"
  46. },
  47. {
  48. "text": "event: message_stop\ndata: {\"type\":\"message_stop\"}\n\n"
  49. }
  50. ]
  51. }
  52. },
  53. {
  54. "id": "activity-subagent-clear",
  55. "description": "成功接纳后清除摘要",
  56. "metadata": {
  57. "kind": "main",
  58. "timingPolicy": "fast-text",
  59. "source": "synthetic",
  60. "syntheticReason": "固定清除后的普通响应,不替代发送接纳。"
  61. },
  62. "match": {
  63. "method": "POST",
  64. "pathIncludes": "/messages",
  65. "lastUserMessageIncludes": [
  66. "E2E_ACTIVITY_SUBAGENT_CLEAR"
  67. ],
  68. "bodyExcludes": [
  69. "Generate a concise title",
  70. "CRITICAL: Respond with TEXT ONLY"
  71. ]
  72. },
  73. "response": {
  74. "statusCode": 200,
  75. "text": {
  76. "id": "subagent-clear",
  77. "inputTokens": 32,
  78. "text": "E2E_ACTIVITY_SUBAGENT_CLEARED"
  79. }
  80. }
  81. },
  82. {
  83. "id": "activity-resume-tool",
  84. "description": "恢复原 Subagent",
  85. "metadata": {
  86. "kind": "main",
  87. "timingPolicy": "fast-text",
  88. "source": "synthetic",
  89. "syntheticReason": "从真实 tool_result 读取 agentId 后恢复同一 Subagent,验证清除边界不误隐藏新结果。"
  90. },
  91. "maxMatches": 1,
  92. "match": {
  93. "method": "POST",
  94. "pathIncludes": "/messages",
  95. "bodyExcludes": [
  96. "Generate a concise title",
  97. "CRITICAL: Respond with TEXT ONLY"
  98. ],
  99. "lastUserMessageIncludes": [
  100. "E2E_ACTIVITY_RESUME_START"
  101. ]
  102. },
  103. "response": {
  104. "statusCode": 200,
  105. "toolUse": {
  106. "id": "toolu_activity_resume",
  107. "name": "SendMessage",
  108. "inputTokens": 32,
  109. "input": {
  110. "to": "{{latestAgentId}}",
  111. "summary": "resume completed inspection",
  112. "message": "E2E_ACTIVITY_RESUME_CHILD"
  113. }
  114. }
  115. }
  116. },
  117. {
  118. "id": "activity-resume-child",
  119. "description": "同一 child 的新结果",
  120. "metadata": {
  121. "kind": "main",
  122. "timingPolicy": "controlled-stream",
  123. "source": "synthetic",
  124. "syntheticReason": "从真实 tool_result 读取 agentId 后恢复同一 Subagent,验证清除边界不误隐藏新结果。"
  125. },
  126. "maxMatches": 1,
  127. "match": {
  128. "method": "POST",
  129. "pathIncludes": "/messages",
  130. "bodyExcludes": [
  131. "Generate a concise title",
  132. "CRITICAL: Respond with TEXT ONLY"
  133. ],
  134. "lastUserMessageIncludes": [
  135. "E2E_ACTIVITY_RESUME_CHILD"
  136. ]
  137. },
  138. "response": {
  139. "statusCode": 200,
  140. "headers": {
  141. "content-type": "text/event-stream; charset=utf-8"
  142. },
  143. "releaseAfterChunks": 3,
  144. "chunks": [
  145. {
  146. "text": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"upstream-e2e-capsule-keep\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":32,\"output_tokens\":0}}}\n\n"
  147. },
  148. {
  149. "text": "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\n"
  150. },
  151. {
  152. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_ACTIVITY_RESUME_RUNNING\"}}\n\n"
  153. },
  154. {
  155. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_ACTIVITY_RESUME_NEW_RESULT\"}}\n\n"
  156. },
  157. {
  158. "text": "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\n"
  159. },
  160. {
  161. "text": "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"output_tokens\":12}}\n\n"
  162. },
  163. {
  164. "text": "event: message_stop\ndata: {\"type\":\"message_stop\"}\n\n"
  165. }
  166. ]
  167. }
  168. },
  169. {
  170. "id": "activity-resume-final",
  171. "description": "恢复后父回复",
  172. "metadata": {
  173. "kind": "main",
  174. "timingPolicy": "fast-text",
  175. "source": "synthetic",
  176. "syntheticReason": "从真实 tool_result 读取 agentId 后恢复同一 Subagent,验证清除边界不误隐藏新结果。"
  177. },
  178. "match": {
  179. "method": "POST",
  180. "pathIncludes": "/messages",
  181. "bodyExcludes": [
  182. "Generate a concise title",
  183. "CRITICAL: Respond with TEXT ONLY"
  184. ],
  185. "bodyIncludes": [
  186. "E2E_ACTIVITY_RESUME_START",
  187. "toolu_activity_resume"
  188. ]
  189. },
  190. "response": {
  191. "statusCode": 200,
  192. "text": "E2E_ACTIVITY_RESUME_ACK"
  193. }
  194. },
  195. {
  196. "id": "capsule-foreground-title",
  197. "description": "隔离标题请求。",
  198. "metadata": {
  199. "kind": "common",
  200. "timingPolicy": "fast-text",
  201. "source": "synthetic",
  202. "syntheticReason": "标题不是 SAT12 的停止语义,固定响应确保 replay 可复现。"
  203. },
  204. "maxMatches": 1,
  205. "match": {
  206. "method": "POST",
  207. "pathIncludes": "/messages",
  208. "bodyIncludes": [
  209. "Generate a concise title",
  210. "E2E_CAPSULE_FOREGROUND_STOP"
  211. ]
  212. },
  213. "response": {
  214. "statusCode": 200,
  215. "statusMessage": "OK",
  216. "headers": {
  217. "content-type": "application/json; charset=utf-8"
  218. },
  219. "body": "{\"id\":\"upstream-e2e-capsule-title\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[{\"type\":\"text\",\"text\":\"{\\\"title\\\":\\\"Capsule foreground stop\\\"}\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":32,\"output_tokens\":12}}"
  220. }
  221. },
  222. {
  223. "id": "capsule-foreground-parent-launch",
  224. "description": "同一父回复并行发起两个前台 Agent。",
  225. "metadata": {
  226. "kind": "main",
  227. "timingPolicy": "fast-tool-use",
  228. "source": "synthetic",
  229. "syntheticReason": "固定两个并行 foreground child,验证只停止用户选择的执行。"
  230. },
  231. "maxMatches": 1,
  232. "match": {
  233. "method": "POST",
  234. "pathIncludes": "/messages",
  235. "lastUserMessageIncludes": [
  236. "E2E_CAPSULE_FOREGROUND_STOP"
  237. ],
  238. "bodyExcludes": [
  239. "Generate a concise title",
  240. "CRITICAL: Respond with TEXT ONLY"
  241. ]
  242. },
  243. "response": {
  244. "statusCode": 200,
  245. "toolUses": [
  246. {
  247. "id": "toolu_e2e_capsule_foreground_stop",
  248. "name": "Agent",
  249. "input": {
  250. "description": "Stop target foreground child",
  251. "prompt": "E2E_CAPSULE_STOP_CHILD: wait for the controlled result.",
  252. "run_in_background": false,
  253. "subagent_type": "general-purpose"
  254. }
  255. },
  256. {
  257. "id": "toolu_e2e_capsule_foreground_keep",
  258. "name": "Agent",
  259. "input": {
  260. "description": "Keep running foreground child",
  261. "prompt": "E2E_CAPSULE_KEEP_CHILD: wait for the controlled result.",
  262. "run_in_background": false,
  263. "subagent_type": "general-purpose"
  264. }
  265. }
  266. ]
  267. }
  268. },
  269. {
  270. "id": "capsule-foreground-stop-controlled",
  271. "description": "停止目标 child 保持真实请求流不完成;由 Stop 中断。",
  272. "metadata": {
  273. "kind": "subagent",
  274. "timingPolicy": "controlled-stream",
  275. "source": "synthetic",
  276. "syntheticReason": "显式受控模型响应保持前台 running 窗口,Stop 必须中断原 Agent 调用。"
  277. },
  278. "maxMatches": 1,
  279. "match": {
  280. "method": "POST",
  281. "pathIncludes": "/messages",
  282. "lastUserMessageIncludes": [
  283. "E2E_CAPSULE_STOP_CHILD"
  284. ],
  285. "bodyExcludes": [
  286. "Generate a concise title",
  287. "CRITICAL: Respond with TEXT ONLY"
  288. ]
  289. },
  290. "response": {
  291. "statusCode": 200,
  292. "headers": {
  293. "content-type": "text/event-stream; charset=utf-8"
  294. },
  295. "releaseAfterChunks": 3,
  296. "chunks": [
  297. {
  298. "text": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"upstream-e2e-capsule-stop\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":32,\"output_tokens\":0}}}\n\n"
  299. },
  300. {
  301. "text": "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\n"
  302. },
  303. {
  304. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_CAPSULE_STOP_RUNNING\"}}\n\n"
  305. },
  306. {
  307. "text": "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\n"
  308. },
  309. {
  310. "text": "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"output_tokens\":12}}\n\n"
  311. },
  312. {
  313. "text": "event: message_stop\ndata: {\"type\":\"message_stop\"}\n\n"
  314. }
  315. ]
  316. }
  317. },
  318. {
  319. "id": "capsule-foreground-keep-controlled",
  320. "description": "另一个 child 在目标 Stop 后由测试放行完成。",
  321. "metadata": {
  322. "kind": "subagent",
  323. "timingPolicy": "controlled-stream",
  324. "source": "synthetic",
  325. "syntheticReason": "保持 sibling 独立运行,证明单项停止不误停另一 child。"
  326. },
  327. "maxMatches": 1,
  328. "match": {
  329. "method": "POST",
  330. "pathIncludes": "/messages",
  331. "lastUserMessageIncludes": [
  332. "E2E_CAPSULE_KEEP_CHILD"
  333. ],
  334. "bodyExcludes": [
  335. "Generate a concise title",
  336. "CRITICAL: Respond with TEXT ONLY"
  337. ]
  338. },
  339. "response": {
  340. "statusCode": 200,
  341. "headers": {
  342. "content-type": "text/event-stream; charset=utf-8"
  343. },
  344. "releaseAfterChunks": 3,
  345. "chunks": [
  346. {
  347. "text": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"upstream-e2e-capsule-keep\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":32,\"output_tokens\":0}}}\n\n"
  348. },
  349. {
  350. "text": "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\n"
  351. },
  352. {
  353. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_CAPSULE_KEEP_RUNNING\"}}\n\n"
  354. },
  355. {
  356. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_CAPSULE_KEEP_DONE\"}}\n\n"
  357. },
  358. {
  359. "text": "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\n"
  360. },
  361. {
  362. "text": "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"output_tokens\":12}}\n\n"
  363. },
  364. {
  365. "text": "event: message_stop\ndata: {\"type\":\"message_stop\"}\n\n"
  366. }
  367. ]
  368. }
  369. },
  370. {
  371. "id": "capsule-foreground-parent-final",
  372. "description": "收到前台 Stop 原工具结果及 sibling 完成后的父回复。",
  373. "metadata": {
  374. "kind": "main",
  375. "timingPolicy": "fast-text",
  376. "source": "synthetic",
  377. "syntheticReason": "固定父模型继续回复,以断言单子项 Stop 不打断原父 turn。"
  378. },
  379. "maxMatches": 1,
  380. "match": {
  381. "method": "POST",
  382. "pathIncludes": "/messages",
  383. "bodyIncludes": [
  384. "E2E_CAPSULE_FOREGROUND_STOP",
  385. "toolu_e2e_capsule_foreground_stop",
  386. "toolu_e2e_capsule_foreground_keep",
  387. "E2E_CAPSULE_KEEP_DONE"
  388. ],
  389. "bodyExcludes": [
  390. "Generate a concise title",
  391. "CRITICAL: Respond with TEXT ONLY"
  392. ]
  393. },
  394. "response": {
  395. "statusCode": 200,
  396. "text": {
  397. "id": "upstream-e2e-capsule-foreground-parent-done",
  398. "inputTokens": 32,
  399. "text": "E2E_CAPSULE_PARENT_DONE"
  400. }
  401. }
  402. }
  403. ]
  404. }