conversation-session-capsule-foreground-stop.json 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. {
  2. "version": 1,
  3. "caseName": "conversation-session-capsule-foreground-stop",
  4. "spec": "./test/e2e/conversation-session/subagents/conversation-session-capsule-foreground-stop.test.ts",
  5. "fixtures": [
  6. {
  7. "id": "capsule-foreground-title",
  8. "description": "隔离标题请求。",
  9. "metadata": {
  10. "kind": "common",
  11. "timingPolicy": "fast-text",
  12. "source": "synthetic",
  13. "syntheticReason": "标题不是 SAT12 的停止语义,固定响应确保 replay 可复现。"
  14. },
  15. "maxMatches": 1,
  16. "match": {
  17. "method": "POST",
  18. "pathIncludes": "/messages",
  19. "bodyIncludes": ["Generate a concise title", "E2E_CAPSULE_FOREGROUND_STOP"]
  20. },
  21. "response": {
  22. "statusCode": 200,
  23. "statusMessage": "OK",
  24. "headers": { "content-type": "application/json; charset=utf-8" },
  25. "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}}"
  26. }
  27. },
  28. {
  29. "id": "capsule-foreground-parent-launch",
  30. "description": "同一父回复并行发起两个前台 Agent。",
  31. "metadata": {
  32. "kind": "main",
  33. "timingPolicy": "fast-tool-use",
  34. "source": "synthetic",
  35. "syntheticReason": "固定两个并行 foreground child,验证只停止用户选择的执行。"
  36. },
  37. "maxMatches": 1,
  38. "match": {
  39. "method": "POST",
  40. "pathIncludes": "/messages",
  41. "lastUserMessageIncludes": ["E2E_CAPSULE_FOREGROUND_STOP"],
  42. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  43. },
  44. "response": {
  45. "statusCode": 200,
  46. "toolUses": [
  47. {
  48. "id": "toolu_e2e_capsule_foreground_stop",
  49. "name": "Agent",
  50. "input": {
  51. "description": "Stop target foreground child",
  52. "prompt": "E2E_CAPSULE_STOP_CHILD: wait for the controlled result.",
  53. "run_in_background": false,
  54. "subagent_type": "general-purpose"
  55. }
  56. },
  57. {
  58. "id": "toolu_e2e_capsule_foreground_keep",
  59. "name": "Agent",
  60. "input": {
  61. "description": "Keep running foreground child",
  62. "prompt": "E2E_CAPSULE_KEEP_CHILD: wait for the controlled result.",
  63. "run_in_background": false,
  64. "subagent_type": "general-purpose"
  65. }
  66. }
  67. ]
  68. }
  69. },
  70. {
  71. "id": "capsule-foreground-stop-controlled",
  72. "description": "停止目标 child 保持真实请求流不完成;由 Stop 中断。",
  73. "metadata": {
  74. "kind": "subagent",
  75. "timingPolicy": "controlled-stream",
  76. "source": "synthetic",
  77. "syntheticReason": "显式受控模型响应保持前台 running 窗口,Stop 必须中断原 Agent 调用。"
  78. },
  79. "maxMatches": 1,
  80. "match": {
  81. "method": "POST",
  82. "pathIncludes": "/messages",
  83. "lastUserMessageIncludes": ["E2E_CAPSULE_STOP_CHILD"],
  84. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  85. },
  86. "response": {
  87. "statusCode": 200,
  88. "headers": { "content-type": "text/event-stream; charset=utf-8" },
  89. "releaseAfterChunks": 3,
  90. "chunks": [
  91. {
  92. "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"
  93. },
  94. {
  95. "text": "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\n"
  96. },
  97. {
  98. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_CAPSULE_STOP_RUNNING\"}}\n\n"
  99. },
  100. {
  101. "text": "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\n"
  102. },
  103. {
  104. "text": "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"output_tokens\":12}}\n\n"
  105. },
  106. { "text": "event: message_stop\ndata: {\"type\":\"message_stop\"}\n\n" }
  107. ]
  108. }
  109. },
  110. {
  111. "id": "capsule-foreground-keep-controlled",
  112. "description": "另一个 child 在目标 Stop 后由测试放行完成。",
  113. "metadata": {
  114. "kind": "subagent",
  115. "timingPolicy": "controlled-stream",
  116. "source": "synthetic",
  117. "syntheticReason": "保持 sibling 独立运行,证明单项停止不误停另一 child。"
  118. },
  119. "maxMatches": 1,
  120. "match": {
  121. "method": "POST",
  122. "pathIncludes": "/messages",
  123. "lastUserMessageIncludes": ["E2E_CAPSULE_KEEP_CHILD"],
  124. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  125. },
  126. "response": {
  127. "statusCode": 200,
  128. "headers": { "content-type": "text/event-stream; charset=utf-8" },
  129. "releaseAfterChunks": 3,
  130. "chunks": [
  131. {
  132. "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"
  133. },
  134. {
  135. "text": "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\n"
  136. },
  137. {
  138. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_CAPSULE_KEEP_RUNNING\"}}\n\n"
  139. },
  140. {
  141. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_CAPSULE_KEEP_DONE\"}}\n\n"
  142. },
  143. {
  144. "text": "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\n"
  145. },
  146. {
  147. "text": "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"output_tokens\":12}}\n\n"
  148. },
  149. { "text": "event: message_stop\ndata: {\"type\":\"message_stop\"}\n\n" }
  150. ]
  151. }
  152. },
  153. {
  154. "id": "capsule-foreground-parent-final",
  155. "description": "收到前台 Stop 原工具结果及 sibling 完成后的父回复。",
  156. "metadata": {
  157. "kind": "main",
  158. "timingPolicy": "fast-text",
  159. "source": "synthetic",
  160. "syntheticReason": "固定父模型继续回复,以断言单子项 Stop 不打断原父 turn。"
  161. },
  162. "maxMatches": 1,
  163. "match": {
  164. "method": "POST",
  165. "pathIncludes": "/messages",
  166. "bodyIncludes": [
  167. "E2E_CAPSULE_FOREGROUND_STOP",
  168. "toolu_e2e_capsule_foreground_stop",
  169. "toolu_e2e_capsule_foreground_keep",
  170. "E2E_CAPSULE_KEEP_DONE"
  171. ],
  172. "bodyExcludes": [
  173. "Generate a concise title",
  174. "CRITICAL: Respond with TEXT ONLY",
  175. "<task-notification>"
  176. ]
  177. },
  178. "response": {
  179. "statusCode": 200,
  180. "text": {
  181. "id": "upstream-e2e-capsule-foreground-parent-done",
  182. "inputTokens": 32,
  183. "text": "E2E_CAPSULE_PARENT_DONE"
  184. }
  185. }
  186. }
  187. ]
  188. }