mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
fix(qa): preserve Code Mode reads in model-switch mock (#122935)
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
// QA Lab mock provider output event builders.
|
||||
|
||||
import type { StreamEvent } from "./mock-openai-contracts.js";
|
||||
import {
|
||||
readTargetFromPrompt,
|
||||
buildMockFunctionCall,
|
||||
buildToolCallEventsWithArgs,
|
||||
} from "./mock-openai-tooling.js";
|
||||
import { buildMockFunctionCall } from "./mock-openai-tooling.js";
|
||||
|
||||
export function buildFailedResponseEvents(): StreamEvent[] {
|
||||
const responseId = `resp_qa_failed_${Date.now()}`;
|
||||
@@ -55,11 +51,6 @@ export function buildPartialFailureEvents(partialText: string): StreamEvent[] {
|
||||
];
|
||||
}
|
||||
|
||||
export function buildToolCallEvents(prompt: string): StreamEvent[] {
|
||||
const targetPath = readTargetFromPrompt(prompt);
|
||||
return buildToolCallEventsWithArgs("read", { path: targetPath });
|
||||
}
|
||||
|
||||
export function buildReleaseAuditJson() {
|
||||
return `${JSON.stringify(
|
||||
{
|
||||
|
||||
@@ -6396,6 +6396,49 @@ Update and merge these partial structured summaries.`,
|
||||
expect(await response.text()).toContain('"name":"read"');
|
||||
});
|
||||
|
||||
it("routes the initial model-switch read through Anthropic guest Code Mode", async () => {
|
||||
const server = await startMockServer();
|
||||
const body = (await expectAnthropicMessagesJson(server, {
|
||||
tools: [
|
||||
{
|
||||
name: "exec",
|
||||
input_schema: {
|
||||
type: "object",
|
||||
properties: { code: { type: "string" } },
|
||||
required: ["code"],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "wait",
|
||||
input_schema: {
|
||||
type: "object",
|
||||
properties: { runId: { type: "string" } },
|
||||
required: ["runId"],
|
||||
},
|
||||
},
|
||||
],
|
||||
messages: [
|
||||
makeAnthropicUserText(
|
||||
"Read repo/qa/scenarios/index.yaml and summarize the QA scenario pack mission in one clause before any model switch.",
|
||||
),
|
||||
],
|
||||
})) as {
|
||||
stop_reason: string;
|
||||
content: Array<Record<string, unknown>>;
|
||||
};
|
||||
|
||||
expect(body.stop_reason).toBe("tool_use");
|
||||
expect(body.content.find((block) => block.type === "tool_use")?.name).toBe("exec");
|
||||
|
||||
const debug = requireRecord(
|
||||
await getJson(server, "/debug/last-request"),
|
||||
"model switch Code Mode debug request",
|
||||
);
|
||||
expect(debug.plannedToolName).toBe("read");
|
||||
expect(debug.plannedWireToolName).toBe("exec");
|
||||
expect(debug.plannedToolArgs).toEqual({ path: "repo/qa/scenarios/index.yaml" });
|
||||
});
|
||||
|
||||
it("returns continuity language after the model-switch reread completes", async () => {
|
||||
const server = await startMockServer();
|
||||
|
||||
|
||||
@@ -134,7 +134,6 @@ import {
|
||||
isHeartbeatPrompt,
|
||||
} from "./mock-openai-directives.js";
|
||||
import {
|
||||
buildToolCallEvents,
|
||||
buildReleaseAuditJson,
|
||||
buildReleaseHandoffMarkdown,
|
||||
extractPlannedToolName,
|
||||
@@ -2363,7 +2362,7 @@ async function buildResponsesPayload(
|
||||
});
|
||||
}
|
||||
if (!hasCompletedToolOutput && /\b(read|inspect|repo|docs|scenario|kickoff)\b/i.test(prompt)) {
|
||||
return buildToolCallEvents(prompt);
|
||||
return buildToolCallEventsWithArgs("read", { path: readTargetFromPrompt(prompt) });
|
||||
}
|
||||
if (/visible skill marker/i.test(prompt) && !hasCompletedToolOutput) {
|
||||
return buildAssistantEvents("VISIBLE-SKILL-OK");
|
||||
|
||||
Reference in New Issue
Block a user