import type { AssistantMessage } from "@mariozechner/pi-ai"; import { describe, expect, it } from "vitest"; import {
buildPayloads,
expectSinglePayloadText,
expectSingleToolErrorPayload,
} from "./payloads.test-helpers.js";
it("does not fall back to commentary-only assistant text when streamed text was suppressed", () => { const payloads = buildPayloads({
lastAssistant: {
role: "assistant",
stopReason: "toolUse",
content: [
{
type: "text",
text: "Need update cron messages to use finalBrief/briefPath.",
textSignature: JSON.stringify({
v: 1,
id: "item_commentary",
phase: "commentary",
}),
},
],
} as AssistantMessage,
});
expect(payloads).toEqual([]);
});
it("falls back to final-answer assistant text when streamed text is unavailable", () => { const payloads = buildPayloads({
lastAssistant: {
role: "assistant",
stopReason: "stop",
content: [
{
type: "text",
text: "Need inspect.",
textSignature: JSON.stringify({
v: 1,
id: "item_commentary",
phase: "commentary",
}),
},
{
type: "text",
text: "Done.",
textSignature: JSON.stringify({
v: 1,
id: "item_final",
phase: "final_answer",
}),
},
],
} as AssistantMessage,
});
it("surfaces exec tool errors for cron sessions even when verbose mode is off", () => { const payloads = buildPayloads({
lastToolError: {
toolName: "exec",
timedOut: true,
error: "Command timed out after 1800 seconds. If this command is expected to take longer, re-run with a higher timeout (e.g., exec timeout=300).",
},
sessionKey: "agent:main:cron:job-1",
verboseLevel: "off",
});
expectSingleToolErrorPayload(payloads, {
title: "Exec",
detail: "Command timed out after 1800 seconds. If this command is expected to take longer, re-run with a higher timeout (e.g., exec timeout=300).",
});
});
it("suppresses assistant text when a deterministic exec approval prompt was already delivered", () => {
expectNoPayloads({
assistantTexts: ["Approval is needed. Please run /approve abc allow-once"],
didSendDeterministicApprovalPrompt: true,
});
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.