Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

refactor(eve): deliver task results in notifications (#2282)

Rui2838bb37c65e
diff --git a/.changeset/silent-redundant-task-wakes.md b/.changeset/silent-redundant-task-wakes.md
new file mode 100644
index 000000000..9b36fc6c7
--- /dev/null
+++ b/.changeset/silent-redundant-task-wakes.md
@@ -0,0 +1,5 @@
+---
+"eve": minor
+---
+
+Remove `task_peek` from experimental background tasks and include completed results and failures directly in task notifications. Conditionally delivered task wakes can remain silent when that result was already covered by an earlier response.
diff --git a/e2e/fixtures/fixture-tasks/agent/agent.ts b/e2e/fixtures/fixture-tasks/agent/agent.ts
index 88e23a234..0eaf515a8 100644
--- a/e2e/fixtures/fixture-tasks/agent/agent.ts
+++ b/e2e/fixtures/fixture-tasks/agent/agent.ts
@@ -10,6 +10,10 @@ import {
const TASK_ID_PATTERN = /task_[a-z0-9]+/iu;
const EMPTY_DELIVERY_SENTINEL = "<eve-empty-delivery/>";
const CONDITIONAL_DELIVERY_MARKER = "Conditional delivery";
+const REDUNDANT_REVIEW_SCENARIO = "TASK-WAKE-REDUNDANT-REVIEW";
+const REDUNDANT_REVIEW_FINDING = "blocker: task admission can discard deferred user input.";
+const REDUNDANT_DELIVERY_GUIDANCE =
+ "results already delivered or incorporated into an earlier response";
function respond(request: MockModelRequest): MockModelResponse | string {
// Framework agent-list notes are model context, not scenario turns.
@@ -25,31 +29,56 @@ function respond(request: MockModelRequest): MockModelResponse | string {
return laterBusyWorker(request, message);
}
if (message.startsWith("TASK-A2-CHILD-FAILURE-VERIFY ")) {
- return peekTask(request, "task-a2-child-failure-verify", "TASK-A2-FAILED", message);
+ return inspectTerminalTask(
+ request,
+ "task-a2-child-failure-verify",
+ "TASK-A2-FAILED",
+ message,
+ "failed",
+ );
}
if (message.startsWith("TASK-A3-UNKNOWN-VERIFY ")) {
- return peekTask(request, "task-a3-unknown-verify", "TASK-A3-UNKNOWN", message);
+ return inspectTerminalTask(request, "task-a3-unknown-verify", "TASK-A3-UNKNOWN", message);
}
if (message.startsWith("TASK-D6-PARTIAL-FANOUT-VERIFY ")) {
- return peekTask(request, "task-d6-partial-fanout-verify", "TASK-D6-STATUS", message);
+ return inspectTerminalTask(
+ request,
+ "task-d6-partial-fanout-verify",
+ "TASK-D6-STATUS",
+ message,
+ "completed",
+ );
}
if (message.startsWith("TASK-D6-PARTIAL-FANOUT-UNKNOWN ")) {
- return peekTask(request, "task-d6-partial-fanout-unknown", "TASK-D6-UNKNOWN", message);
+ return inspectTerminalTask(
+ request,
+ "task-d6-partial-fanout-unknown",
+ "TASK-D6-UNKNOWN",
+ message,
+ );
}
if (message.startsWith("TASK-C7-AUTHORIZATION-VERIFY ")) {
- return peekTask(request, "task-c7-authorization-verify", "TASK-C7-STATUS", message);
+ return inspectTerminalTask(
+ request,
+ "task-c7-authorization-verify",
+ "TASK-C7-STATUS",
+ message,
+ "completed",
+ );
}
if (message.startsWith("TASK-C8-REMOTE-VERIFY ")) {
- return peekTask(request, "task-c8-remote-verify", "TASK-C8-STATUS", message);
+ return inspectTerminalTask(
+ request,
+ "task-c8-remote-verify",
+ "TASK-C8-STATUS",
+ message,
+ "completed",
+ );
}
if (message.includes("TASK-C8-REMOTE-CHILD")) return runRemoteGate(request);
if (message.startsWith("Background task ")) {
- if (request.userMessages.includes("TASK-WAKE-CONDITIONAL-DELIVERY")) {
- return request.messages.some(
- (entry) => entry.role === "system" && entry.text.includes(CONDITIONAL_DELIVERY_MARKER),
- )
- ? EMPTY_DELIVERY_SENTINEL
- : "TASK-WAKE-WAS-NOT-CONDITIONAL";
+ if (request.userMessages.includes(REDUNDANT_REVIEW_SCENARIO)) {
+ return handleRedundantReviewWake(request, message);
}
// Scenarios that act on wake notifications route to their script;
// every other scenario acknowledges them without running tools.
@@ -64,26 +93,45 @@ function respond(request: MockModelRequest): MockModelResponse | string {
if (message === "TASK-FANOUT-PARENT-UPDATES") return fanoutTasks(request, 10);
if (message === "TASK-PARENT-WAKE-UPDATES") return fanoutTasks(request, 3);
- if (message === "TASK-WAKE-CONDITIONAL-DELIVERY") return startConditionalWakeWorker(request);
+ if (message === REDUNDANT_REVIEW_SCENARIO) return startRedundantReviewers(request);
if (message === "TASK-FAN-IN") return fanInTasks(request);
if (message === "TASK-UPDATE-SETUP") return startTaskUpdateChild(request);
if (message === "TASK-CANCEL-SETUP") return setupCancelWorker(request);
if (message.startsWith("TASK-CANCEL-VERIFY ")) {
- return peekTask(request, "task-cancel-verify", "TASK-CANCEL-STATUS", message);
+ return inspectTerminalTask(
+ request,
+ "task-cancel-verify",
+ "TASK-CANCEL-STATUS",
+ message,
+ "cancelled",
+ );
}
if (message.startsWith("TASK-HITL-VERIFY ")) {
- return peekTask(request, "task-hitl-verify", "TASK-HITL-STATUS", message);
+ return inspectTerminalTask(
+ request,
+ "task-hitl-verify",
+ "TASK-HITL-STATUS",
+ message,
+ "completed",
+ );
}
if (message.startsWith("TASK-INPUT-BATCH-VERIFY ")) {
- return peekTask(request, "task-input-batch-verify", "TASK-INPUT-BATCH-STATUS", message);
+ return inspectTerminalTask(
+ request,
+ "task-input-batch-verify",
+ "TASK-INPUT-BATCH-STATUS",
+ message,
+ "completed",
+ );
}
if (message.startsWith("CHILD-TASK-EXCLUSIVITY-VERIFY ")) {
- return peekTask(
+ return inspectTerminalTask(
request,
"child-task-exclusivity-verify",
"CHILD-TASK-EXCLUSIVITY-STATUS",
message,
+ "completed",
);
}
if (message === "TASK-HITL-ROUTING") {
@@ -129,19 +177,53 @@ function startTaskUpdateChild(request: MockModelRequest): MockModelResponse | st
return "TASK-UPDATE-STARTED";
}
-function startConditionalWakeWorker(request: MockModelRequest): MockModelResponse | string {
- if (resultById(request, "task-conditional-wake-worker") === undefined) {
+function startRedundantReviewers(request: MockModelRequest): MockModelResponse | string {
+ const reviewers = [
+ {
+ id: "task-redundant-review-fast",
+ message: `Review PR #2277. Return this finding: ${REDUNDANT_REVIEW_FINDING}`,
+ },
+ {
+ id: "task-redundant-review-late",
+ message: `BUSY-WORKER-A Review PR #2277. Return this finding: ${REDUNDANT_REVIEW_FINDING}`,
+ },
+ ] as const;
+ const pending = reviewers.filter(({ id }) => resultById(request, id) === undefined);
+ if (pending.length > 0) {
return {
- toolCalls: [
- {
- id: "task-conditional-wake-worker",
- input: { message: "TASK-WAKE-CONDITIONAL-CHILD" },
- name: "busy-worker",
- },
- ],
+ toolCalls: pending.map(({ id, message }) => ({
+ id,
+ input: { message },
+ name: "busy-worker",
+ })),
};
}
- return "TASK-WAKE-CONDITIONAL-STARTED";
+ return "TASK-REDUNDANT-REVIEWERS-STARTED";
+}
+
+function handleRedundantReviewWake(
+ request: MockModelRequest,
+ message: string,
+): MockModelResponse | string {
+ if (!message.includes(REDUNDANT_REVIEW_FINDING)) {
+ throw new Error("The completed reviewer did not return the expected finding.");
+ }
+
+ const findingWasAlreadyReported = request.messages.some(
+ (entry) => entry.role === "assistant" && entry.text.includes(REDUNDANT_REVIEW_FINDING),
+ );
+ if (!findingWasAlreadyReported) {
+ return `request changes on PR #2277.\n\n- ${REDUNDANT_REVIEW_FINDING}`;
+ }
+
+ const conditionalInstruction = request.messages.find(
+ (entry) => entry.role === "system" && entry.text.includes(CONDITIONAL_DELIVERY_MARKER),
+ );
+ if (conditionalInstruction === undefined) return "TASK-WAKE-WAS-NOT-CONDITIONAL";
+
+ return conditionalInstruction.text.includes(REDUNDANT_DELIVERY_GUIDANCE)
+ ? EMPTY_DELIVERY_SENTINEL
+ : "already incorporated into the review above.";
}
function sendTaskUpdate(request: MockModelRequest): MockModelResponse | string {
@@ -199,43 +281,19 @@ function fanInTasks(request: MockModelRequest): MockModelResponse | string {
return "TASK-FAN-IN-STARTED";
}
-/**
- * The deterministic join predicate: on every wake, peek every fan-in task
- * and answer only when all of them are completed. This is the model-side
- * join contract — the framework delivers one wake
- * per ready transition and the model decides whether the state suffices.
- */
+/** The model-side join derives completion from the result-bearing notifications already in history. */
function fanInNotification(request: MockModelRequest): MockModelResponse | string {
- const callId = `task-fan-in-check-${scenarioUserMessageCount(request)}`;
- const checked = resultById(request, callId);
const taskIds = FAN_IN_CALL_IDS.map((id) => findTaskId(resultById(request, id)?.output)).filter(
(taskId): taskId is string => taskId !== undefined,
);
if (taskIds.length !== FAN_IN_CALL_IDS.length) {
throw new Error("Fan-in notification arrived before both task receipts.");
}
- if (checked === undefined) {
- return { toolCalls: [{ id: callId, input: { taskIds }, name: "task_peek" }] };
- }
- return allTasksCompleted(checked.output, taskIds)
+ return taskIds.every((taskId) => hasTaskNotification(request, taskId, "completed"))
? "TASK-FAN-IN-COMPLETE"
: "TASK-FAN-IN-WAITING";
}
-function allTasksCompleted(output: unknown, expectedTaskIds: readonly string[]): boolean {
- if (output === null || typeof output !== "object") return false;
- const tasks = Reflect.get(output, "tasks");
- if (!Array.isArray(tasks) || tasks.length !== expectedTaskIds.length) return false;
- const byId = new Map(
- tasks
- .filter((task) => task !== null && typeof task === "object")
- .map((task) => [Reflect.get(task, "taskId"), task] as const),
- );
- return expectedTaskIds.every(
- (taskId) => Reflect.get(byId.get(taskId) ?? {}, "status") === "completed",
- );
-}
-
function setupCancelWorker(request: MockModelRequest): MockModelResponse | string {
if (resultById(request, "task-cancel-worker") === undefined) {
return {
@@ -325,21 +383,36 @@ function runRemoteGate(request: MockModelRequest): MockModelResponse | string {
return `C8-REMOTE-COMPLETE ${marker}`;
}
-function peekTask(
+function inspectTerminalTask(
request: MockModelRequest,
callIdPrefix: string,
completedText: string,
message: string,
+ status?: "cancelled" | "completed" | "failed",
): MockModelResponse | string {
+ const taskId = TASK_ID_PATTERN.exec(message)?.[0];
+ if (taskId === undefined) throw new Error(`Verification message has no task id: ${message}`);
+ if (status !== undefined && !hasTaskNotification(request, taskId, status)) {
+ return `${completedText}-WAITING`;
+ }
const callId = `${callIdPrefix}-${scenarioUserMessageCount(request)}`;
if (resultById(request, callId) === undefined) {
- const taskId = TASK_ID_PATTERN.exec(message)?.[0];
- if (taskId === undefined) throw new Error(`Verification message has no task id: ${message}`);
- return { toolCalls: [{ id: callId, input: { taskIds: [taskId] }, name: "task_peek" }] };
+ return { toolCalls: [{ id: callId, input: { taskIds: [taskId] }, name: "task_cancel" }] };
}
return completedText;
}
+function hasTaskNotification(
+ request: MockModelRequest,
+ taskId: string,
+ status: "cancelled" | "completed" | "failed",
+): boolean {
+ const statusText = status === "failed" ? " failed." : ` is ${status}.`;
+ return request.userMessages.some(
+ (entry) => entry.includes(`Background task ${taskId} (`) && entry.includes(statusText),
+ );
+}
+
function isScenarioMessage(message: string): boolean {
return !message.startsWith("[Agents]");
}
diff --git a/e2e/fixtures/fixture-tasks/evals/shared.ts b/e2e/fixtures/fixture-tasks/evals/shared.ts
index 5c99fc192..a3fae096a 100644
--- a/e2e/fixtures/fixture-tasks/evals/shared.ts
+++ b/e2e/fixtures/fixture-tasks/evals/shared.ts
@@ -87,13 +87,13 @@ export function requireBackgroundTaskId(turn: EveEvalTurn): string {
throw new Error("Turn completed without a background task receipt.");
}
-/** Returns the exact model-visible task view for one owned task id. */
+/** Returns the exact model-visible task view from a task-control result. */
export function requireTaskView(output: unknown, taskId: string): Record<string, unknown> {
if (output === null || typeof output !== "object") {
- throw new Error("task_peek did not return an object.");
+ throw new Error("Task control did not return an object.");
}
const tasks = Reflect.get(output, "tasks");
- if (!Array.isArray(tasks)) throw new Error("task_peek did not return a tasks array.");
+ if (!Array.isArray(tasks)) throw new Error("Task control did not return a tasks array.");
const matches = tasks.filter(
(candidate) =>
candidate !== null &&
@@ -101,7 +101,7 @@ export function requireTaskView(output: unknown, taskId: string): Record<string,
Reflect.get(candidate, "taskId") === taskId,
);
if (matches.length !== 1) {
- throw new Error(`task_peek returned ${matches.length} views for ${taskId}.`);
+ throw new Error(`Task control returned ${matches.length} views for ${taskId}.`);
}
return matches[0] as Record<string, unknown>;
}
@@ -138,7 +138,7 @@ export async function sendAndFollowQueuedTurn(
throw new Error(`Queued message "${message}" was not received after 20 turns.`);
}
-/** Polls the non-blocking task view until the expected task is completed. */
+/** Waits for completion, then reads the immutable terminal view through no-op cancellation. */
export async function waitForCompletedTask(
t: EveEvalContext,
session: TaskEvalSessionDriver,
@@ -148,7 +148,7 @@ export async function waitForCompletedTask(
return await waitForTaskStatus(t, session, verificationMessage, taskId, "completed");
}
-/** Polls the non-blocking task view until the expected task reaches `status`. */
+/** Waits for a terminal status, then reads it through no-op cancellation. */
export async function waitForTaskStatus(
t: EveEvalContext,
session: TaskEvalSessionDriver,
@@ -170,20 +170,20 @@ export async function waitForTaskStatus(
}
const turn = followed.turn;
currentSession = followed.session;
- const peeked = turn.toolCalls.find((call) => call.name === "task_peek");
- if (taskStatus(peeked?.output, taskId) === status) {
+ const inspected = turn.toolCalls.find((call) => call.name === "task_cancel");
+ if (taskStatus(inspected?.output, taskId) === status) {
await t.require(
- peeked?.output,
+ inspected?.output,
satisfies(
(output) => taskStatus(output, taskId) === status,
- `task_peek returns ${status} task ${taskId}`,
+ `task_cancel preserves ${status} task ${taskId}`,
),
);
return turn;
}
await t.sleep(100);
}
- throw new Error(`Task ${taskId} did not reach "${status}" after 20 task_peek attempts.`);
+ throw new Error(`Task ${taskId} did not reach "${status}" after 20 verification attempts.`);
}
function messageText(message: unknown): string {
diff --git a/e2e/fixtures/fixture-tasks/evals/task.agent.continue.accepted-terminal-available.eval.ts b/e2e/fixtures/fixture-tasks/evals/task.agent.continue.accepted-terminal-available.eval.ts
index ddb31d8a9..88461aa20 100644
--- a/e2e/fixtures/fixture-tasks/evals/task.agent.continue.accepted-terminal-available.eval.ts
+++ b/e2e/fixtures/fixture-tasks/evals/task.agent.continue.accepted-terminal-available.eval.ts
@@ -42,7 +42,7 @@ export default defineTaskEval({
firstTaskId,
);
const firstView = requireTaskView(
- firstTerminal.requireToolCall("task_peek").output,
+ firstTerminal.requireToolCall("task_cancel").output,
firstTaskId,
);
const firstAgentId = requireAgentId(firstView);
@@ -82,7 +82,7 @@ export default defineTaskEval({
secondTaskId,
);
const secondView = requireTaskView(
- secondTerminal.requireToolCall("task_peek").output,
+ secondTerminal.requireToolCall("task_cancel").output,
secondTaskId,
);
await t.require(
diff --git a/e2e/fixtures/fixture-tasks/evals/task.agent.continue.rejected-agent-busy.eval.ts b/e2e/fixtures/fixture-tasks/evals/task.agent.continue.rejected-agent-busy.eval.ts
index 307dacf01..37bbb1790 100644
--- a/e2e/fixtures/fixture-tasks/evals/task.agent.continue.rejected-agent-busy.eval.ts
+++ b/e2e/fixtures/fixture-tasks/evals/task.agent.continue.rejected-agent-busy.eval.ts
@@ -29,7 +29,10 @@ export default defineTaskEval({
"CHILD-TASK-EXCLUSIVITY-VERIFY",
initialTaskId,
);
- const agentId = agentIdFromTaskView(initial.requireToolCall("task_peek").output, initialTaskId);
+ const agentId = agentIdFromTaskView(
+ initial.requireToolCall("task_cancel").output,
+ initialTaskId,
+ );
const race = await sendAndFollowQueuedTurn(t, "CHILD-TASK-EXCLUSIVITY-RACE", t, {
allowFailedActions: true,
diff --git a/e2e/fixtures/fixture-tasks/evals/task.authorization.callback.accepted-current-attempt.eval.ts b/e2e/fixtures/fixture-tasks/evals/task.authorization.callback.accepted-current-attempt.eval.ts
index 7a1b2dc63..f7228262a 100644
--- a/e2e/fixtures/fixture-tasks/evals/task.authorization.callback.accepted-current-attempt.eval.ts
+++ b/e2e/fixtures/fixture-tasks/evals/task.authorization.callback.accepted-current-attempt.eval.ts
@@ -5,7 +5,6 @@ import {
requireBackgroundTaskId,
requireSessionStreamIndex,
requireTaskView,
- sendAndFollowQueuedTurn,
type TaskEvalSessionDriver,
waitForCompletedTask,
} from "./shared.js";
@@ -44,25 +43,6 @@ export default defineTaskEval({
});
required.turn.notEvent("input.requested");
- const peeked = await sendAndFollowQueuedTurn(
- t,
- `TASK-C7-AUTHORIZATION-VERIFY ${taskId}`,
- required.session,
- );
- const taskCall = peeked.turn.requireToolCall("task_peek", { input: { taskIds: [taskId] } });
- const blockedView = requireTaskView(taskCall.output, taskId);
- const authorizationRequestId = `task:authorization:${required.event.data.attemptId ?? AUTHORIZATION_NAME}`;
- await t.require(
- blockedView,
- satisfies(
- (view: Record<string, unknown>) =>
- Reflect.get(view, "status") === "input_required" &&
- hasMetadata(view, "approval-worker", "local") &&
- hasAuthorizationBlocker(view, authorizationRequestId),
- "task view exposes only the reserved authorization blocker",
- ),
- );
-
const webhookUrl = required.event.data.webhookUrl;
if (webhookUrl === undefined) throw new Error("C7 authorization.required had no webhook URL.");
const callback = new URL(webhookUrl);
@@ -74,7 +54,7 @@ export default defineTaskEval({
const completed = await waitForAuthorizationEvent(
t,
- peeked.session,
+ required.session,
undefined,
"authorization.completed",
);
@@ -89,7 +69,7 @@ export default defineTaskEval({
"TASK-C7-AUTHORIZATION-VERIFY",
taskId,
);
- const terminalView = requireTaskView(terminal.requireToolCall("task_peek").output, taskId);
+ const terminalView = requireTaskView(terminal.requireToolCall("task_cancel").output, taskId);
await t.require(
terminalView,
satisfies(
@@ -115,29 +95,6 @@ export default defineTaskEval({
},
});
-function hasAuthorizationBlocker(
- view: Record<string, unknown>,
- authorizationRequestId: string,
-): boolean {
- const requests = Reflect.get(view, "inputRequests");
- return (
- Array.isArray(requests) &&
- requests.length === 1 &&
- Reflect.get(requests[0] ?? {}, "requestId") === authorizationRequestId &&
- Reflect.get(requests[0] ?? {}, "blockedOn") === "authorization"
- );
-}
-
-function hasMetadata(view: Record<string, unknown>, name: string, mode: string): boolean {
- const metadata = Reflect.get(view, "metadata");
- return (
- metadata !== null &&
- typeof metadata === "object" &&
- Reflect.get(metadata, "name") === name &&
- Reflect.get(metadata, "mode") === mode
- );
-}
-
async function waitForAuthorizationEvent<TType extends AuthorizationEvent["type"]>(
t: EveEvalContext,
initialSession: TaskEvalSessionDriver,
diff --git a/e2e/fixtures/fixture-tasks/evals/task.dispatch-batch.start.accepted-partial-failure.eval.ts b/e2e/fixtures/fixture-tasks/evals/task.dispatch-batch.start.accepted-partial-failure.eval.ts
index da9aebac9..ac1d5783d 100644
--- a/e2e/fixtures/fixture-tasks/evals/task.dispatch-batch.start.accepted-partial-failure.eval.ts
+++ b/e2e/fixtures/fixture-tasks/evals/task.dispatch-batch.start.accepted-partial-failure.eval.ts
@@ -125,7 +125,7 @@ function requireReceiptTaskId(receipts: readonly BackgroundReceipt[], callId: st
function assertCompletedBusyWorker(turn: EveEvalTurn, taskId: string, marker: string): void {
turn.expectOk();
turn.messageIncludes("TASK-D6-STATUS");
- const view = requireTaskView(turn.requireToolCall("task_peek").output, taskId);
+ const view = requireTaskView(turn.requireToolCall("task_cancel").output, taskId);
const metadata = Reflect.get(view, "metadata");
const lastOutput = Reflect.get(view, "lastOutput");
if (
diff --git a/e2e/fixtures/fixture-tasks/evals/task.input.answer.accepted-complete.remote.eval.ts b/e2e/fixtures/fixture-tasks/evals/task.input.answer.accepted-complete.remote.eval.ts
index 42fa59592..6573dcc52 100644
--- a/e2e/fixtures/fixture-tasks/evals/task.input.answer.accepted-complete.remote.eval.ts
+++ b/e2e/fixtures/fixture-tasks/evals/task.input.answer.accepted-complete.remote.eval.ts
@@ -54,7 +54,7 @@ export default defineTaskEval({
const terminal = await waitForCompletedTask(t, gate.session, "TASK-C8-REMOTE-VERIFY", taskId);
terminal.expectOk();
- const view = requireTaskView(terminal.requireToolCall("task_peek").output, taskId);
+ const view = requireTaskView(terminal.requireToolCall("task_cancel").output, taskId);
await t.require(
view,
satisfies(
diff --git a/e2e/fixtures/fixture-tasks/evals/task.input.route.observed-stale-unrouted.eval.ts b/e2e/fixtures/fixture-tasks/evals/task.input.route.observed-stale-unrouted.eval.ts
index 08c883bfd..d1982cafc 100644
--- a/e2e/fixtures/fixture-tasks/evals/task.input.route.observed-stale-unrouted.eval.ts
+++ b/e2e/fixtures/fixture-tasks/evals/task.input.route.observed-stale-unrouted.eval.ts
@@ -1,8 +1,5 @@
-import { satisfies } from "eve/evals/expect";
-
import {
requireBackgroundTaskId,
- requireTaskView,
sendAndFollowQueuedTurn,
waitForCompletedTask,
waitForTaskInput,
@@ -35,7 +32,6 @@ export default defineTaskEval({
firstAnswer.expectOk();
const second = await waitForTaskInput(t, first.session, "second_gate");
- const secondChildRequestId = second.request.requestId.replace(`${taskId}:`, "");
const stale = await second.session.respond([
{
optionId: "approve",
@@ -51,23 +47,10 @@ export default defineTaskEval({
`TASK-INPUT-BATCH-VERIFY ${taskId}`,
second.session,
);
- const peeked = afterStale.turn.toolCalls.find((call) => call.name === "task_peek");
- await t.require(
- peeked?.output,
- satisfies((output) => {
- const view = requireTaskView(output, taskId);
- const requests = Reflect.get(view, "inputRequests");
- return (
- Reflect.get(view, "status") === "input_required" &&
- Array.isArray(requests) &&
- requests.length === 1 &&
- Reflect.get(requests[0], "requestId") === secondChildRequestId
- );
- }, "the stale Q1 answer leaves exactly Q2 outstanding"),
- );
+ afterStale.turn.notCalledTool("task_cancel");
- // If the stale Q1 answer cleared Q2, this exact Q2 response cannot resume
- // the child and the task never reaches `completed`.
+ // This exact Q2 response can only resume the child if the stale Q1 answer
+ // left Q2 outstanding. Completion below is the externally observable proof.
const secondAnswer = await afterStale.session.respond([
{
optionId: "approve",
diff --git a/e2e/fixtures/fixture-tasks/evals/task.join.evaluate.observed-all-terminal.eval.ts b/e2e/fixtures/fixture-tasks/evals/task.join.evaluate.observed-all-terminal.eval.ts
index a022eb6c7..e46479ee1 100644
--- a/e2e/fixtures/fixture-tasks/evals/task.join.evaluate.observed-all-terminal.eval.ts
+++ b/e2e/fixtures/fixture-tasks/evals/task.join.evaluate.observed-all-terminal.eval.ts
@@ -13,7 +13,7 @@ const FAN_IN_CALLS = [
type FanInMarker = (typeof FAN_IN_CALLS)[number]["marker"];
-/** A join completes only from a peek proving its exact task set is terminal. */
+/** A join completes after result-bearing notifications cover its exact task set. */
export default defineTaskEval({
description: "A join observes both exact tasks completed before answering COMPLETE.",
transition: {
@@ -54,44 +54,25 @@ export default defineTaskEval({
released.expectOk();
const complete = await waitForTurnMessage(t, blocked.session, "TASK-FAN-IN-COMPLETE", released);
- const completePeek = complete.toolCalls.find((call) => call.name === "task_peek");
- await requireExactCompletedPeek(t, completePeek, taskIds, tasksByMarker);
+ complete.notCalledTool("task_peek");
+ for (const { marker } of FAN_IN_CALLS) {
+ const taskId = requireMappedValue(tasksByMarker, marker, "background task");
+ t.event("message.received", {
+ count: 1,
+ data: {
+ message: (message) =>
+ typeof message === "string" &&
+ message.includes(`Background task ${taskId} (`) &&
+ message.includes(" is completed.") &&
+ message.includes(`FANOUT-COMPLETE:${marker}`),
+ },
+ });
+ }
+ t.notCalledTool("task_peek");
t.noFailedActions();
},
});
-async function requireExactCompletedPeek(
- t: EveEvalContext,
- call: EveEvalTurn["toolCalls"][number] | undefined,
- taskIds: readonly string[],
- tasksByMarker: ReadonlyMap<FanInMarker, string>,
-): Promise<void> {
- await t.require(
- { input: call?.input, output: call?.output },
- satisfies((subject: { readonly input: unknown; readonly output: unknown }) => {
- const inputIds = Reflect.get(subject.input ?? {}, "taskIds");
- const tasks = Reflect.get(subject.output ?? {}, "tasks");
- if (!Array.isArray(inputIds) || !Array.isArray(tasks)) return false;
- const expectedIds = [...taskIds].sort();
- const outputIds = tasks.map((task) => Reflect.get(task, "taskId")).sort();
- return (
- JSON.stringify([...inputIds].sort()) === JSON.stringify(expectedIds) &&
- JSON.stringify(outputIds) === JSON.stringify(expectedIds) &&
- FAN_IN_CALLS.every(({ marker }) => {
- const taskId = tasksByMarker.get(marker);
- const task = tasks.find((candidate) => Reflect.get(candidate ?? {}, "taskId") === taskId);
- const lastOutput = Reflect.get(task ?? {}, "lastOutput");
- return (
- Reflect.get(task ?? {}, "status") === "completed" &&
- Reflect.get(lastOutput ?? {}, "type") === "result" &&
- Reflect.get(lastOutput ?? {}, "data") === `FANOUT-COMPLETE:${marker}`
- );
- })
- );
- }, "the COMPLETE turn peeks both exact tasks with their completed outputs"),
- );
-}
-
interface BlockedFanIn {
readonly requestsByMarker: ReadonlyMap<FanInMarker, InputRequest>;
readonly session: TaskEvalSessionDriver;
diff --git a/e2e/fixtures/fixture-tasks/evals/task.join.evaluate.observed-partial.eval.ts b/e2e/fixtures/fixture-tasks/evals/task.join.evaluate.observed-partial.eval.ts
index eef76b817..f76fd0bb6 100644
--- a/e2e/fixtures/fixture-tasks/evals/task.join.evaluate.observed-partial.eval.ts
+++ b/e2e/fixtures/fixture-tasks/evals/task.join.evaluate.observed-partial.eval.ts
@@ -39,9 +39,7 @@ export default defineTaskEval({
await requireDistinctTasks(t, taskIds);
const blocked = await waitForReleaseRequests(t, t, started);
- const marker1 = "TASK-FAN-IN-1";
const marker2 = "TASK-FAN-IN-2";
- const marker1TaskId = requireMappedValue(tasksByMarker, marker1, "background task");
const marker2TaskId = requireMappedValue(tasksByMarker, marker2, "background task");
const marker2Request = requireMappedValue(blocked.requestsByMarker, marker2, "release request");
@@ -56,16 +54,15 @@ export default defineTaskEval({
"TASK-FAN-IN-WAITING",
firstReleased,
);
- const waitingPeek = waiting.turn.toolCalls.find((call) => call.name === "task_peek");
- await requireExactPeek(
- t,
- waitingPeek,
- taskIds,
- [
- { marker: marker1, status: "input_required", taskId: marker1TaskId },
- { marker: marker2, status: "completed", taskId: marker2TaskId },
- ],
- "the join reads one completed and one input-required exact task",
+ await t.require(
+ waiting.observedTurns,
+ satisfies(
+ (turns: readonly EveEvalTurn[]) =>
+ turns.some((turn) =>
+ hasCompletedNotification(turn, marker2TaskId, `FANOUT-COMPLETE:${marker2}`),
+ ),
+ "the join receives the completed task's result in its notification",
+ ),
);
for (const turn of waiting.observedTurns) {
await t.require(
@@ -76,16 +73,11 @@ export default defineTaskEval({
),
);
}
+ t.notCalledTool("task_peek");
t.noFailedActions();
},
});
-interface ExpectedTask {
- readonly marker: FanInMarker;
- readonly status: "completed" | "input_required";
- readonly taskId: string;
-}
-
async function requireDistinctTasks(t: EveEvalContext, taskIds: readonly string[]): Promise<void> {
await t.require(
taskIds,
@@ -96,51 +88,15 @@ async function requireDistinctTasks(t: EveEvalContext, taskIds: readonly string[
);
}
-async function requireExactPeek(
- t: EveEvalContext,
- call: EveEvalTurn["toolCalls"][number] | undefined,
- taskIds: readonly string[],
- expectedTasks: readonly ExpectedTask[],
- description: string,
-): Promise<void> {
- await t.require(
- { input: call?.input, output: call?.output },
- satisfies((subject: { readonly input: unknown; readonly output: unknown }) => {
- const inputIds = Reflect.get(subject.input ?? {}, "taskIds");
- const tasks = Reflect.get(subject.output ?? {}, "tasks");
- if (!Array.isArray(inputIds) || !Array.isArray(tasks)) return false;
- const expectedIds = [...taskIds].sort();
- const outputIds = tasks.map((task) => Reflect.get(task, "taskId")).sort();
- return (
- JSON.stringify([...inputIds].sort()) === JSON.stringify(expectedIds) &&
- JSON.stringify(outputIds) === JSON.stringify(expectedIds) &&
- expectedTasks.every((expectedTask) => {
- const task = tasks.find(
- (candidate) => Reflect.get(candidate ?? {}, "taskId") === expectedTask.taskId,
- );
- return taskMatchesExpected(task, expectedTask);
- })
- );
- }, description),
- );
-}
-
-function taskMatchesExpected(task: unknown, expected: ExpectedTask): boolean {
- if (Reflect.get(task ?? {}, "status") !== expected.status) return false;
- if (expected.status === "completed") {
- const lastOutput = Reflect.get(task ?? {}, "lastOutput");
- return (
- Reflect.get(lastOutput ?? {}, "type") === "result" &&
- Reflect.get(lastOutput ?? {}, "data") === `FANOUT-COMPLETE:${expected.marker}`
- );
- }
- const inputRequests = Reflect.get(task ?? {}, "inputRequests");
- if (!Array.isArray(inputRequests)) return false;
- const release = inputRequests.find(
- (request) => Reflect.get(Reflect.get(request ?? {}, "action") ?? {}, "toolName") === "release",
+function hasCompletedNotification(turn: EveEvalTurn, taskId: string, result: string): boolean {
+ return turn.events.some(
+ (event) =>
+ event.type === "message.received" &&
+ typeof event.data.message === "string" &&
+ event.data.message.includes(`Background task ${taskId} (`) &&
+ event.data.message.includes(" is completed.") &&
+ event.data.message.includes(result),
);
- const action = Reflect.get(release ?? {}, "action");
- return Reflect.get(Reflect.get(action ?? {}, "input") ?? {}, "marker") === expected.marker;
}
interface BlockedFanIn {
diff --git a/e2e/fixtures/fixture-tasks/evals/task.lifecycle.cancel.accepted-nonterminal.eval.ts b/e2e/fixtures/fixture-tasks/evals/task.lifecycle.cancel.accepted-nonterminal.eval.ts
index 9b4746587..b7cf53ec7 100644
--- a/e2e/fixtures/fixture-tasks/evals/task.lifecycle.cancel.accepted-nonterminal.eval.ts
+++ b/e2e/fixtures/fixture-tasks/evals/task.lifecycle.cancel.accepted-nonterminal.eval.ts
@@ -52,10 +52,10 @@ export default defineTaskEval({
verified.expectOk();
verified.messageIncludes("TASK-CANCEL-STATUS");
await t.require(
- requireTaskView(verified.requireToolCall("task_peek").output, taskId),
+ requireTaskView(verified.requireToolCall("task_cancel").output, taskId),
satisfies(
(view: Record<string, unknown>) => hasSameCancelledFields(view, cancelledView),
- "task_peek preserves the cancelled task's semantic fields",
+ "no-op cancellation preserves the cancelled task's semantic fields",
),
);
},
diff --git a/e2e/fixtures/fixture-tasks/evals/task.lifecycle.cancel.noop-already-cancelled.eval.ts b/e2e/fixtures/fixture-tasks/evals/task.lifecycle.cancel.noop-already-cancelled.eval.ts
index 309b4bad1..e0e7db927 100644
--- a/e2e/fixtures/fixture-tasks/evals/task.lifecycle.cancel.noop-already-cancelled.eval.ts
+++ b/e2e/fixtures/fixture-tasks/evals/task.lifecycle.cancel.noop-already-cancelled.eval.ts
@@ -60,10 +60,10 @@ export default defineTaskEval({
);
still.expectOk();
await t.require(
- requireTaskView(still.requireToolCall("task_peek").output, taskId),
+ requireTaskView(still.requireToolCall("task_cancel").output, taskId),
satisfies(
(view: Record<string, unknown>) => hasSameCancelledFields(view, cancelledView),
- "task_peek observes the same semantic fields after repeated cancellation",
+ "another no-op cancellation observes the same semantic fields",
),
);
},
diff --git a/e2e/fixtures/fixture-tasks/evals/task.lifecycle.fail.accepted-nonterminal.eval.ts b/e2e/fixtures/fixture-tasks/evals/task.lifecycle.fail.accepted-nonterminal.eval.ts
index b8ecafe64..72c21a7cc 100644
--- a/e2e/fixtures/fixture-tasks/evals/task.lifecycle.fail.accepted-nonterminal.eval.ts
+++ b/e2e/fixtures/fixture-tasks/evals/task.lifecycle.fail.accepted-nonterminal.eval.ts
@@ -31,8 +31,8 @@ export default defineTaskEval({
const failed = await waitForTaskStatus(t, t, "TASK-A2-CHILD-FAILURE-VERIFY", taskId, "failed");
failed.expectOk();
failed.messageIncludes("TASK-A2-FAILED");
- const peeked = failed.requireToolCall("task_peek", { input: { taskIds: [taskId] } });
- const view = requireTaskView(peeked.output, taskId);
+ const inspected = failed.requireToolCall("task_cancel", { input: { taskIds: [taskId] } });
+ const view = requireTaskView(inspected.output, taskId);
await t.require(
view,
satisfies(
diff --git a/e2e/fixtures/fixture-tasks/evals/task.parent.wake.emitted-ready.conditional-delivery.eval.ts b/e2e/fixtures/fixture-tasks/evals/task.parent.wake.emitted-ready.conditional-delivery.eval.ts
index 3a999eef9..8839a1303 100644
--- a/e2e/fixtures/fixture-tasks/evals/task.parent.wake.emitted-ready.conditional-delivery.eval.ts
+++ b/e2e/fixtures/fixture-tasks/evals/task.parent.wake.emitted-ready.conditional-delivery.eval.ts
@@ -1,12 +1,15 @@
+import type { EveEvalTurn } from "eve/evals";
import { satisfies } from "eve/evals/expect";
import { defineTaskEval } from "./task-transition.js";
-import { requireBackgroundTaskId, requireSessionStreamIndex } from "./shared.js";
+import { requireSessionStreamIndex } from "./shared.js";
-/** A ready-task wake runs the parent model but does not require a channel message. */
+const REVIEW_FINDING = "blocker: task admission can discard deferred user input.";
+
+/** A late reviewer result already represented in the conversation requires no new message. */
export default defineTaskEval({
description:
- "A completed background task wakes the parent with conditional delivery and can remain silent.",
+ "A completed reviewer repeats a finding already delivered to the user, so its wake remains silent.",
transition: {
primary: "task.parent.wake.emitted-ready",
setup: [
@@ -16,25 +19,60 @@ export default defineTaskEval({
dimensions: { transport: "local", parentPhase: "parked" },
},
async test(t) {
- const started = await t.send("TASK-WAKE-CONDITIONAL-DELIVERY");
+ const started = await t.send("TASK-WAKE-REDUNDANT-REVIEW");
started.expectOk();
- started.messageIncludes("TASK-WAKE-CONDITIONAL-STARTED");
- const taskId = requireBackgroundTaskId(started);
+ started.calledSubagent("busy-worker", { count: 2 });
+
+ const taskIds = started.events.flatMap((event) =>
+ event.type === "subagent.completed" && event.data.backgroundTask !== undefined
+ ? [event.data.backgroundTask.taskId]
+ : [],
+ );
+ await t.require(
+ taskIds,
+ satisfies(
+ (ids: readonly string[]) => ids.length === 2 && new Set(ids).size === 2,
+ "two distinct reviewer task receipts",
+ ),
+ );
const sessionId = started.sessionId;
- const live = t.target.watchTurn(sessionId, {
- startIndex: requireSessionStreamIndex(t, "Conditional task wake"),
+ const firstLive = t.target.watchTurn(sessionId, {
+ startIndex: requireSessionStreamIndex(t, "First reviewer wake"),
});
- const wake = await live.result();
+ const firstWake = await firstLive.result();
+
+ firstWake.expectOk();
+ firstWake.messageIncludes(`request changes on PR #2277.\n\n- ${REVIEW_FINDING}`);
+ const firstNotification = requireTaskNotification(firstWake);
+ await t.require(
+ firstNotification,
+ satisfies(
+ (notification: TaskNotification) =>
+ taskIds.includes(notification.taskId) && notification.message.includes(REVIEW_FINDING),
+ "the first wake carries one reviewer's result",
+ ),
+ );
+ firstWake.notCalledTool("task_peek");
+
+ const secondLive = t.target.watchTurn(sessionId, {
+ startIndex: requireSessionStreamIndex(firstLive.session, "Late reviewer wake"),
+ });
+ const wake = await secondLive.result();
wake.expectOk();
- wake.eventsSatisfy("the completed task notification started the wake turn", (events) =>
- events.some(
- (event) =>
- event.type === "message.received" &&
- event.data.message.includes(`Background task ${taskId}`),
+ const lateNotification = requireTaskNotification(wake);
+ await t.require(
+ lateNotification,
+ satisfies(
+ (notification: TaskNotification) =>
+ taskIds.includes(notification.taskId) &&
+ notification.taskId !== firstNotification.taskId &&
+ notification.message.includes(REVIEW_FINDING),
+ "the late wake carries the other reviewer's redundant result",
),
);
+ wake.notCalledTool("task_peek");
wake.event("message.completed", {
count: 1,
data: (data) => data.finishReason !== "tool-calls" && data.message === null,
@@ -46,6 +84,21 @@ export default defineTaskEval({
wake.message,
satisfies((message) => message === undefined, "the task wake delivers no channel message"),
);
+ t.notCalledTool("task_peek");
t.noFailedActions();
},
});
+
+interface TaskNotification {
+ readonly message: string;
+ readonly taskId: string;
+}
+
+function requireTaskNotification(turn: EveEvalTurn): TaskNotification {
+ for (const event of turn.events) {
+ if (event.type !== "message.received" || typeof event.data.message !== "string") continue;
+ const taskId = /Background task (task_[a-z0-9]+)/iu.exec(event.data.message)?.[1];
+ if (taskId !== undefined) return { message: event.data.message, taskId };
+ }
+ throw new Error("Reviewer wake has no completed-task notification.");
+}
diff --git a/packages/eve/src/cli/dev/tui/runner.test.ts b/packages/eve/src/cli/dev/tui/runner.test.ts
index 3a1b1f4bc..5f234cedd 100644
--- a/packages/eve/src/cli/dev/tui/runner.test.ts
+++ b/packages/eve/src/cli/dev/tui/runner.test.ts
@@ -607,10 +607,10 @@ describe("EveTUIRunner idle session follow", () => {
data: {
actions: [
{
- callId: "peek-1",
+ callId: "cancel-1",
input: { taskIds: ["task_123"] },
kind: "tool-call",
- toolName: "task_peek",
+ toolName: "task_cancel",
},
],
sequence: 1,
@@ -622,10 +622,10 @@ describe("EveTUIRunner idle session follow", () => {
type: "action.result",
data: {
result: {
- callId: "peek-1",
+ callId: "cancel-1",
kind: "tool-result",
- output: { tasks: [{ status: "completed", taskId: "task_123" }] },
- toolName: "task_peek",
+ output: { tasks: [{ status: "cancelled", taskId: "task_123" }] },
+ toolName: "task_cancel",
},
sequence: 1,
status: "completed",
diff --git a/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts b/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
index 8da7b9715..8f801e92c 100644
--- a/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
+++ b/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts
@@ -1572,13 +1572,13 @@ describe("TerminalRenderer (inline scrollback)", () => {
{
type: "tool-call",
input: { taskIds: ["task_123"] },
- toolCallId: "peek-1",
- toolName: "task_peek",
+ toolCallId: "cancel-1",
+ toolName: "task_cancel",
},
{
type: "tool-result",
- output: { tasks: [{ status: "completed", taskId: "task_123" }] },
- toolCallId: "peek-1",
+ output: { tasks: [{ status: "cancelled", taskId: "task_123" }] },
+ toolCallId: "cancel-1",
},
{ type: "assistant-delta", id: "wake-1", delta: "Research finished." },
{ type: "assistant-complete", id: "wake-1" },
diff --git a/packages/eve/src/cli/dev/tui/tool-presentation.test.ts b/packages/eve/src/cli/dev/tui/tool-presentation.test.ts
index 7b63be5c0..9aed4a8aa 100644
--- a/packages/eve/src/cli/dev/tui/tool-presentation.test.ts
+++ b/packages/eve/src/cli/dev/tui/tool-presentation.test.ts
@@ -179,7 +179,6 @@ describe("presentTool", () => {
load_skill: { skill: "commit" },
read_file: { filePath: "/workspace/a.ts" },
task_cancel: { taskIds: ["task_abc"] },
- task_peek: { taskIds: ["task_abc"] },
task_update: { message: "Finished the next region." },
task_sleep: { seconds: 30 },
todo: { todos: [] },
diff --git a/packages/eve/src/cli/dev/tui/tool-presentation.ts b/packages/eve/src/cli/dev/tui/tool-presentation.ts
index 757b68084..a49876bcc 100644
--- a/packages/eve/src/cli/dev/tui/tool-presentation.ts
+++ b/packages/eve/src/cli/dev/tui/tool-presentation.ts
@@ -131,14 +131,6 @@ const BUILTIN_TOOL_COPY: Readonly<Record<string, BuiltinToolCopy>> = {
singularNoun: "task",
pluralNoun: "tasks",
},
- task_peek: {
- verb: "Check",
- pastVerb: "Checked",
- argKey: "taskIds",
- extractItem: taskIdsArg,
- singularNoun: "task",
- pluralNoun: "tasks",
- },
task_sleep: {
verb: "Pause",
pastVerb: "Paused",
diff --git a/packages/eve/src/execution/node-step.test.ts b/packages/eve/src/execution/node-step.test.ts
index 1244a1b1e..027836bfa 100644
--- a/packages/eve/src/execution/node-step.test.ts
+++ b/packages/eve/src/execution/node-step.test.ts
@@ -278,7 +278,7 @@ describe("createNodeHarnessTools", () => {
it("does not inject task tools without experimental.tasks", () => {
const tools = createNodeHarnessTools({ node: createTestNode() });
- for (const name of ["task_peek", "task_cancel", "task_sleep", "task_update"]) {
+ for (const name of ["task_cancel", "task_sleep", "task_update"]) {
expect(tools.has(name)).toBe(false);
}
});
@@ -295,7 +295,7 @@ describe("createNodeHarnessTools", () => {
},
});
- for (const name of ["task_peek", "task_cancel", "task_update"]) {
+ for (const name of ["task_cancel", "task_update"]) {
expect(tools.get(name)?.runtimeAction).toEqual({ kind: "task-control" });
expect(tools.get(name)?.execute).toBeUndefined();
}
@@ -316,7 +316,7 @@ describe("createNodeHarnessTools", () => {
},
});
- expect(tools.has("task_peek")).toBe(true);
+ expect(tools.has("task_sleep")).toBe(true);
expect(tools.has("task_cancel")).toBe(false);
});
});
diff --git a/packages/eve/src/execution/tasks/child/steps.test.ts b/packages/eve/src/execution/tasks/child/steps.test.ts
new file mode 100644
index 000000000..413c7eb22
--- /dev/null
+++ b/packages/eve/src/execution/tasks/child/steps.test.ts
@@ -0,0 +1,60 @@
+import { describe, expect, it } from "vitest";
+
+import { formatTaskNotification } from "#execution/tasks/child/steps.js";
+import type { TaskView } from "#tasks/types.js";
+
+const metadata = {
+ agentId: "agent-reviewer",
+ kind: "subagent" as const,
+ mode: "local" as const,
+ name: "reviewer",
+};
+
+const notificationCases: readonly { readonly expected: string; readonly view: TaskView }[] = [
+ {
+ expected: "Background task task-1 (reviewer) is completed.\n\nResult:\nship it",
+ view: {
+ lastOutput: { data: "ship it", type: "result" },
+ metadata,
+ status: "completed",
+ taskId: "task-1",
+ },
+ },
+ {
+ expected: 'Background task task-1 (reviewer) is completed.\n\nResult:\n{"verdict":"ship"}',
+ view: {
+ lastOutput: { data: { verdict: "ship" }, type: "result" },
+ metadata,
+ status: "completed",
+ taskId: "task-1",
+ },
+ },
+ {
+ expected: 'Background task task-1 (reviewer) failed.\n\nError:\n{"code":"FAILED"}',
+ view: {
+ lastOutput: { data: { code: "FAILED" }, type: "error" },
+ metadata,
+ status: "failed",
+ taskId: "task-1",
+ },
+ },
+];
+
+describe("formatTaskNotification", () => {
+ it.each(notificationCases)(
+ "includes terminal output in the parent notification",
+ ({ expected, view }) => {
+ expect(formatTaskNotification(view)).toBe(expected);
+ },
+ );
+
+ it("reports cancellation without inventing output", () => {
+ const view = {
+ metadata,
+ status: "cancelled",
+ taskId: "task-1",
+ } satisfies TaskView;
+
+ expect(formatTaskNotification(view)).toBe("Background task task-1 (reviewer) is cancelled.");
+ });
+});
diff --git a/packages/eve/src/execution/tasks/child/steps.ts b/packages/eve/src/execution/tasks/child/steps.ts
index 080cea471..f057785be 100644
--- a/packages/eve/src/execution/tasks/child/steps.ts
+++ b/packages/eve/src/execution/tasks/child/steps.ts
@@ -8,6 +8,7 @@ import type {
import { isTaskWorkflowTargetGone } from "#execution/tasks/workflow-target.js";
import { resumeSessionInbox } from "#execution/wire/session-inbox-resume.js";
import { createLogger } from "#internal/logging.js";
+import type { JsonValue } from "#shared/json.js";
import {
isTerminalTaskStatus,
taskAuthorizationRequestId,
@@ -221,10 +222,20 @@ export async function deliverTaskInputResponsesStep(input: {
}
}
-function formatTaskNotification(view: TaskView): string {
+export function formatTaskNotification(view: TaskView): string {
const subject = `Background task ${view.taskId} (${view.metadata.name})`;
if (view.status === "input_required") {
- return `${subject} needs input. Use task_peek to inspect the outstanding requests.`;
+ return `${subject} needs input.`;
}
- return `${subject} is ${view.status}. Use task_peek to read its output.`;
+ if (view.status === "completed") {
+ return `${subject} is completed.\n\nResult:\n${formatTaskOutput(view.lastOutput.data)}`;
+ }
+ if (view.status === "failed") {
+ return `${subject} failed.\n\nError:\n${formatTaskOutput(view.lastOutput.data)}`;
+ }
+ return `${subject} is cancelled.`;
+}
+
+function formatTaskOutput(output: JsonValue): string {
+ return typeof output === "string" ? output : (JSON.stringify(output) ?? "null");
}
diff --git a/packages/eve/src/execution/tasks/parent/control-shared.ts b/packages/eve/src/execution/tasks/parent/control-shared.ts
index dc38b5761..be1e7b6fb 100644
--- a/packages/eve/src/execution/tasks/parent/control-shared.ts
+++ b/packages/eve/src/execution/tasks/parent/control-shared.ts
@@ -13,7 +13,7 @@ import type { TaskView } from "#tasks/types.js";
/**
* Result and lookup helpers shared by the task-control executors
- * (`task_peek`/`task_cancel` in the dispatch module,
+ * (`task_cancel` in the dispatch module,
* task controls in their own).
*/
diff --git a/packages/eve/src/execution/tasks/parent/dispatch-task-step.ts b/packages/eve/src/execution/tasks/parent/dispatch-task-step.ts
index 99e8e616b..1616fb917 100644
--- a/packages/eve/src/execution/tasks/parent/dispatch-task-step.ts
+++ b/packages/eve/src/execution/tasks/parent/dispatch-task-step.ts
@@ -11,7 +11,7 @@
* parent turn inbox, and every start dispatches a conversation-mode
* (persistent) child so the background task stays resumable.
*
- * Task-control calls (`task_peek` / `task_cancel` / `task_update`) execute
+ * Task-control calls (`task_cancel` / `task_update`) execute
* inline in this step, which holds the session ownership index and world
* access they need.
*/
diff --git a/packages/eve/src/execution/tasks/parent/dispatch.ts b/packages/eve/src/execution/tasks/parent/dispatch.ts
index f7c85e4da..1874dcd94 100644
--- a/packages/eve/src/execution/tasks/parent/dispatch.ts
+++ b/packages/eve/src/execution/tasks/parent/dispatch.ts
@@ -9,7 +9,6 @@ import {
createUnknownTasksError,
findTaskAgentAddress,
lookupTaskEntries,
- readTaskViews,
readTaskView,
} from "#execution/tasks/parent/control-shared.js";
import { executeTaskUpdate } from "#execution/tasks/child/update.js";
@@ -27,7 +26,6 @@ import type { CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
import {
TASK_CANCEL_TOOL_NAME,
TASK_CONTROL_TOOL_NAMES,
- TASK_PEEK_TOOL_NAME,
TASK_UPDATE_TOOL_NAME,
} from "#runtime/framework-tools/tasks.js";
import type { SessionTaskIndexEntry } from "#tasks/session-index.js";
@@ -94,24 +92,18 @@ export async function executeTaskControlAction(input: {
}
const entries = lookup.entries;
- switch (action.toolName) {
- case TASK_PEEK_TOOL_NAME: {
- const views = await readTaskViews(entries);
- return { result: createTaskViewsResult(action, views), session };
- }
- case TASK_CANCEL_TOOL_NAME: {
- const views: TaskView[] = [];
- for (const entry of entries) {
- views.push(await cancelOwnedTask({ bundle: input.bundle, entry, session }));
- }
- return { result: createTaskViewsResult(action, views), session };
- }
- default:
- return {
- result: createTaskControlError(action, `Unsupported task control "${action.toolName}".`),
- session,
- };
+ if (action.toolName !== TASK_CANCEL_TOOL_NAME) {
+ return {
+ result: createTaskControlError(action, `Unsupported task control "${action.toolName}".`),
+ session,
+ };
+ }
+
+ const views: TaskView[] = [];
+ for (const entry of entries) {
+ views.push(await cancelOwnedTask({ bundle: input.bundle, entry, session }));
}
+ return { result: createTaskViewsResult(action, views), session };
}
/** Commits task cancellation, then propagates it to the addressed executor. */
diff --git a/packages/eve/src/harness/advertised-tools.test.ts b/packages/eve/src/harness/advertised-tools.test.ts
index 1e3334b23..07e580498 100644
--- a/packages/eve/src/harness/advertised-tools.test.ts
+++ b/packages/eve/src/harness/advertised-tools.test.ts
@@ -138,21 +138,20 @@ describe("getAdvertisedTools for definition arrays", () => {
it("keeps the task tools in the root session", () => {
const tools = new Map([
["add", createTool("add")],
- ["task_peek", createTaskControlTool("task_peek")],
+ ["task_cancel", createTaskControlTool("task_cancel")],
["task_sleep", createTool("task_sleep")],
["task_update", createTaskControlTool("task_update")],
]) satisfies HarnessToolMap;
const advertisedTools = getAdvertisedTools({ session: {}, tools });
- expect([...advertisedTools.keys()]).toEqual(["add", "task_peek", "task_sleep"]);
+ expect([...advertisedTools.keys()]).toEqual(["add", "task_cancel", "task_sleep"]);
});
it("keeps only task_update in delegated sessions", () => {
const tools = new Map([
["add", createTool("add")],
["task_cancel", createTaskControlTool("task_cancel")],
- ["task_peek", createTaskControlTool("task_peek")],
["task_sleep", createTool("task_sleep")],
["task_update", createTaskControlTool("task_update")],
]) satisfies HarnessToolMap;
diff --git a/packages/eve/src/harness/execute-tool.ts b/packages/eve/src/harness/execute-tool.ts
index bfb9168ab..0c2177c68 100644
--- a/packages/eve/src/harness/execute-tool.ts
+++ b/packages/eve/src/harness/execute-tool.ts
@@ -10,7 +10,7 @@ import type { ToolExecuteOptions } from "#shared/tool-definition.js";
* The harness records the tool call and the runtime executes it later.
*
* `task-control` marks the `experimental.tasks` parent tools
- * (`task_peek`, `task_cancel`): they carry no child
+ * (`task_cancel`, `task_update`): they carry no child
* address of their own — the dispatch step resolves targets through the
* session task index by tool name.
*/
diff --git a/packages/eve/src/runtime/framework-tools/tasks.ts b/packages/eve/src/runtime/framework-tools/tasks.ts
index 0e75873c0..b5bae7f49 100644
--- a/packages/eve/src/runtime/framework-tools/tasks.ts
+++ b/packages/eve/src/runtime/framework-tools/tasks.ts
@@ -9,20 +9,18 @@ import type { ResolvedToolDefinition } from "#runtime/types.js";
*
* With the flag on, subagent calls return a task receipt instead of
* blocking the parent turn; these tools coordinate that delegated work.
- * `task_peek`, `task_cancel`, and `task_update` are
+ * `task_cancel` and `task_update` are
* execute-less runtime actions — they need durable session state and
* world access, so the runtime-action dispatch step executes them.
* `task_sleep` only records a durable pause and executes in-loop.
*/
-export const TASK_PEEK_TOOL_NAME = "task_peek";
export const TASK_CANCEL_TOOL_NAME = "task_cancel";
export const TASK_SLEEP_TOOL_NAME = "task_sleep";
export const TASK_UPDATE_TOOL_NAME = "task_update";
/** Every model-visible task tool name, for gating and dispatch matching. */
export const TASK_TOOL_NAMES: ReadonlySet<string> = new Set([
- TASK_PEEK_TOOL_NAME,
TASK_CANCEL_TOOL_NAME,
TASK_SLEEP_TOOL_NAME,
TASK_UPDATE_TOOL_NAME,
@@ -30,7 +28,6 @@ export const TASK_TOOL_NAMES: ReadonlySet<string> = new Set([
/** Task-control tools executed by the runtime-action dispatch step. */
export const TASK_CONTROL_TOOL_NAMES: ReadonlySet<string> = new Set([
- TASK_PEEK_TOOL_NAME,
TASK_CANCEL_TOOL_NAME,
TASK_UPDATE_TOOL_NAME,
]);
@@ -40,7 +37,6 @@ const TASK_IDS_SCHEMA = z
.min(1)
.describe("Task ids from earlier subagent task receipts.");
-export const TASK_PEEK_INPUT_SCHEMA = z.strictObject({ taskIds: TASK_IDS_SCHEMA });
export const TASK_CANCEL_INPUT_SCHEMA = z.strictObject({ taskIds: TASK_IDS_SCHEMA });
export const TASK_UPDATE_INPUT_SCHEMA = z.strictObject({
@@ -79,17 +75,13 @@ export const TASK_SLEEP_OUTPUT_SCHEMA = z.strictObject({
waitedSeconds: z.number().positive(),
});
-const TASK_PEEK_DESCRIPTION =
- "Read the current state of one or more background tasks without waiting. " +
- "Returns each task's status and, for finished tasks, its output. Does not wake or change the task.";
-
const TASK_CANCEL_DESCRIPTION =
"Request cooperative cancellation of one or more background tasks. " +
"Cancellation is final: a task that finishes after you cancel it stays cancelled. Cancelling an already-finished task changes nothing.";
const TASK_SLEEP_DESCRIPTION =
- "Pause durably before continuing, for paced background-task checks. " +
- "Does not read or change any task; follow it with task_peek.";
+ "Pause durably before continuing while waiting for a background-task notification. " +
+ "Does not read or change any task.";
const TASK_UPDATE_DESCRIPTION =
"Briefly tell the parent agent what this background task is currently doing. " +
@@ -103,13 +95,6 @@ const TASK_UPDATE_DESCRIPTION =
*/
export function createTaskToolHarnessDefinitions(): readonly HarnessToolDefinition[] {
return [
- {
- description: TASK_PEEK_DESCRIPTION,
- inputSchema: TASK_PEEK_INPUT_SCHEMA,
- name: TASK_PEEK_TOOL_NAME,
- outputSchema: TASK_VIEWS_OUTPUT_SCHEMA,
- runtimeAction: { kind: "task-control" },
- },
{
description: TASK_CANCEL_DESCRIPTION,
inputSchema: TASK_CANCEL_INPUT_SCHEMA,
@@ -179,7 +164,6 @@ function createResolvedTaskToolStub(input: {
* these entries exist so `disableTool(name)` validates the names.
*/
export const TASK_TOOL_DEFINITIONS: readonly ResolvedToolDefinition[] = [
- createResolvedTaskToolStub({ description: TASK_PEEK_DESCRIPTION, name: TASK_PEEK_TOOL_NAME }),
createResolvedTaskToolStub({ description: TASK_CANCEL_DESCRIPTION, name: TASK_CANCEL_TOOL_NAME }),
createResolvedTaskToolStub({ description: TASK_SLEEP_DESCRIPTION, name: TASK_SLEEP_TOOL_NAME }),
createResolvedTaskToolStub({ description: TASK_UPDATE_DESCRIPTION, name: TASK_UPDATE_TOOL_NAME }),
diff --git a/packages/eve/src/runtime/prompt/compose.test.ts b/packages/eve/src/runtime/prompt/compose.test.ts
index d139b1483..d4dda8005 100644
--- a/packages/eve/src/runtime/prompt/compose.test.ts
+++ b/packages/eve/src/runtime/prompt/compose.test.ts
@@ -32,7 +32,10 @@ describe("composeRuntimeBasePrompt", () => {
expect(prompt).toContainEqual(
expect.stringContaining("return immediately with a task receipt"),
);
- expect(prompt).toContainEqual(expect.stringContaining("do not poll with task_peek"));
+ expect(prompt).toContainEqual(
+ expect.stringContaining("notifications include the task's result"),
+ );
+ expect(prompt).not.toContainEqual(expect.stringContaining("task_peek"));
expect(prompt).toContainEqual(expect.stringContaining("notify you"));
});
diff --git a/packages/eve/src/runtime/prompt/compose.ts b/packages/eve/src/runtime/prompt/compose.ts
index 96618c89f..6ecafe198 100644
--- a/packages/eve/src/runtime/prompt/compose.ts
+++ b/packages/eve/src/runtime/prompt/compose.ts
@@ -15,7 +15,7 @@ const AGENT_MESSAGING_INSTRUCTION =
"Agent messaging\nAgents you have already delegated to stay available after they answer. eve injects the current `<agents>` list into the conversation as a note labeled `[Agents]`; it is added automatically by the framework, not written by the user, and never requires a reply. The list is only a record of those existing agents — their `agentId`, name, and latest status. It does not limit which subagent tools you can call: your tool list is the source of truth, and any subagent tool can always be called without `agentId` to start a new agent, including when the `<agents>` list is empty or absent. Pass `agentId` to the same subagent tool only to continue one of those existing agents' sessions.";
const TASK_AGENT_MESSAGING_INSTRUCTION =
- "Agent messaging\nSubagent calls start durable background tasks and return immediately with a task receipt. After delegating, continue helping the user or end your turn; do not poll with task_peek or wait with task_sleep unless the user explicitly asks you to wait or the task result is required before you can answer. The task will notify you when it completes, fails, needs input, or sends an update. Agents you have already delegated to remain visible in the framework-authored `<agents>` conversation note. `availability=busy` means the listed task still owns that agent session: use task_peek or task_cancel with its taskId instead of starting a continuation. `availability=available` means no nonterminal task owns the session, so you may pass agentId to the original subagent tool to continue it. Calling a subagent without agentId always starts a new agent session.";
+ "Agent messaging\nSubagent calls start durable background tasks and return immediately with a task receipt. After delegating, continue helping the user or end your turn; do not wait with task_sleep unless the user explicitly asks you to wait or the task result is required before you can answer. The task will notify you when it completes, fails, needs input, or sends an update; completion and failure notifications include the task's result. Agents you have already delegated to remain visible in the framework-authored `<agents>` conversation note. `availability=busy` means the listed task still owns that agent session: wait for its notification or use task_cancel with its taskId instead of starting a continuation. `availability=available` means no nonterminal task owns the session, so you may pass agentId to the original subagent tool to continue it. Calling a subagent without agentId always starts a new agent session.";
/**
* Input for composing the base authored instructions prompt for one
diff --git a/packages/eve/src/shared/empty-delivery.ts b/packages/eve/src/shared/empty-delivery.ts
index 537193977..687c3e00a 100644
--- a/packages/eve/src/shared/empty-delivery.ts
+++ b/packages/eve/src/shared/empty-delivery.ts
@@ -1,6 +1,6 @@
export const EMPTY_DELIVERY_SENTINEL = "<eve-empty-delivery/>";
-export const CONDITIONAL_DELIVERY_INSTRUCTION = `Conditional delivery\nOnly when the current task explicitly makes delivery conditional and there is nothing to report, reply with exactly ${EMPTY_DELIVERY_SENTINEL} and no other text. Do not use this marker for ordinary conversations, after input or approval responses, or merely because you have no additional commentary. Never return an empty response; use the marker to intentionally deliver nothing.`;
+export const CONDITIONAL_DELIVERY_INSTRUCTION = `Conditional delivery\nOnly when the current task explicitly makes delivery conditional and there is nothing new to report, reply with exactly ${EMPTY_DELIVERY_SENTINEL} and no other text. This includes results already delivered or incorporated into an earlier response; do not send an acknowledgement of that redundancy. Do not use this marker for ordinary conversations, after input or approval responses, or to omit commentary from a response that still needs delivery. Never return an empty response; use the marker to intentionally deliver nothing.`;
export function hasEmptyDeliverySentinel(text: string | null | undefined): boolean {
return text?.includes(EMPTY_DELIVERY_SENTINEL) ?? false;
diff --git a/research/subagents-as-tasks-implementation.md b/research/subagents-as-tasks-implementation.md
index e8dd7b6b7..98ace0145 100644
--- a/research/subagents-as-tasks-implementation.md
+++ b/research/subagents-as-tasks-implementation.md
@@ -1,7 +1,7 @@
---
issue: https://github.com/vercel/eve/issues/1084
status: draft
-last_updated: "2026-08-01"
+last_updated: "2026-08-19"
---
# Subagents as tasks: additive delivery plan
@@ -102,12 +102,12 @@ lifecycle path.
### Stage 2 — task tools, undiscoverable
-Register the task tools (`task_peek`, `task_cancel`, `task_sleep`, `task_update`)
+Register the task tools (`task_cancel`, `task_sleep`, `task_update`)
as framework tools, filtered out of the tool set unless the flag is on. The first implementation
has no child-facing task tool.
- `task_sleep` reuses the existing durable turn-sleep request.
-- `task_peek` and `task_cancel` read the session task index; an `agentId` continuation resolves a
+- `task_cancel` reads the session task index; an `agentId` continuation resolves a
terminal task's child address through the agent handle store and starts a new task.
Verification: unit tests per tool; a scenario test that the tools are absent from advertised
@@ -127,8 +127,8 @@ In the runtime-action dispatch step, add a delegated mode alongside the existing
Step 4 is what keeps the parent turn moving and history provider-valid: the receipt is the one
result the existing key-based batch matching consumes, so the turn continues without a second
-result path. A task notification starts or nudges a parent turn, and the model can read additional
-current state through `task_peek`. Nothing selects this mode yet.
+result path. A task notification starts or nudges a parent turn and carries its ready result or
+error directly. Nothing selects this mode yet.
Verification: integration tests invoking the mode directly; replay tests proving the same
originating call returns the same task and never dispatches twice.
@@ -175,7 +175,8 @@ deliberately; they get their own plans if anything nontrivial surfaces.
nonterminal tasks, with at most one such task per child session; busy agents remain visible in
`<agents>` with their active task id and status.
2. **Wake policy.** Terminal and `input_required` transitions wake a parked parent through the
- session delivery path; they are the only wake triggers. The resulting parent turn is
+ session delivery path; they are the only wake triggers. Terminal notifications carry the full
+ result or error so the model needs no follow-up state read. The resulting parent turn is
conditionally delivered: the model sees the framework notification, but it may intentionally
produce no channel message.
3. **Continuation to a busy child.** An `agentId` continuation to a `working` task surfaces `AGENT_BUSY` as a tool
@@ -193,8 +194,7 @@ deliberately; they get their own plans if anything nontrivial surfaces.
1. **Remote parity is release-blocking.** Remote task children must support the same HITL,
authorization, cancellation, and terminal lifecycle as local children before the flag ships.
2. **Blocked vs computing children.** Today a child parked on input or authorization looks like
- any running child. The `input_required` transition in stage 4 is what makes the difference
- observable; until then `task_peek` reports `working` for both, which is acceptable for the
- inert stages but must be closed before the flag ships.
+ any running child. The `input_required` transition in stage 4 makes the difference observable
+ through the parent session's HITL events and must land before the flag ships.
[subagents-as-tasks design]: ./tools-as-tasks.md
diff --git a/research/tools-as-tasks.md b/research/tools-as-tasks.md
index 4e6d500d9..f116c34ad 100644
--- a/research/tools-as-tasks.md
+++ b/research/tools-as-tasks.md
@@ -1,7 +1,7 @@
---
issue: https://github.com/vercel/eve/issues/1084
status: draft
-last_updated: "2026-08-17"
+last_updated: "2026-08-19"
---
# Subagents as tasks
@@ -11,8 +11,9 @@ last_updated: "2026-08-17"
Under an opt-in `experimental.tasks` mode, eve should represent long-running work as durable,
addressable tasks. This plan applies that model only to local and remote subagents. A subagent call
returns a task receipt after dispatch instead of keeping the parent turn blocked until the child
-finishes. The parent can inspect, message, or cancel the task with framework-owned tools,
-and the child can intentionally report progress to its parent with one framework-owned tool.
+finishes. The parent receives result-bearing lifecycle notifications and can wait for or cancel
+the task with framework-owned tools. The child can intentionally report progress to its parent
+with one framework-owned tool.
Without the flag, current tool and subagent behavior must remain unchanged.
@@ -125,7 +126,6 @@ The parent receives these framework-owned tools:
```ts
interface TaskParentTools {
task_cancel(input: { taskIds: string[] }): Promise<TaskToolResult<boolean>>;
- task_peek(input: { taskIds: string[] }): Promise<TaskToolResult<TaskView[]>>;
task_update(input: { message: string }): Promise<{ status: "sent"; taskId: string }>;
task_sleep(input: { seconds: number }): Promise<TaskToolResult<boolean>>;
}
@@ -136,8 +136,6 @@ on the parent session, and eve routes matching responses directly to the blocked
The controls have distinct behavior:
-- `task_peek` reads current state without blocking and does not return credentials or routing
- handles.
- Passing `agentId` to the original subagent tool sends a follow-up after the prior task became terminal, creating a new task
bound to the same child session. It never reopens a terminal task or answers HITL.
- `task_cancel` requests cooperative cancellation. A committed terminal state is final, so a late
@@ -194,8 +192,9 @@ gets one receipt:
```
The eventual child result must not become a second result for that call. A framework-authored
-task notification starts or nudges a parent turn, and the model reads any additional current state
-with `task_peek`. This keeps history append-only and leaves no dangling provider tool call.
+task notification starts or nudges a parent turn and carries the ready state's result or error
+directly. The notification is separate append-only conversation input, so history remains
+provider-valid without a second read racing the queued notification.
## Task state and ownership
@@ -316,7 +315,7 @@ sequenceDiagram
C->>T: task.update or authorization
T->>H: full task snapshot
H->>H: queue until safe boundary
- H-->>M: task notification; task_peek if needed
+ H-->>M: task notification with result or error
```
### Agent-to-agent dependency
@@ -346,8 +345,10 @@ The current [MCP Tasks extension] provides the closest standard vocabulary:
- full task snapshots in `notifications/tasks`;
- terminal states that do not change.
-eve's `task_peek` and `task_cancel` map to those operations. `task_sleep` is an eve
-control, not an MCP method. eve is not implementing the MCP wire protocol in this work.
+eve's `task_cancel` maps to cancellation. Result-bearing notifications replace a model-facing
+`tasks/get` operation: the model receives ready state at the transition that wakes it instead of
+performing a second read that can race the queued notification. `task_sleep` is an eve control,
+not an MCP method. eve is not implementing the MCP wire protocol in this work.
One semantic difference is decided. MCP treats a tool-level `isError: true` result as
`completed`; `failed` is reserved for JSON-RPC execution failure. eve diverges: child failure
@@ -382,9 +383,8 @@ than MCP compatibility.
- The original tool call has exactly one result in durable history. Later task output cannot be
attached to that call a second time.
- Local and remote subagents support the same five parent-child flows.
-- Terminal and `input_required` transitions wake the parent; the model can inspect all relevant
- task views with `task_peek` and decide whether the available state is sufficient.
-- `task_peek` observes current state without waking or mutating the executor.
+- Terminal and `input_required` transitions wake the parent. Terminal notifications carry the
+ task result or error directly, and input requests use the parent session's ordinary HITL events.
- Parent-session responses route directly to the intended local task child without a parent model
turn and cannot cross task or session ownership. Follow-up messages use the original subagent tool with `agentId`.
- One child session owns at most one nonterminal task; repeated sends return `AGENT_BUSY` and do