





























@@ -1015,7 +1015,84 @@ describe("qa mock openai server", () => {
10151015{
10161016content: [
10171017{
1018-text: "Protocol note: delegated fanout complete. Alpha=ALPHA-OK. Beta=BETA-OK.",
1018+text: "subagent-1: ok\nsubagent-2: ok",
1019+},
1020+],
1021+},
1022+],
1023+});
1024+});
1025+1026+it("completes subagent fanout from a continuation turn without tool output", async () => {
1027+const server = await startQaMockOpenAiServer({
1028+host: "127.0.0.1",
1029+port: 0,
1030+});
1031+cleanups.push(async () => {
1032+await server.stop();
1033+});
1034+1035+const prompt =
1036+"Subagent fanout synthesis check: delegate two bounded subagents sequentially, then report both results together.";
1037+const spawn = await fetch(`${server.baseUrl}/v1/responses`, {
1038+method: "POST",
1039+headers: { "content-type": "application/json" },
1040+body: JSON.stringify({
1041+stream: true,
1042+tools: [SESSIONS_SPAWN_TOOL],
1043+input: [{ role: "user", content: [{ type: "input_text", text: prompt }] }],
1044+}),
1045+});
1046+expect(spawn.status).toBe(200);
1047+expect(await spawn.text()).toContain('\\"label\\":\\"qa-fanout-alpha\\"');
1048+1049+const secondSpawn = await fetch(`${server.baseUrl}/v1/responses`, {
1050+method: "POST",
1051+headers: { "content-type": "application/json" },
1052+body: JSON.stringify({
1053+stream: true,
1054+tools: [SESSIONS_SPAWN_TOOL],
1055+input: [
1056+{ role: "user", content: [{ type: "input_text", text: prompt }] },
1057+{
1058+type: "function_call_output",
1059+output:
1060+'{"status":"accepted","childSessionKey":"agent:qa:subagent:alpha","note":"ALPHA-OK"}',
1061+},
1062+],
1063+}),
1064+});
1065+expect(secondSpawn.status).toBe(200);
1066+expect(await secondSpawn.text()).toContain('\\"label\\":\\"qa-fanout-beta\\"');
1067+1068+const phaseOnlyFinal = await fetch(`${server.baseUrl}/v1/responses`, {
1069+method: "POST",
1070+headers: {
1071+"content-type": "application/json",
1072+},
1073+body: JSON.stringify({
1074+stream: false,
1075+tools: [SESSIONS_SPAWN_TOOL],
1076+input: [
1077+{
1078+role: "user",
1079+content: [
1080+{
1081+type: "input_text",
1082+text: "Continue.",
1083+},
1084+],
1085+},
1086+],
1087+}),
1088+});
1089+expect(phaseOnlyFinal.status).toBe(200);
1090+expect(await phaseOnlyFinal.json()).toMatchObject({
1091+output: [
1092+{
1093+content: [
1094+{
1095+text: "subagent-1: ok\nsubagent-2: ok",
10191096},
10201097],
10211098},
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。