fix(cron): treat embedded error payloads as run failures

(cherry picked from commit 50fd31c070)
This commit is contained in:
chilu18
2026-02-23 19:16:57 +00:00
committed by Peter Steinberger
parent 75969ed5c4
commit 8c8374defa
2 changed files with 49 additions and 4 deletions

View File

@@ -27,9 +27,9 @@ function makeDeps(): CliDeps {
};
}
function mockEmbeddedTexts(texts: string[]) {
function mockEmbeddedPayloads(payloads: Array<{ text?: string; isError?: boolean }>) {
vi.mocked(runEmbeddedPiAgent).mockResolvedValue({
payloads: texts.map((text) => ({ text })),
payloads,
meta: {
durationMs: 5,
agentMeta: { sessionId: "s", provider: "p", model: "m" },
@@ -37,6 +37,10 @@ function mockEmbeddedTexts(texts: string[]) {
});
}
function mockEmbeddedTexts(texts: string[]) {
mockEmbeddedPayloads(texts.map((text) => ({ text })));
}
function mockEmbeddedOk() {
mockEmbeddedTexts(["ok"]);
}
@@ -174,6 +178,25 @@ describe("runCronIsolatedAgentTurn", () => {
});
});
it("returns error when embedded run payload is marked as error", async () => {
await withTempHome(async (home) => {
mockEmbeddedPayloads([
{
text: "⚠️ 🛠️ Exec failed: /bin/bash: line 1: python: command not found",
isError: true,
},
]);
const { res } = await runCronTurn(home, {
jobPayload: DEFAULT_AGENT_TURN_PAYLOAD,
mockTexts: null,
});
expect(res.status).toBe("error");
expect(res.error).toContain("command not found");
expect(res.summary).toContain("Exec failed");
});
});
it("passes resolved agentDir to runEmbeddedPiAgent", async () => {
await withTempHome(async (home) => {
const { res } = await runCronTurn(home, {