mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 17:10:49 +00:00
test(gateway): skip opencode acp image probe by default
This commit is contained in:
@@ -30,6 +30,7 @@ import {
|
||||
buildLiveCronProbeMessage,
|
||||
createLiveCronProbeSpec,
|
||||
runOpenClawCliJson,
|
||||
shouldRunLiveImageProbe,
|
||||
} from "./live-agent-probes.js";
|
||||
import { renderCatFacePngBase64 } from "./live-image-probe.js";
|
||||
import { startGatewayServer } from "./server.js";
|
||||
@@ -907,48 +908,57 @@ describeLive("gateway live (ACP bind)", () => {
|
||||
expect(boundHistory.matchedAssistantText).toContain(`ACP-BIND-MEMORY-${memoryNonce}`);
|
||||
logLiveStep("bound session transcript contains the final marker token");
|
||||
|
||||
const markerAssistantCount = assistantTexts.length;
|
||||
let imageHistory: Awaited<ReturnType<typeof waitForAssistantTurn>> | null = null;
|
||||
for (let attempt = 0; attempt < 2 && !imageHistory; attempt += 1) {
|
||||
await sendChatAndWait({
|
||||
client,
|
||||
sessionKey: originalSessionKey,
|
||||
idempotencyKey: `idem-image-${attempt}-${randomUUID()}`,
|
||||
message:
|
||||
"What animal is drawn in the attached image? Reply with only the lowercase animal name.",
|
||||
originatingChannel: "slack",
|
||||
originatingTo: conversationId,
|
||||
originatingAccountId: accountId,
|
||||
attachments: [
|
||||
{
|
||||
mimeType: "image/png",
|
||||
fileName: `probe-${randomUUID()}.png`,
|
||||
content: renderCatFacePngBase64(),
|
||||
},
|
||||
],
|
||||
});
|
||||
logLiveStep(`image turn completed (attempt ${String(attempt + 1)})`);
|
||||
|
||||
try {
|
||||
imageHistory = await waitForAssistantTurn({
|
||||
if (
|
||||
shouldRunLiveImageProbe({
|
||||
agent: liveAgent,
|
||||
override: process.env.OPENCLAW_LIVE_ACP_BIND_IMAGE_PROBE,
|
||||
})
|
||||
) {
|
||||
const markerAssistantCount = assistantTexts.length;
|
||||
let imageHistory: Awaited<ReturnType<typeof waitForAssistantTurn>> | null = null;
|
||||
for (let attempt = 0; attempt < 2 && !imageHistory; attempt += 1) {
|
||||
await sendChatAndWait({
|
||||
client,
|
||||
sessionKey: spawnedSessionKey,
|
||||
minAssistantCount: markerAssistantCount + 1,
|
||||
timeoutMs: liveAgent === "claude" ? 60_000 : 45_000,
|
||||
sessionKey: originalSessionKey,
|
||||
idempotencyKey: `idem-image-${attempt}-${randomUUID()}`,
|
||||
message:
|
||||
"What animal is drawn in the attached image? Reply with only the lowercase animal name.",
|
||||
originatingChannel: "slack",
|
||||
originatingTo: conversationId,
|
||||
originatingAccountId: accountId,
|
||||
attachments: [
|
||||
{
|
||||
mimeType: "image/png",
|
||||
fileName: `probe-${randomUUID()}.png`,
|
||||
content: renderCatFacePngBase64(),
|
||||
},
|
||||
],
|
||||
});
|
||||
} catch {
|
||||
if (attempt === 1) {
|
||||
logLiveStep(
|
||||
"bound session image reply not observed; continuing to cron verification",
|
||||
);
|
||||
break;
|
||||
logLiveStep(`image turn completed (attempt ${String(attempt + 1)})`);
|
||||
|
||||
try {
|
||||
imageHistory = await waitForAssistantTurn({
|
||||
client,
|
||||
sessionKey: spawnedSessionKey,
|
||||
minAssistantCount: markerAssistantCount + 1,
|
||||
timeoutMs: liveAgent === "claude" ? 60_000 : 45_000,
|
||||
});
|
||||
} catch {
|
||||
if (attempt === 1) {
|
||||
logLiveStep(
|
||||
"bound session image reply not observed; continuing to cron verification",
|
||||
);
|
||||
break;
|
||||
}
|
||||
logLiveStep("bound session image reply not observed yet; retrying");
|
||||
}
|
||||
logLiveStep("bound session image reply not observed yet; retrying");
|
||||
}
|
||||
}
|
||||
if (imageHistory) {
|
||||
assertLiveImageProbeReply(imageHistory.lastAssistantText);
|
||||
logLiveStep("bound session classified the probe image");
|
||||
if (imageHistory) {
|
||||
assertLiveImageProbeReply(imageHistory.lastAssistantText);
|
||||
logLiveStep("bound session classified the probe image");
|
||||
}
|
||||
} else {
|
||||
logLiveStep(`skipping image probe for ${liveAgent}`);
|
||||
}
|
||||
|
||||
const requireCronMcpProbe = shouldRequireCronMcpProbe();
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
buildLiveCronProbeMessage,
|
||||
createLiveCronProbeSpec,
|
||||
isClaudeLikeLiveAgent,
|
||||
shouldRunLiveImageProbe,
|
||||
} from "./live-agent-probes.js";
|
||||
|
||||
describe("live-agent-probes", () => {
|
||||
@@ -28,6 +29,13 @@ describe("live-agent-probes", () => {
|
||||
expect(() => assertLiveImageProbeReply("caterpillar")).toThrow("image probe expected 'cat'");
|
||||
});
|
||||
|
||||
it("skips the shared image probe for text-only live agents unless forced", () => {
|
||||
expect(shouldRunLiveImageProbe({ agent: "claude" })).toBe(true);
|
||||
expect(shouldRunLiveImageProbe({ agent: "opencode" })).toBe(false);
|
||||
expect(shouldRunLiveImageProbe({ agent: "opencode", override: "1" })).toBe(true);
|
||||
expect(shouldRunLiveImageProbe({ agent: "claude", override: "0" })).toBe(false);
|
||||
});
|
||||
|
||||
it("builds a retryable cron prompt with provider-specific fallback wording", () => {
|
||||
const spec = createLiveCronProbeSpec({
|
||||
agentId: "codex",
|
||||
|
||||
@@ -38,6 +38,22 @@ export function assertLiveImageProbeReply(text: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
export function shouldRunLiveImageProbe(params: { agent: string; override?: string }): boolean {
|
||||
const override = params.override?.trim();
|
||||
if (override) {
|
||||
switch (normalizeOptionalLowercaseString(override)) {
|
||||
case "1":
|
||||
case "on":
|
||||
case "true":
|
||||
case "yes":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return normalizeOptionalLowercaseString(params.agent) !== "opencode";
|
||||
}
|
||||
|
||||
export function createLiveCronProbeSpec(
|
||||
params: {
|
||||
agentId?: string;
|
||||
|
||||
Reference in New Issue
Block a user