Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): propagate terminal subagent model-call failures to the parent (#493)

Ruic0a0ae26468b
diff --git a/.changeset/subagent-terminal-error-propagation.md b/.changeset/subagent-terminal-error-propagation.md
new file mode 100644
index 000000000..7bd5abddd
--- /dev/null
+++ b/.changeset/subagent-terminal-error-propagation.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Terminal model-call failures in delegated subagent runs (e.g. an unresolvable model id returning 404) now propagate to the parent as a failed subagent result instead of a successful empty output, so orchestrator sessions no longer report success when a delegation failed.
diff --git a/packages/eve/src/harness/tool-loop.test.ts b/packages/eve/src/harness/tool-loop.test.ts
index 619a4e8e3..6d3f40ce8 100644
--- a/packages/eve/src/harness/tool-loop.test.ts
+++ b/packages/eve/src/harness/tool-loop.test.ts
@@ -2696,6 +2696,39 @@ describe("createToolLoopHarness", () => {
expect(types).not.toContain("session.waiting");
});
+ it("surfaces a terminal model-call error to the parent as a failed task result", async () => {
+ // Regression test for https://github.com/vercel/eve/issues/412 — a
+ // delegated subagent runs in task mode; when its model id does not
+ // resolve (terminal 404), the failure must reach the parent as an
+ // error result, not a successful empty output.
+ const error = Object.assign(new Error("No endpoints found for anthropic/claude-3.5-haiku"), {
+ name: "AI_APICallError",
+ statusCode: 404,
+ });
+ setupMockAgentError(error);
+
+ const { emit, events } = createEventCollector();
+ const runStep = createToolLoopHarness(createTestConfig("task", emit));
+
+ const result = await runStep(createTestSession(), { message: "Delegated task" });
+
+ // The task's terminal result must be marked as an error with the
+ // failure message as output, mirroring the non-terminal task-mode
+ // failure shape. Today the terminal branch returns
+ // `{ done: true, output: "" }`, which the parent driver treats as a
+ // successful delegation with empty output.
+ expect(result.next).toMatchObject({
+ done: true,
+ isError: true,
+ output: expect.stringContaining("No endpoints found for anthropic/claude-3.5-haiku"),
+ });
+
+ const types = events.map((e) => e.type);
+ expect(types).toContain("step.failed");
+ expect(types).toContain("turn.failed");
+ expect(types).toContain("session.failed");
+ });
+
it("emits the full terminal failure cascade on an explicit Gateway invalid-request error", async () => {
setupMockAgentError(
createGatewayModelCallError({
diff --git a/packages/eve/src/harness/tool-loop.ts b/packages/eve/src/harness/tool-loop.ts
index b08903b1a..9bcc35963 100644
--- a/packages/eve/src/harness/tool-loop.ts
+++ b/packages/eve/src/harness/tool-loop.ts
@@ -994,8 +994,15 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {
message: errorMessage,
sessionId: session.sessionId,
});
+ // In task mode (delegated subagent runs) the terminal failure
+ // must be the task's error result so the parent driver resumes
+ // with a failed `subagent-result` instead of a successful empty
+ // output (https://github.com/vercel/eve/issues/412).
return {
- next: { done: true, output: "" },
+ next:
+ config.mode === "task"
+ ? { done: true, isError: true, output: errorMessage }
+ : { done: true, output: "" },
session,
};
}