conversation-session-background-subagent-rate-limit.json 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. {
  2. "version": 1,
  3. "caseName": "conversation-session-background-subagent-rate-limit",
  4. "spec": "./test/e2e/conversation-session/background/conversation-session-background-subagent-rate-limit.test.ts",
  5. "fixtures": [
  6. {
  7. "id": "background-subagent-rate-limit-title",
  8. "description": "background subagent rate limit 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_BACKGROUND_SUBAGENT_RATE_LIMIT_PARENT"]
  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-background-subagent-rate-limit-title\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[{\"type\":\"text\",\"text\":\"{\\\"title\\\":\\\"Background Agent 429\\\"}\"}],\"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": "background-subagent-rate-limit-parent-launch",
  31. "description": "父模型启动一个 background Agent。",
  32. "metadata": {
  33. "kind": "main",
  34. "timingPolicy": "fast-tool-use",
  35. "source": "synthetic",
  36. "syntheticReason": "稳定创建真实 Agent(run_in_background=true) 以覆盖 terminal notification 投影。"
  37. },
  38. "maxMatches": 1,
  39. "match": {
  40. "method": "POST",
  41. "pathIncludes": "/messages",
  42. "lastUserMessageIncludes": ["E2E_BACKGROUND_SUBAGENT_RATE_LIMIT_PARENT"],
  43. "bodyIncludes": [
  44. "E2E_BACKGROUND_SUBAGENT_RATE_LIMIT_PARENT",
  45. "E2E_BACKGROUND_SUBAGENT_RATE_LIMIT_PARENT_DONE"
  46. ],
  47. "bodyExcludes": [
  48. "Async agent launched successfully",
  49. "Generate a concise title",
  50. "CRITICAL: Respond with TEXT ONLY"
  51. ]
  52. },
  53. "response": {
  54. "statusCode": 200,
  55. "toolUse": {
  56. "id": "toolu_e2e_background_subagent_rate_limit_agent",
  57. "name": "Agent",
  58. "input": {
  59. "description": "世界杯冠军预测分析",
  60. "prompt": "E2E_BACKGROUND_SUBAGENT_RATE_LIMIT_CHILD: make one provider request; the replay server will return a stable 429.",
  61. "run_in_background": true,
  62. "subagent_type": "general-purpose"
  63. }
  64. }
  65. }
  66. },
  67. {
  68. "id": "background-subagent-rate-limit-parent-launch-ack",
  69. "description": "父模型在 background Agent launch ACK 后结束当前 turn。",
  70. "metadata": {
  71. "kind": "main",
  72. "timingPolicy": "fast-text",
  73. "source": "synthetic",
  74. "syntheticReason": "让父会话先回 idle,随后由 failed task notification 唤醒。"
  75. },
  76. "maxMatches": 1,
  77. "match": {
  78. "method": "POST",
  79. "pathIncludes": "/messages",
  80. "bodyIncludes": [
  81. "E2E_BACKGROUND_SUBAGENT_RATE_LIMIT_PARENT",
  82. "Async agent launched successfully",
  83. "toolu_e2e_background_subagent_rate_limit_agent"
  84. ],
  85. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"],
  86. "lastUserMessageExcludes": ["<task-notification>"]
  87. },
  88. "response": {
  89. "statusCode": 200,
  90. "text": {
  91. "id": "upstream-e2e-background-subagent-rate-limit-launch-ack",
  92. "text": "background-subagent-rate-limit-launched-ok"
  93. }
  94. }
  95. },
  96. {
  97. "id": "background-subagent-rate-limit-child-initial-429",
  98. "description": "child-only marker 的首个请求延迟返回 429,确保父 turn 先消费 launch ACK。",
  99. "metadata": {
  100. "kind": "subagent",
  101. "timingPolicy": "fault-stream",
  102. "source": "synthetic",
  103. "syntheticReason": "首个 429 延迟到父 turn 消费 launch ACK 后返回;BG26 worker 禁用模型 retry,只验证 terminal/UI/snapshot 的原始错误投影。"
  104. },
  105. "maxMatches": 1,
  106. "match": {
  107. "method": "POST",
  108. "pathIncludes": "/messages",
  109. "lastUserMessageIncludes": ["E2E_BACKGROUND_SUBAGENT_RATE_LIMIT_CHILD"],
  110. "bodyIncludes": ["E2E_BACKGROUND_SUBAGENT_RATE_LIMIT_CHILD"],
  111. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  112. },
  113. "response": {
  114. "statusCode": 429,
  115. "statusMessage": "Too Many Requests",
  116. "delayMs": 1500,
  117. "headers": {
  118. "content-type": "application/json; charset=utf-8",
  119. "retry-after": "0"
  120. },
  121. "body": "{\"error\":{\"code\":\"AccountRateLimitExceeded\",\"message\":\"Requests are too frequent. Please reduce your request frequency, wait a short moment, and retry your request. Request id: e2e-background-subagent-rate-limit\",\"param\":null,\"type\":\"TooManyRequests\"}}"
  122. }
  123. },
  124. {
  125. "id": "background-subagent-rate-limit-parent-notification",
  126. "description": "父模型消费 failed background Agent notification。",
  127. "metadata": {
  128. "kind": "main",
  129. "timingPolicy": "task-notification",
  130. "source": "synthetic",
  131. "syntheticReason": "证明 failed notification 经 runtime command queue 回到父模型并正常收口。"
  132. },
  133. "maxMatches": 1,
  134. "match": {
  135. "method": "POST",
  136. "pathIncludes": "/messages",
  137. "lastUserMessageIncludes": ["<task-notification>", "<status>failed</status>"],
  138. "bodyIncludes": [
  139. "E2E_BACKGROUND_SUBAGENT_RATE_LIMIT_PARENT",
  140. "<tool-use-id>toolu_e2e_background_subagent_rate_limit_agent</tool-use-id>",
  141. "<status>failed</status>"
  142. ],
  143. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  144. },
  145. "response": {
  146. "statusCode": 200,
  147. "text": {
  148. "id": "upstream-e2e-background-subagent-rate-limit-parent-done",
  149. "text": "E2E_BACKGROUND_SUBAGENT_RATE_LIMIT_PARENT_DONE"
  150. }
  151. }
  152. },
  153. {
  154. "id": "background-subagent-rate-limit-merged-title",
  155. "description": "BG26 合并通知用例的固定标题响应。",
  156. "metadata": {
  157. "kind": "common",
  158. "timingPolicy": "fast-text",
  159. "source": "synthetic",
  160. "syntheticReason": "标题生成不属于本 case,只需稳定返回以免误匹配业务 fixture。"
  161. },
  162. "match": {
  163. "method": "POST",
  164. "pathIncludes": "/messages",
  165. "bodyIncludes": ["Generate a concise title", "E2E_BG26_MERGED_PARENT"]
  166. },
  167. "response": {
  168. "statusCode": 200,
  169. "statusMessage": "OK",
  170. "headers": {
  171. "content-type": "application/json; charset=utf-8"
  172. },
  173. "body": "{\"id\":\"upstream-e2e-bg26-merged-title\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[{\"type\":\"text\",\"text\":\"{\\\"title\\\":\\\"Background Agent merged notifications\\\"}\"}],\"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\"}}"
  174. }
  175. },
  176. {
  177. "id": "background-subagent-rate-limit-merged-parent-launch",
  178. "description": "父模型在同一 response 启动三个 background Agent:失败、完成、失败。",
  179. "metadata": {
  180. "kind": "main",
  181. "timingPolicy": "fast-tool-use",
  182. "source": "synthetic",
  183. "syntheticReason": "同一 response 启动三个真实 Agent(run_in_background=true),终止顺序由各 child 的延迟决定。"
  184. },
  185. "maxMatches": 1,
  186. "match": {
  187. "method": "POST",
  188. "pathIncludes": "/messages",
  189. "lastUserMessageIncludes": ["E2E_BG26_MERGED_PARENT"],
  190. "bodyIncludes": ["E2E_BG26_MERGED_PARENT", "E2E_BG26_MERGED_PARENT_DONE"],
  191. "bodyExcludes": [
  192. "Async agent launched successfully",
  193. "Generate a concise title",
  194. "CRITICAL: Respond with TEXT ONLY"
  195. ]
  196. },
  197. "response": {
  198. "statusCode": 200,
  199. "toolUses": [
  200. {
  201. "id": "toolu_e2e_bg26_merged_first_failing_agent",
  202. "name": "Agent",
  203. "input": {
  204. "description": "BG26 first failing background Agent",
  205. "prompt": "E2E_BG26_MERGED_FIRST_FAILING_CHILD: make one provider request; the replay server will return a stable 429.",
  206. "run_in_background": true,
  207. "subagent_type": "general-purpose"
  208. }
  209. },
  210. {
  211. "id": "toolu_e2e_bg26_merged_completing_agent",
  212. "name": "Agent",
  213. "input": {
  214. "description": "BG26 completing background Agent",
  215. "prompt": "E2E_BG26_MERGED_COMPLETING_CHILD: Return exactly E2E_BG26_MERGED_COMPLETED_RESULT.",
  216. "run_in_background": true,
  217. "subagent_type": "general-purpose"
  218. }
  219. },
  220. {
  221. "id": "toolu_e2e_bg26_merged_last_failing_agent",
  222. "name": "Agent",
  223. "input": {
  224. "description": "BG26 last failing background Agent",
  225. "prompt": "E2E_BG26_MERGED_LAST_FAILING_CHILD: make one provider request; the replay server will return a stable 429.",
  226. "run_in_background": true,
  227. "subagent_type": "general-purpose"
  228. }
  229. }
  230. ]
  231. }
  232. },
  233. {
  234. "id": "background-subagent-rate-limit-merged-parent-launch-ack",
  235. "description": "父模型在三个 Agent launch ACK 后延迟结束当前 turn。",
  236. "metadata": {
  237. "kind": "main",
  238. "timingPolicy": "delayed-text",
  239. "source": "synthetic",
  240. "syntheticReason": "九秒延迟让三个 child 都在父 launch turn 结束前终止,三条通知在父会话空闲时由同一次 drain 合并为一轮。"
  241. },
  242. "maxMatches": 1,
  243. "match": {
  244. "method": "POST",
  245. "pathIncludes": "/messages",
  246. "bodyIncludes": [
  247. "E2E_BG26_MERGED_PARENT",
  248. "Async agent launched successfully",
  249. "toolu_e2e_bg26_merged_first_failing_agent",
  250. "toolu_e2e_bg26_merged_completing_agent",
  251. "toolu_e2e_bg26_merged_last_failing_agent"
  252. ],
  253. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"],
  254. "lastUserMessageExcludes": ["<task-notification>"]
  255. },
  256. "response": {
  257. "statusCode": 200,
  258. "delayMs": 9000,
  259. "text": {
  260. "id": "upstream-e2e-bg26-merged-launch-ack",
  261. "text": "bg26-merged-agents-launched-ok"
  262. }
  263. }
  264. },
  265. {
  266. "id": "background-subagent-rate-limit-merged-first-child-partial-step",
  267. "description": "第一个失败 child 的首个请求先回正文和一个 TodoWrite 调用,留下部分报告。",
  268. "metadata": {
  269. "kind": "subagent",
  270. "timingPolicy": "fast-tool-use",
  271. "source": "synthetic",
  272. "syntheticReason": "子代理先写出正文再失败,失败通知的 <result> 才有部分报告;TodoWrite 不需要 shell 和权限,第二次请求按工具调用 id 匹配。"
  273. },
  274. "maxMatches": 1,
  275. "match": {
  276. "method": "POST",
  277. "pathIncludes": "/messages",
  278. "lastUserMessageIncludes": ["E2E_BG26_MERGED_FIRST_FAILING_CHILD"],
  279. "bodyIncludes": ["E2E_BG26_MERGED_FIRST_FAILING_CHILD"],
  280. "bodyExcludes": [
  281. "Generate a concise title",
  282. "CRITICAL: Respond with TEXT ONLY",
  283. "toolu_e2e_bg26_merged_first_partial_step"
  284. ]
  285. },
  286. "response": {
  287. "statusCode": 200,
  288. "statusMessage": "OK",
  289. "headers": {
  290. "cache-control": "no-cache",
  291. "content-type": "text/event-stream; charset=utf-8"
  292. },
  293. "body": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"upstream-e2e-bg26-merged-first-partial-step\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":120,\"output_tokens\":0}}}\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_BG26_MERGED_FIRST_PARTIAL_REPORT\"}}\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\nevent: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":1,\"content_block\":{\"type\":\"tool_use\",\"id\":\"toolu_e2e_bg26_merged_first_partial_step\",\"name\":\"TodoWrite\",\"input\":{}}}\n\nevent: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":1,\"delta\":{\"type\":\"input_json_delta\",\"partial_json\":\"{\\\"todos\\\":[{\\\"content\\\":\\\"Check module A\\\",\\\"priority\\\":\\\"high\\\",\\\"status\\\":\\\"in_progress\\\"}]}\"}}\n\nevent: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":1}\n\nevent: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"tool_use\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":120,\"output_tokens\":24}}\n\nevent: message_stop\ndata: {\"type\":\"message_stop\"}\n\n"
  294. }
  295. },
  296. {
  297. "id": "background-subagent-rate-limit-merged-first-child-429",
  298. "description": "第一个失败 child 的第二个请求在 0.5 秒后返回 429。",
  299. "metadata": {
  300. "kind": "subagent",
  301. "timingPolicy": "fault-stream",
  302. "source": "synthetic",
  303. "syntheticReason": "最先终止,失败通知排在批次第一条;在部分报告那一步之后失败,延迟缩短到 0.5 秒,保证仍早于 3 秒完成的 child。BG26 worker 禁用模型 retry。"
  304. },
  305. "maxMatches": 1,
  306. "match": {
  307. "method": "POST",
  308. "pathIncludes": "/messages",
  309. "bodyIncludes": [
  310. "E2E_BG26_MERGED_FIRST_FAILING_CHILD",
  311. "toolu_e2e_bg26_merged_first_partial_step"
  312. ],
  313. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  314. },
  315. "response": {
  316. "statusCode": 429,
  317. "statusMessage": "Too Many Requests",
  318. "delayMs": 500,
  319. "headers": {
  320. "content-type": "application/json; charset=utf-8",
  321. "retry-after": "0"
  322. },
  323. "body": "{\"error\":{\"code\":\"AccountRateLimitExceeded\",\"message\":\"Requests are too frequent. Please reduce your request frequency, wait a short moment, and retry your request. Request id: e2e-bg26-merged-first-failure\",\"param\":null,\"type\":\"TooManyRequests\"}}"
  324. }
  325. },
  326. {
  327. "id": "background-subagent-rate-limit-merged-child-completed",
  328. "description": "完成 child 在 3 秒后返回结果。",
  329. "metadata": {
  330. "kind": "subagent",
  331. "timingPolicy": "delayed-text",
  332. "source": "synthetic",
  333. "syntheticReason": "第二个终止,完成通知排在批次第二条,紧跟第一条失败通知。"
  334. },
  335. "maxMatches": 1,
  336. "match": {
  337. "method": "POST",
  338. "pathIncludes": "/messages",
  339. "lastUserMessageIncludes": ["E2E_BG26_MERGED_COMPLETING_CHILD: Return exactly"],
  340. "bodyIncludes": ["E2E_BG26_MERGED_COMPLETING_CHILD"],
  341. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  342. },
  343. "response": {
  344. "statusCode": 200,
  345. "delayMs": 3000,
  346. "text": {
  347. "id": "upstream-e2e-bg26-merged-child-completed",
  348. "text": "E2E_BG26_MERGED_COMPLETED_RESULT"
  349. }
  350. }
  351. },
  352. {
  353. "id": "background-subagent-rate-limit-merged-last-child-429",
  354. "description": "最后一个失败 child 的唯一请求在 4.5 秒后返回 429。",
  355. "metadata": {
  356. "kind": "subagent",
  357. "timingPolicy": "fault-stream",
  358. "source": "synthetic",
  359. "syntheticReason": "最后终止,失败通知排在批次第三条,覆盖后面的通知块取得终态。"
  360. },
  361. "maxMatches": 1,
  362. "match": {
  363. "method": "POST",
  364. "pathIncludes": "/messages",
  365. "lastUserMessageIncludes": ["E2E_BG26_MERGED_LAST_FAILING_CHILD"],
  366. "bodyIncludes": ["E2E_BG26_MERGED_LAST_FAILING_CHILD"],
  367. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  368. },
  369. "response": {
  370. "statusCode": 429,
  371. "statusMessage": "Too Many Requests",
  372. "delayMs": 4500,
  373. "headers": {
  374. "content-type": "application/json; charset=utf-8",
  375. "retry-after": "0"
  376. },
  377. "body": "{\"error\":{\"code\":\"AccountRateLimitExceeded\",\"message\":\"Requests are too frequent. Please reduce your request frequency, wait a short moment, and retry your request. Request id: e2e-bg26-merged-last-failure\",\"param\":null,\"type\":\"TooManyRequests\"}}"
  378. }
  379. },
  380. {
  381. "id": "background-subagent-rate-limit-merged-parent-notification",
  382. "description": "父模型在同一轮消费三条 notification。",
  383. "metadata": {
  384. "kind": "main",
  385. "timingPolicy": "task-notification",
  386. "source": "synthetic",
  387. "syntheticReason": "同一条 last user message 同时含三条通知与完成任务的结果,证明合并为一轮后父模型正常收口。"
  388. },
  389. "maxMatches": 1,
  390. "match": {
  391. "method": "POST",
  392. "pathIncludes": "/messages",
  393. "lastUserMessageIncludes": [
  394. "<tool-use-id>toolu_e2e_bg26_merged_first_failing_agent</tool-use-id>",
  395. "<tool-use-id>toolu_e2e_bg26_merged_completing_agent</tool-use-id>",
  396. "<tool-use-id>toolu_e2e_bg26_merged_last_failing_agent</tool-use-id>",
  397. "E2E_BG26_MERGED_COMPLETED_RESULT"
  398. ],
  399. "bodyIncludes": ["E2E_BG26_MERGED_PARENT"],
  400. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  401. },
  402. "response": {
  403. "statusCode": 200,
  404. "text": {
  405. "id": "upstream-e2e-bg26-merged-parent-done",
  406. "text": "E2E_BG26_MERGED_PARENT_DONE"
  407. }
  408. }
  409. }
  410. ]
  411. }