fix: propagate max-step failures and unify task transcripts (#874)
Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
20
src/tests/agent/subagent-max-steps-propagation.test.ts
Normal file
20
src/tests/agent/subagent-max-steps-propagation.test.ts
Normal 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");
|
||||
});
|
||||
});
|
||||
29
src/tests/tools/task-foreground-transcript.test.ts
Normal file
29
src/tests/tools/task-foreground-transcript.test.ts
Normal 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}\`;`,
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user