conversation-session-running-send-now-subagent.json 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. {
  2. "version": 1,
  3. "caseName": "conversation-session-running-send-now-subagent",
  4. "spec": "./test/e2e/conversation-session/queue/conversation-session-running-send-now-subagent.test.ts",
  5. "fixtures": [
  6. {
  7. "id": "running-send-now-subagent-title",
  8. "description": "立即发送转后台 case 的固定标题响应。父轮被抢占,标题由被点消息那一轮生成。",
  9. "metadata": {
  10. "kind": "common",
  11. "timingPolicy": "fast-text",
  12. "source": "synthetic",
  13. "syntheticReason": "标题生成不属于本 case,只需稳定返回以免误匹配业务 fixture。"
  14. },
  15. "match": {
  16. "method": "POST",
  17. "pathIncludes": "/messages",
  18. "bodyIncludes": ["Generate a concise title", "E2E_SEND_NOW_SUBAGENT_"]
  19. },
  20. "response": {
  21. "statusCode": 200,
  22. "statusMessage": "OK",
  23. "headers": {
  24. "content-type": "application/json; charset=utf-8"
  25. },
  26. "body": "{\"id\":\"upstream-e2e-send-now-subagent-title\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[{\"type\":\"text\",\"text\":\"{\\\"title\\\":\\\"Send now with foreground Agent\\\"}\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":125,\"cache_creation_input_tokens\":0,\"cache_read_tokens\":0,\"output_tokens\":24,\"service_tier\":\"standard\"}}"
  27. }
  28. },
  29. {
  30. "id": "running-send-now-subagent-parent-launch",
  31. "description": "父模型启动一个前台 Agent(不带 run_in_background)。",
  32. "metadata": {
  33. "kind": "main",
  34. "timingPolicy": "fast-tool-use",
  35. "source": "synthetic",
  36. "syntheticReason": "稳定创建真实前台 Agent,让父轮停在等待子代理结果。"
  37. },
  38. "maxMatches": 1,
  39. "match": {
  40. "method": "POST",
  41. "pathIncludes": "/messages",
  42. "lastUserMessageIncludes": ["E2E_SEND_NOW_SUBAGENT_PARENT"],
  43. "bodyIncludes": ["E2E_SEND_NOW_SUBAGENT_PARENT"],
  44. "bodyExcludes": [
  45. "Async agent launched successfully",
  46. "E2E_SEND_NOW_SUBAGENT_QUEUED",
  47. "Generate a concise title",
  48. "CRITICAL: Respond with TEXT ONLY"
  49. ]
  50. },
  51. "response": {
  52. "statusCode": 200,
  53. "toolUse": {
  54. "id": "toolu_e2e_send_now_subagent_agent",
  55. "name": "Agent",
  56. "input": {
  57. "description": "Send-now foreground Agent",
  58. "prompt": "E2E_SEND_NOW_SUBAGENT_CHILD: work slowly, then return the result marker.",
  59. "subagent_type": "general-purpose"
  60. }
  61. }
  62. }
  63. },
  64. {
  65. "id": "running-send-now-subagent-child-held",
  66. "description": "子代理唯一请求以受控流挂起,测试断言运行中计数后再放行。",
  67. "metadata": {
  68. "kind": "subagent",
  69. "timingPolicy": "controlled-stream",
  70. "source": "synthetic",
  71. "syntheticReason": "子代理在立即发送时仍在运行;转入后台后同一个请求被放行并返回结果,证明子代理没有被取消。用受控流代替固定延迟:慢机器上固定延迟可能先到期,子代理在计数断言前完成。"
  72. },
  73. "maxMatches": 1,
  74. "match": {
  75. "method": "POST",
  76. "pathIncludes": "/messages",
  77. "lastUserMessageIncludes": ["E2E_SEND_NOW_SUBAGENT_CHILD: work slowly"],
  78. "bodyIncludes": ["E2E_SEND_NOW_SUBAGENT_CHILD"],
  79. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  80. },
  81. "response": {
  82. "statusCode": 200,
  83. "statusMessage": "OK",
  84. "headers": {
  85. "cache-control": "no-cache",
  86. "content-type": "text/event-stream; charset=utf-8"
  87. },
  88. "releaseAfterChunks": 1,
  89. "chunks": [
  90. {
  91. "text": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"upstream-e2e-send-now-subagent-child\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":118,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":0,\"service_tier\":\"standard\"}}}\n\n",
  92. "delayMs": 0
  93. },
  94. {
  95. "text": "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\n",
  96. "delayMs": 0
  97. },
  98. {
  99. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_SEND_NOW_SUBAGENT_CHILD_RESULT\"}}\n\n",
  100. "delayMs": 0
  101. },
  102. {
  103. "text": "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\n",
  104. "delayMs": 0
  105. },
  106. {
  107. "text": "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":118,\"output_tokens\":12,\"service_tier\":\"standard\"}}\n\n",
  108. "delayMs": 0
  109. },
  110. {
  111. "text": "event: message_stop\ndata: {\"type\":\"message_stop\"}\n\n",
  112. "delayMs": 0
  113. }
  114. ]
  115. }
  116. },
  117. {
  118. "id": "running-send-now-subagent-queued-reply",
  119. "description": "被点立即发送的消息开新一轮,父模型直接回复。",
  120. "metadata": {
  121. "kind": "main",
  122. "timingPolicy": "fast-text",
  123. "source": "synthetic",
  124. "syntheticReason": "新一轮请求的历史里带 Agent 的 async_launched 结果;断言在 spec 里读取请求证据。"
  125. },
  126. "maxMatches": 1,
  127. "match": {
  128. "method": "POST",
  129. "pathIncludes": "/messages",
  130. "lastUserMessageIncludes": ["E2E_SEND_NOW_SUBAGENT_QUEUED:"],
  131. "lastUserMessageExcludes": ["<task-notification>"],
  132. "bodyIncludes": ["E2E_SEND_NOW_SUBAGENT_PARENT"],
  133. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  134. },
  135. "response": {
  136. "statusCode": 200,
  137. "text": {
  138. "id": "upstream-e2e-send-now-subagent-queued-reply",
  139. "text": "E2E_SEND_NOW_SUBAGENT_QUEUED_REPLY"
  140. }
  141. }
  142. },
  143. {
  144. "id": "running-send-now-subagent-parent-notification",
  145. "description": "后台子代理完成后,父模型消费 completed notification。",
  146. "metadata": {
  147. "kind": "main",
  148. "timingPolicy": "task-notification",
  149. "source": "synthetic",
  150. "syntheticReason": "证明转入后台的子代理完成后经 task notification 回到父模型并正常收口。"
  151. },
  152. "maxMatches": 1,
  153. "match": {
  154. "method": "POST",
  155. "pathIncludes": "/messages",
  156. "lastUserMessageIncludes": [
  157. "<task-notification>",
  158. "<tool-use-id>toolu_e2e_send_now_subagent_agent</tool-use-id>",
  159. "<status>completed</status>"
  160. ],
  161. "bodyIncludes": ["E2E_SEND_NOW_SUBAGENT_PARENT", "E2E_SEND_NOW_SUBAGENT_CHILD_RESULT"],
  162. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  163. },
  164. "response": {
  165. "statusCode": 200,
  166. "text": {
  167. "id": "upstream-e2e-send-now-subagent-parent-done",
  168. "text": "E2E_SEND_NOW_SUBAGENT_PARENT_DONE"
  169. }
  170. }
  171. }
  172. ]
  173. }