

























@@ -99,6 +99,7 @@ type MockOpenAiRequestSnapshot = {
9999providerVariant: MockOpenAiProviderVariant;
100100imageInputCount: number;
101101plannedToolName?: string;
102+plannedToolArgs?: Record<string, unknown>;
102103};
103104104105// Anthropic /v1/messages request/response shapes the mock actually needs.
@@ -577,6 +578,7 @@ function buildExplicitSessionsSpawnArgs(text: string): Record<string, unknown> |
577578}
578579const label = extractQuotedToolArg(text, "label") ?? extractBareToolArg(text, "label");
579580const mode = extractBareToolArg(text, "mode")?.toLowerCase();
581+const context = extractBareToolArg(text, "context")?.toLowerCase();
580582const runTimeoutSecondsRaw = extractBareToolArg(text, "runTimeoutSeconds");
581583const runTimeoutSeconds =
582584runTimeoutSecondsRaw && /^\d+$/.test(runTimeoutSecondsRaw)
@@ -587,6 +589,7 @@ function buildExplicitSessionsSpawnArgs(text: string): Record<string, unknown> |
587589 ...(label ? { label } : {}),
588590 ...(extractBareToolArg(text, "thread")?.toLowerCase() === "true" ? { thread: true } : {}),
589591 ...(mode === "session" || mode === "run" ? { mode } : {}),
592+ ...(context === "fork" || context === "isolated" ? { context } : {}),
590593 ...(runTimeoutSeconds !== undefined ? { runTimeoutSeconds } : {}),
591594};
592595}
@@ -745,11 +748,27 @@ function buildAssistantText(
745748if (/fanout worker beta/i.test(prompt)) {
746749return "BETA-OK";
747750}
751+if (/report the visible code/i.test(prompt) && /FORKED-CONTEXT-ALPHA/i.test(allInputText)) {
752+return "FORKED-CONTEXT-ALPHA";
753+}
748754const fanoutCompleteReply = "subagent-1: ok\nsubagent-2: ok";
749755if (scenarioState.subagentFanoutPhase === 2 && prompt) {
750756scenarioState.subagentFanoutPhase = 3;
751757return fanoutCompleteReply;
752758}
759+if (
760+/forked subagent context qa check/i.test(prompt) &&
761+/FORKED-CONTEXT-ALPHA/i.test(allInputText)
762+) {
763+return [
764+"Worked",
765+"- FORKED-CONTEXT-ALPHA",
766+"Evidence",
767+"- The forked child recovered the visible code from requester transcript context.",
768+"Blocked",
769+"- None.",
770+].join("\n");
771+}
753772if (toolOutput && (/\bdelegate\b/i.test(prompt) || /subagent handoff/i.test(prompt))) {
754773const compact = toolOutput.replace(/\s+/g, " ").trim() || "no delegated output";
755774return `Delegated task:\n- Inspect the QA workspace via a bounded subagent.\nResult:\n- ${compact}\nEvidence:\n- The child result was folded back into the main thread exactly once.`;
@@ -802,6 +821,25 @@ function extractPlannedToolName(events: StreamEvent[]) {
802821return undefined;
803822}
804823824+function extractPlannedToolArgs(events: StreamEvent[]) {
825+for (const event of events) {
826+if (event.type !== "response.output_item.done") {
827+continue;
828+}
829+const item = event.item as { type?: unknown; arguments?: unknown };
830+if (item.type !== "function_call" || typeof item.arguments !== "string") {
831+continue;
832+}
833+try {
834+const parsed = JSON.parse(item.arguments);
835+return parsed && typeof parsed === "object" ? (parsed as Record<string, unknown>) : undefined;
836+} catch {
837+return undefined;
838+}
839+}
840+return undefined;
841+}
842+805843type MockAssistantMessageSpec = {
806844id: string;
807845phase?: "commentary" | "final_answer";
@@ -1277,6 +1315,14 @@ async function buildResponsesPayload(
12771315if (canCallSessionsSpawn && explicitSessionsSpawnArgs && !toolOutput) {
12781316return buildToolCallEventsWithArgs("sessions_spawn", explicitSessionsSpawnArgs);
12791317}
1318+if (canCallSessionsSpawn && /forked subagent context qa check/i.test(prompt) && !toolOutput) {
1319+return buildToolCallEventsWithArgs("sessions_spawn", {
1320+task: "Report the visible code from the requester transcript.",
1321+label: "qa-fork-context",
1322+mode: "run",
1323+context: "fork",
1324+});
1325+}
12801326if (/tool continuity check/i.test(prompt) && !toolOutput) {
12811327return buildToolCallEventsWithArgs("read", { path: "QA_KICKOFF_TASK.md" });
12821328}
@@ -1814,6 +1860,7 @@ export async function startQaMockOpenAiServer(params?: { host?: string; port?: n
18141860providerVariant: resolveProviderVariant(resolvedModel),
18151861imageInputCount: countImageInputs(input),
18161862plannedToolName: extractPlannedToolName(events),
1863+plannedToolArgs: extractPlannedToolArgs(events),
18171864};
18181865requests.push(lastRequest);
18191866if (requests.length > 50) {
@@ -1869,6 +1916,7 @@ export async function startQaMockOpenAiServer(params?: { host?: string; port?: n
18691916providerVariant: resolveProviderVariant(normalizedModel),
18701917imageInputCount: countImageInputs(input),
18711918plannedToolName: extractPlannedToolName(events),
1919+plannedToolArgs: extractPlannedToolArgs(events),
18721920};
18731921requests.push(lastRequest);
18741922if (requests.length > 50) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。