fix: propagate max-step failures and unify task transcripts (#874)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2026-02-09 14:49:38 -08:00
committed by GitHub
parent 101fc6f874
commit 8e5bc3956f
6 changed files with 198 additions and 48 deletions

View File

@@ -0,0 +1,20 @@
import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
describe("subagent max_steps error propagation", () => {
test("non-zero exit path prefers parsed finalError over generic exit code", () => {
const managerPath = fileURLToPath(
new URL("../../agent/subagents/manager.ts", import.meta.url),
);
const source = readFileSync(managerPath, "utf-8");
expect(source).toContain(
"const propagatedError = state.finalError?.trim();",
);
expect(source).toContain(
`const fallbackError = stderr || \`Subagent exited with code \${exitCode}\`;`,
);
expect(source).toContain("error: propagatedError || fallbackError");
});
});

View File

@@ -0,0 +1,29 @@
import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
describe("Task foreground transcript wiring", () => {
test("writes foreground transcript start and result output", () => {
const taskPath = fileURLToPath(
new URL("../../tools/impl/Task.ts", import.meta.url),
);
const source = readFileSync(taskPath, "utf-8");
expect(source).toContain("const foregroundTaskId = getNextTaskId();");
expect(source).toContain(
"const outputFile = createBackgroundOutputFile(foregroundTaskId);",
);
expect(source).toContain(
"writeTaskTranscriptStart(outputFile, description, subagent_type);",
);
expect(source).toContain(
"writeTaskTranscriptResult(outputFile, result, header);",
);
expect(source).toContain(
`return \`\${truncatedOutput}\\nOutput file: \${outputFile}\`;`,
);
expect(source).toContain(
`return \`Error: \${errorMessage}\\nOutput file: \${outputFile}\`;`,
);
});
});