fix(eval): surfaced subagent abort reason

- Used `||` so empty stderr no longer masks the real abort reason.
This commit is contained in:
can1357
2026-06-06 20:54:00 +02:00
parent 4ae58e1abc
commit bdbbfa9778
2 changed files with 22 additions and 1 deletions
@@ -231,6 +231,27 @@ describe("runEvalAgent", () => {
});
await expect(runEvalAgent({ prompt: "fail" }, { session: makeSession() })).rejects.toThrow("boom");
});
it("surfaces the abort reason when an aborted subagent has empty stderr", async () => {
// An aborted subagent returns exitCode 1 with stderr "" and error
// undefined; the real reason lives in abortReason. The bridge must not
// collapse the failure message to "" (which the Python prelude renders as
// the info-free "bridge call '__agent__' failed").
mockAgents();
vi.spyOn(taskExecutor, "runSubprocess").mockImplementation(async options =>
singleResult(options, {
exitCode: 1,
output: "",
stderr: "",
aborted: true,
abortReason: "Subagent runtime limit exceeded (task.maxRuntimeMs=1000)",
}),
);
await expect(runEvalAgent({ prompt: "hello" }, { session: makeSession() })).rejects.toThrow(
"Subagent runtime limit exceeded (task.maxRuntimeMs=1000)",
);
});
});
describe("agent() through eval runtimes", () => {
@@ -280,7 +280,7 @@ export async function runEvalAgent(args: unknown, options: EvalAgentBridgeOption
if (result.exitCode !== 0 || result.error) {
const failureMessage =
result.error ?? result.stderr ?? result.abortReason ?? `agent() subagent '${agentName}' failed.`;
result.error || result.stderr || result.abortReason || `agent() subagent '${agentName}' failed.`;
throw new ToolError(failureMessage);
}