Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): e2e - stabilize delegated HITL smoke (#303)

Andrew Barba7959021cc989
diff --git a/.github/workflows/e2e-local.yml b/.github/workflows/e2e-local.yml
index 8bbd4f609..642caa3ad 100644
--- a/.github/workflows/e2e-local.yml
+++ b/.github/workflows/e2e-local.yml
@@ -83,5 +83,6 @@ jobs:
.junit
e2e/fixtures/*/.eve/evals
apps/fixtures/*/.eve/evals
+ include-hidden-files: true
if-no-files-found: ignore
retention-days: 7
diff --git a/.github/workflows/e2e-vercel.yml b/.github/workflows/e2e-vercel.yml
index 74d23ff90..0b97ecb7b 100644
--- a/.github/workflows/e2e-vercel.yml
+++ b/.github/workflows/e2e-vercel.yml
@@ -110,5 +110,6 @@ jobs:
.junit
e2e/fixtures/*/.eve/evals
apps/fixtures/*/.eve/evals
+ include-hidden-files: true
if-no-files-found: ignore
retention-days: 7
diff --git a/e2e/fixtures/agent-subagents-hitl/agent/instructions.md b/e2e/fixtures/agent-subagents-hitl/agent/instructions.md
index 84aa238bd..b35376156 100644
--- a/e2e/fixtures/agent-subagents-hitl/agent/instructions.md
+++ b/e2e/fixtures/agent-subagents-hitl/agent/instructions.md
@@ -1,4 +1,6 @@
# Identity
You are a helpful assistant. When the user explicitly asks you to use a named
-subagent, call that subagent and include its result in your final reply.
+subagent, call that subagent exactly once. After it returns, include its result
+in your final reply without calling any subagent again unless the user explicitly
+requested multiple calls.
diff --git a/e2e/fixtures/agent-subagents-hitl/agent/subagents/stock-price/instructions.md b/e2e/fixtures/agent-subagents-hitl/agent/subagents/stock-price/instructions.md
index 1ce914186..3fd3c1c46 100644
--- a/e2e/fixtures/agent-subagents-hitl/agent/subagents/stock-price/instructions.md
+++ b/e2e/fixtures/agent-subagents-hitl/agent/subagents/stock-price/instructions.md
@@ -1 +1,3 @@
-You are a stock price lookup agent. When given a ticker symbol, use your tools to look up the current price and return a concise summary.
+You are a stock price lookup agent. When given a ticker symbol, call the
+get_stock_price tool exactly once, then return a concise summary without calling
+any tool again.
diff --git a/e2e/fixtures/agent-subagents-hitl/agent/subagents/stock-price/tools/get_stock_price.ts b/e2e/fixtures/agent-subagents-hitl/agent/subagents/stock-price/tools/get_stock_price.ts
index 97a7f0c6f..bfdacf6af 100644
--- a/e2e/fixtures/agent-subagents-hitl/agent/subagents/stock-price/tools/get_stock_price.ts
+++ b/e2e/fixtures/agent-subagents-hitl/agent/subagents/stock-price/tools/get_stock_price.ts
@@ -1,4 +1,5 @@
import { defineTool } from "eve/tools";
+import { once } from "eve/tools/approval";
import { z } from "zod";
const MOCK_PRICES: Record<string, { price: number; change: number }> = {
@@ -15,7 +16,7 @@ export default defineTool({
inputSchema: z.object({
ticker: z.string().describe("Stock ticker symbol"),
}),
- approval: () => "user-approval",
+ approval: once(),
async execute(input) {
const ticker = input.ticker.toUpperCase();
const data = MOCK_PRICES[ticker];
diff --git a/e2e/fixtures/agent-subagents-hitl/evals/hitl.eval.ts b/e2e/fixtures/agent-subagents-hitl/evals/hitl.eval.ts
index a4bfdbc6f..f26c7f1ef 100644
--- a/e2e/fixtures/agent-subagents-hitl/evals/hitl.eval.ts
+++ b/e2e/fixtures/agent-subagents-hitl/evals/hitl.eval.ts
@@ -19,7 +19,7 @@ function subagentOutputs(events: readonly HandleMessageStreamEvent[]): string[]
/**
* Parent/child HITL proxying: the stock-price subagent's tool approval
- * (`approval: () => "user-approval"`) surfaces on the parent stream, the approval
+ * (`approval: once()`) surfaces on the parent stream, the approval
* routes back down, and the child's result splices into the parent reply.
* Parking is server-side.
*/
@@ -28,7 +28,7 @@ export default defineEval({
async test(t) {
await t.send(
- `Use the stock-price subagent with message 'Call the get_stock_price tool with ticker "GOOG".'. When it finishes, include the exact stock price in your reply.`,
+ `Call the stock-price subagent exactly once with message 'Call the get_stock_price tool exactly once with ticker "GOOG". After it returns, do not call any tool again; return the result.'. After that single subagent call finishes, do not call any subagent or tool again; include the exact stock price in your final reply.`,
);
// The child's approval request must surface on the parent stream.
@@ -38,14 +38,43 @@ export default defineEval({
const resumed = await t.respondAll("approve");
resumed.expectOk();
+ t.event(
+ (events) =>
+ events.filter(
+ (event) => event.type === "subagent.called" && event.data.name === "stock-price",
+ ).length === 1,
+ "stock-price subagent was called exactly once",
+ );
+
+ if (resumed.inputRequests.length > 0) {
+ const requests = resumed.inputRequests.map((request) => ({
+ requestId: request.requestId,
+ toolName: request.action.kind === "tool-call" ? request.action.toolName : undefined,
+ }));
+ throw new Error(
+ `Subagent re-parked after approval with input requests: ${JSON.stringify(requests)}.`,
+ );
+ }
const outputs = subagentOutputs(t.events);
if (!outputs.some((output) => output.includes(GOOG_PRICE))) {
+ const failedActions = t.events.flatMap((event) => {
+ if (event.type !== "action.result") return [];
+ if (event.data.status !== "failed" && event.data.result.isError !== true) return [];
+ return [event.data.result];
+ });
+ const recentEventTypes = t.events.slice(-20).map((event) => event.type);
throw new Error(
- `No subagent.completed output contained the GOOG price; got [${outputs.join(", ")}].`,
+ [
+ `No subagent.completed output contained the GOOG price; got [${outputs.join(", ")}].`,
+ `Resumed turn status: ${resumed.status}.`,
+ `Failed actions: ${JSON.stringify(failedActions)}.`,
+ `Recent events: [${recentEventTypes.join(", ")}].`,
+ ].join(" "),
);
}
+ t.noFailedActions();
t.didNotFail();
t.completed();
t.messageIncludes(GOOG_PRICE);
diff --git a/packages/eve/test/tui-client/tui-subagents-weather.ts b/packages/eve/test/tui-client/tui-subagents-weather.ts
index 2d692c31b..18e2209cf 100644
--- a/packages/eve/test/tui-client/tui-subagents-weather.ts
+++ b/packages/eve/test/tui-client/tui-subagents-weather.ts
@@ -11,7 +11,7 @@ import { theme } from "./lib/theme.ts";
* Multi-message subagent smoke driving `e2e/fixtures/agent-subagents-hitl` and its
* `stock-price` subagent. The subagent emits a pre-tool message
* ("I'll look up..."), calls `get_stock_price` (which has
- * `needsApproval: () => true`), and then emits a post-tool message
+ * `approval: once()`), and then emits a post-tool message
* with the result. This is the real-world flow that broke the earlier
* stepIndex-keyed implementation, both pre and post messages were
* landing under `stepIndex: 0` and collapsing into one box.
@@ -57,10 +57,10 @@ run({ app: "agent-subagents-hitl", kind: "local-build" }, async (target) => {
// Delegate explicitly. An implicit prompt ("what is the value of GOOG?")
// leaves the choice to the model, which may answer directly instead of
- // delegating; naming the subagent keeps the flow this smoke exercises
- // deterministic. The price itself is fixed by the subagent's fixture tool.
+ // delegating. Explicitly limiting the request to one delegation also keeps
+ // the model from re-checking the fixed fixture result with a second child.
input.type(
- `Use the stock-price subagent with message 'Call the get_stock_price tool with ticker "${TICKER}".'. When it finishes, include the exact stock price in your reply.`,
+ `Call the stock-price subagent exactly once with message 'Call the get_stock_price tool exactly once with ticker "${TICKER}". After it returns, do not call any tool again; return the result.'. After that single subagent call finishes, do not call any subagent or tool again; include the exact stock price in your final reply.`,
);
input.enter();