The Open Framework for Building Agents
fix(eve): compaction - account for final request context (#3097)
Andrew Barbae30181875cd9
diff --git a/.changeset/account-for-request-envelope.md b/.changeset/account-for-request-envelope.mdnew file mode 100644index 000000000..4515a4f88--- /dev/null+++ b/.changeset/account-for-request-envelope.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Account for effective instructions and tool schemas before each model call so dynamic capability growth triggers context compaction. Preserve provider-reported usage without counting unchanged schemas twice, and reserve room for the final request while compacting history.diff --git a/docs/concepts/context-control.md b/docs/concepts/context-control.mdindex 268ba8bea..e4091dce3 100644--- a/docs/concepts/context-control.md+++ b/docs/concepts/context-control.md@@ -58,6 +58,10 @@ See [Dynamic capabilities](../guides/dynamic-capabilities) for the resolver API,## Compaction and clear+Before a model call, eve checks the projected history together with the effective system instructions and advertised tool schemas. The check runs after `step.started` resolves dynamic capabilities. When the provider reports input usage, eve adds estimates for new messages and growth in the instructions and tool catalog to that count; unchanged schemas are not counted again.++Compaction reserves space for those instructions and tools while reducing conversation history. It cannot shrink the instructions or tool catalog themselves, so keep them within the selected model's context window.+User-role instructions follow the normal history lifecycle. Compaction can summarize them, and clear removes them without rerunning their static definitions or dynamic resolvers. System-role instructions remain outside history and continue to apply after either operation.Recalled memory also uses user-role messages, but eve keeps their attributiondiff --git a/e2e/fixtures/agent-compaction-envelope/agent/agent.ts b/e2e/fixtures/agent-compaction-envelope/agent/agent.tsnew file mode 100644index 000000000..3f2f2fe15--- /dev/null+++ b/e2e/fixtures/agent-compaction-envelope/agent/agent.ts@@ -0,0 +1,43 @@+import { e2eAgentConfig } from "@eve-e2e/config";+import { defineAgent } from "eve";+import { mockModel } from "eve/evals";++const model = mockModel({+ modelId: "request-envelope-compaction-model",+ respond(request) {+ if (+ request.messages.some(+ (message) =>+ message.role === "system" && message.text.includes("CONTEXT CHECKPOINT COMPACTION"),+ )+ ) {+ return "Earlier seed turns recorded evidence. Continue with the current request.";+ }+ if (request.lastUserMessage?.includes("[expand-envelope]")) {+ const compacted = request.messages.some(+ (message) => message.text === "Summary of our conversation so far:",+ );+ const instructionsGrew = request.messages.some(+ (message) => message.role === "system" && message.text.includes("EXPANDED_POLICY"),+ );+ const toolsGrew = request.tools.some((tool) => tool.name === "catalog_probe");+ if (!compacted || !instructionsGrew || !toolsGrew) {+ throw new Error(+ `Expanded request was not compacted: ${JSON.stringify({ compacted, instructionsGrew, toolsGrew })}`,+ );+ }+ return { text: "DYNAMIC_ENVELOPE_COMPACTED", usage: { inputTokens: 9_000 } };+ }+ return {+ text: "Seed evidence recorded. ".repeat(64),+ usage: { inputTokens: 8_000 },+ };+ },+});++export default defineAgent({+ ...e2eAgentConfig(),+ model,+ modelContextWindowTokens: 50_000,+ compaction: { thresholdPercent: 0.2 },+});diff --git a/e2e/fixtures/agent-compaction-envelope/agent/instructions.md b/e2e/fixtures/agent-compaction-envelope/agent/instructions.mdnew file mode 100644index 000000000..b7e6e0c40--- /dev/null+++ b/e2e/fixtures/agent-compaction-envelope/agent/instructions.md@@ -0,0 +1 @@+Use the scripted fixture model to verify request-envelope compaction.diff --git a/e2e/fixtures/agent-compaction-envelope/agent/instructions/catalog-policy.ts b/e2e/fixtures/agent-compaction-envelope/agent/instructions/catalog-policy.tsnew file mode 100644index 000000000..2ae253c95--- /dev/null+++ b/e2e/fixtures/agent-compaction-envelope/agent/instructions/catalog-policy.ts@@ -0,0 +1,15 @@+import type { HookEvent } from "eve/hooks";+import { defineDynamic, defineInstructions } from "eve/instructions";++export default defineDynamic({+ events: {+ "turn.started": (event) => {+ // The preamble cannot read this turn's message yet; six seed turns precede expansion.+ if ((event as HookEvent<"turn.started">).data.sequence < 6) return null;+ return defineInstructions({+ role: "system",+ content: `EXPANDED_POLICY ${"Use the configured catalog policy. ".repeat(140)}`,+ });+ },+ },+});diff --git a/e2e/fixtures/agent-compaction-envelope/agent/tools/catalog.ts b/e2e/fixtures/agent-compaction-envelope/agent/tools/catalog.tsnew file mode 100644index 000000000..2be075a7f--- /dev/null+++ b/e2e/fixtures/agent-compaction-envelope/agent/tools/catalog.ts@@ -0,0 +1,23 @@+import { defineDynamic, defineTool } from "eve/tools";++export default defineDynamic({+ events: {+ "step.started": (_event, ctx) => {+ if (!JSON.stringify(ctx.messages).includes("[expand-envelope]")) return null;+ return {+ catalog_probe: defineTool({+ description: "Inspect the expanded catalog.",+ inputSchema: {+ type: "object",+ properties: {+ query: { type: "string", description: "Catalog query documentation. ".repeat(650) },+ },+ required: ["query"],+ additionalProperties: false,+ },+ execute: () => "catalog-ready",+ }),+ };+ },+ },+});diff --git a/e2e/fixtures/agent-compaction-envelope/evals/envelope-growth.eval.ts b/e2e/fixtures/agent-compaction-envelope/evals/envelope-growth.eval.tsnew file mode 100644index 000000000..7a71b59f0--- /dev/null+++ b/e2e/fixtures/agent-compaction-envelope/evals/envelope-growth.eval.ts@@ -0,0 +1,21 @@+import { defineEval } from "eve/evals";++export default defineEval({+ description:+ "Growing instructions and tool schemas trigger compaction above prior provider usage.",+ async test(t) {+ for (let index = 0; index < 6; index += 1) {+ const seed = await t.send(+ `Seed ${index}: ${"Preserve this repository evidence. ".repeat(40)}`,+ );+ seed.expectOk();+ seed.event("compaction.completed", { count: 0 });+ }+ const expanded = await t.send(+ "[expand-envelope] Verify that the expanded request was compacted.",+ );+ expanded.expectOk();+ expanded.event("compaction.completed", { count: 1 });+ expanded.messageIncludes("DYNAMIC_ENVELOPE_COMPACTED");+ },+});diff --git a/e2e/fixtures/agent-compaction-envelope/evals/evals.config.ts b/e2e/fixtures/agent-compaction-envelope/evals/evals.config.tsnew file mode 100644index 000000000..a34189397--- /dev/null+++ b/e2e/fixtures/agent-compaction-envelope/evals/evals.config.ts@@ -0,0 +1,3 @@+import { defineEvalConfig } from "eve/evals";++export default defineEvalConfig({ maxConcurrency: 1, timeoutMs: 180_000 });diff --git a/e2e/fixtures/agent-compaction-envelope/package.json b/e2e/fixtures/agent-compaction-envelope/package.jsonnew file mode 100644index 000000000..6493ff91c--- /dev/null+++ b/e2e/fixtures/agent-compaction-envelope/package.json@@ -0,0 +1,22 @@+{+ "name": "agent-compaction-envelope",+ "version": "0.0.0",+ "private": true,+ "type": "module",+ "scripts": {+ "build": "eve build",+ "dev": "eve dev",+ "start": "eve start",+ "typecheck": "eve build && tsc",+ "test:e2e": "eve eval --strict"+ },+ "dependencies": {+ "@eve-e2e/config": "workspace:*",+ "@workflow/world-postgres": "catalog:",+ "eve": "workspace:*"+ },+ "devDependencies": {+ "@types/node": "catalog:",+ "typescript": "catalog:"+ }+}diff --git a/e2e/fixtures/agent-compaction-envelope/tsconfig.json b/e2e/fixtures/agent-compaction-envelope/tsconfig.jsonnew file mode 100644index 000000000..85e3eceb8--- /dev/null+++ b/e2e/fixtures/agent-compaction-envelope/tsconfig.json@@ -0,0 +1,17 @@+{+ "compilerOptions": {+ "target": "ES2022",+ "module": "esnext",+ "moduleResolution": "bundler",+ "outDir": "dist",+ "rootDir": ".",+ "strict": true,+ "esModuleInterop": true,+ "skipLibCheck": true,+ "forceConsistentCasingInFileNames": true,+ "declaration": true,+ "noEmit": true,+ "types": ["node"]+ },+ "include": ["agent/**/*.ts", "evals/**/*.ts"]+}diff --git a/e2e/fixtures/agent-compaction-regressions/agent/agent.ts b/e2e/fixtures/agent-compaction-regressions/agent/agent.tsindex b281013da..b1bd1ff61 100644--- a/e2e/fixtures/agent-compaction-regressions/agent/agent.ts+++ b/e2e/fixtures/agent-compaction-regressions/agent/agent.ts@@ -1,6 +1,6 @@import { e2eAgentConfig, e2eModel } from "@eve-e2e/config";import { defineAgent } from "eve";-import { mockModel, type MockModelRequest } from "eve/evals";+import { mockModel, type MockModelRequest, type MockModelResponder } from "eve/evals";import {COMPACTION_CHECKPOINT_TEXT,@@ -9,15 +9,20 @@ import {CONTENT_OUTPUT_LEAD_MARKER,CONTENT_OUTPUT_PAYLOAD_CANARY,CONTENT_OUTPUT_TAIL_MARKER,- SECOND_CHECKPOINT_MARKER,TASK_PRESERVED_MARKER,TASK_TAIL_SENTINEL,} from "../constants";+import { assistantHasReport } from "../report-evidence";+import { handoffReferences, reviewReferences } from "../release-reports";const TEST_CONTEXT_WINDOW_TOKENS = 32_000;-// Scripted usage supplies pressure without starving the real summarizer's transcript.-const TEST_COMPACTION_THRESHOLD_TOKENS = 2_048;-const COMPACTION_PRESSURE_USAGE = { inputTokens: 4_096 };+// The compiled fixture's instructions and 13 advertised tools occupy ~2,823+// tokens. Reserve them in addition to the summarizer's history budget.+const TEST_REQUEST_ENVELOPE_TOKENS = 2_823;+// Fit the capped file-output exchange, while forcing the larger review and+// handoff reports into the assistant checkpoint consumed by the script.+const TEST_HISTORY_BUDGET_TOKENS = 900;+const COMPACTION_PRESSURE_USAGE = { inputTokens: TEST_REQUEST_ENVELOPE_TOKENS + 4_096 };const MAX_TOOL_CALLS = 10;type RegressionCase =@@ -27,7 +32,7 @@ type RegressionCase =| "task-survival";let activeCase: RegressionCase | undefined;-const checkpointAdvanceCallCounts = new Map<RegressionCase, number>();+const handoffCallCounts = new Map<RegressionCase, number>();const toolCallCounts = new Map<RegressionCase, number>();/** One entry per content-output-file-stub model call, rendered by {@link renderHistoryShape}. */@@ -62,7 +67,7 @@ let requestCount = 0;const taskModel = mockModel({modelId: "compaction-regression-task-model",- respond(request) {+ respond: withFullRequestUsage((request) => {// EVE_E2E_DUMP_CONTEXT=1 prints every request's messages — the context// exactly as the model sees it, so compaction, capping, and replay are// observable per step while iterating on these evals.@@ -78,7 +83,7 @@ const taskModel = mockModel({const initialCase = findInitialCase(request);if (initialCase !== undefined && activeCase !== initialCase) {activeCase = initialCase;- checkpointAdvanceCallCounts.set(initialCase, 0);+ handoffCallCounts.set(initialCase, 0);toolCallCounts.set(initialCase, 0);}@@ -125,9 +130,8 @@ const taskModel = mockModel({toolCallCounts.set(regressionCase, contentOutputCalls + 1);return {- // This case isolates cap-only rewriting: the file supplies the- // pressure, while the measured-token fixture covers a large baseline.- usage: { inputTokens: 1 },+ // This case isolates file capping; only the attachment supplies history pressure.+ usage: { inputTokens: TEST_REQUEST_ENVELOPE_TOKENS + 1 },toolCalls: [{id: "emit-compaction-content-1",@@ -168,66 +172,48 @@ const taskModel = mockModel({};}- const marker = completionMarker(regressionCase);+ const subject = regressionCase === "redundant-tool-calls" ? "repository" : "checkout";+ const reviewId = reviewReferences[subject];+ const handoffId = handoffReferences[subject];- // These are fixture markers, not compaction protocol fields. `marker` records the- // regression work tool; `SECOND_CHECKPOINT_MARKER` records the test-only tool- // whose output makes the harness cross the compaction threshold a second time.- // Kept tool results, checkpoints, and eviction trails all prove completed work.- // User messages are excluded because the eval instructions quote the markers.- if (completionEvidenceContains(request.messages, marker)) {- if (completionEvidenceContains(request.messages, SECOND_CHECKPOINT_MARKER)) {- return `Done: ${marker}; ${SECOND_CHECKPOINT_MARKER}`;+ if (assistantHasReport(request.messages, reviewId)) {+ if (assistantHasReport(request.messages, handoffId)) {+ return `The completed review is recorded as ${reviewId}. The release handoff is ready at ${handoffId}.`;}- const advanceCalls = checkpointAdvanceCallCounts.get(regressionCase) ?? 0;- if (advanceCalls >= MAX_TOOL_CALLS) {- return `Hard stop after ${MAX_TOOL_CALLS} checkpoint advances: ${marker}`;+ const handoffCalls = handoffCallCounts.get(regressionCase) ?? 0;+ if (handoffCalls >= MAX_TOOL_CALLS) {+ return "The review is complete, but the release handoff could not be confirmed.";}-- checkpointAdvanceCallCounts.set(regressionCase, advanceCalls + 1);+ handoffCallCounts.set(regressionCase, handoffCalls + 1);return {usage: COMPACTION_PRESSURE_USAGE,toolCalls: [{- id: `advance-checkpoint-${advanceCalls + 1}`,- input: { regressionCase },- name: "advance-checkpoint",+ id: `prepare-handoff-${handoffCalls + 1}`,+ input: { subject, reviewId },+ name: "prepare-handoff",},],};}- const completedCalls = toolCallCounts.get(regressionCase) ?? 0;- if (completedCalls >= MAX_TOOL_CALLS) {- return `Hard stop after ${MAX_TOOL_CALLS} calls: ${marker}`;+ const reviewCalls = toolCallCounts.get(regressionCase) ?? 0;+ if (reviewCalls >= MAX_TOOL_CALLS) {+ return "The review could not be confirmed, so a release handoff is not ready.";}-- const attempt = completedCalls + 1;- toolCallCounts.set(regressionCase, attempt);-- return regressionCase === "redundant-tool-calls"- ? {- usage: COMPACTION_PRESSURE_USAGE,- toolCalls: [- {- id: `inspect-repository-${attempt}`,- input: { scope: "repository" },- name: "inspect-repository",- },- ],- }- : {- usage: COMPACTION_PRESSURE_USAGE,- toolCalls: [- {- id: `perform-source-analysis-${attempt}`,- input: { approach: `attempt-${attempt}` },- name: "perform-source-analysis",- },- ],- };- },+ toolCallCounts.set(regressionCase, reviewCalls + 1);+ return {+ usage: COMPACTION_PRESSURE_USAGE,+ toolCalls: [+ {+ id: `${subject}-review-${reviewCalls + 1}`,+ input: { scope: subject },+ name: subject === "repository" ? "inspect-repository" : "perform-source-analysis",+ },+ ],+ };+ }),});export default defineAgent({@@ -239,7 +225,8 @@ export default defineAgent({compaction: {model: e2eModel(),modelContextWindowTokens: TEST_CONTEXT_WINDOW_TOKENS,- thresholdPercent: TEST_COMPACTION_THRESHOLD_TOKENS / TEST_CONTEXT_WINDOW_TOKENS,+ thresholdPercent:+ (TEST_REQUEST_ENVELOPE_TOKENS + TEST_HISTORY_BUDGET_TOKENS) / TEST_CONTEXT_WINDOW_TOKENS,},limits: {maxInputTokensPerSession: 100_000,@@ -257,26 +244,28 @@ function findInitialCase(request: MockModelRequest): RegressionCase | undefinedfunction regressionCaseFromText(text: string): RegressionCase | undefined {if (text.includes("[case: content-output-file-stub]")) return "content-output-file-stub";- if (text.includes("[case: redundant-tool-calls]")) return "redundant-tool-calls";- if (text.includes("[case: stale-todo-work]")) return "stale-todo-work";+ if (text.toLowerCase().includes("review the storefront repository"))+ return "redundant-tool-calls";+ if (text.toLowerCase().includes("review the checkout implementation")) return "stale-todo-work";if (text.includes("[case: task-survival]")) return "task-survival";return undefined;}-function completionMarker(- regressionCase: Exclude<RegressionCase, "content-output-file-stub" | "task-survival">,-): string {- return regressionCase === "redundant-tool-calls"- ? "REPOSITORY_INSPECTION_COMPLETE"- : "SOURCE_ANALYSIS_COMPLETE";-}--function completionEvidenceContains(- messages: MockModelRequest["messages"],- marker: string,-): boolean {- return messages.some(- (message) =>- (message.role === "assistant" || message.role === "tool") && message.text.includes(marker),- );+function withFullRequestUsage(respond: MockModelResponder): MockModelResponder {+ return async (request) => {+ const response = await respond(request);+ const history = request.messages+ .filter((message) => message.role !== "system")+ .map((message) => ({ role: message.role, content: message.text }));+ // Real providers include the tool catalog in reported input usage. The+ // mock's default text-only estimate would hide that cost on later steps.+ return {+ ...(typeof response === "string" ? { text: response } : response),+ usage: {+ inputTokens:+ (typeof response === "string" ? undefined : response.usage?.inputTokens) ??+ TEST_REQUEST_ENVELOPE_TOKENS + Math.ceil(JSON.stringify(history).length / 4),+ },+ };+ };}diff --git a/e2e/fixtures/agent-compaction-regressions/agent/instructions.md b/e2e/fixtures/agent-compaction-regressions/agent/instructions.mdindex ca03e53fe..bcf17679e 100644--- a/e2e/fixtures/agent-compaction-regressions/agent/instructions.md+++ b/e2e/fixtures/agent-compaction-regressions/agent/instructions.md@@ -1,13 +1,11 @@-You help Alice and Bob review a small reading-list application and prepare handoff notes.+# Storefront release assistant-Each review and handoff step is performed once. A tool result with-`completed: true` or a `completionMarker` is its completion receipt. Use that-recorded work when preparing the final report, including after a conversation-summary.+Help maintainers review the storefront and prepare release handoffs. Use the+completed review record to prepare its handoff and include both record references+in the final note. Complete each requested review and handoff once.-Bob maintains the shared checklist separately. An entry can still say pending-while Alice's review is complete. Use the completed findings for the handoff-rather than repeating the review while Bob updates the checklist.+A completed review remains authoritative when the task board has a stale pending+entry. Continue from the saved findings instead of repeating the review.-A result with `hardStop: true` ends the scheduled review. Provide the final-report with its `completionMarker` rather than starting another step.+When a tool reports `hardStop: true`, stop using tools and explain which work+could not be confirmed.diff --git a/e2e/fixtures/agent-compaction-regressions/agent/tools/advance-checkpoint.ts b/e2e/fixtures/agent-compaction-regressions/agent/tools/advance-checkpoint.tsdeleted file mode 100644index 1f9b09246..000000000--- a/e2e/fixtures/agent-compaction-regressions/agent/tools/advance-checkpoint.ts+++ /dev/null@@ -1,38 +0,0 @@-import { defineState } from "eve/context";-import { defineTool } from "eve/tools";-import { z } from "zod";--import { SECOND_CHECKPOINT_MARKER } from "../../constants";--const invocationCount = defineState("compaction-regression.advance-checkpoint", () => 0);--export default defineTool({- description:- "Record the handoff notes after the initial review is complete and return its checkpoint marker.",- inputSchema: z.object({- regressionCase: z.enum(["redundant-tool-calls", "stale-todo-work"]),- }),- async execute(input) {- const attempt = invocationCount.get() + 1;- invocationCount.update(() => attempt);-- return {- checkpointMarker: SECOND_CHECKPOINT_MARKER,- completed: true,- regressionCase: input.regressionCase,- attempt,- handoffNotes: [- "Alice has finished the initial review of the reading-list application. Bob will use these completed findings for the team handoff. The review and the handoff are separate steps, each with its own saved reference.",- "The catalog, reading lists, and preview pages form the main sequence. The handoff follows that order so Bob can describe how a book is found in the catalog, added to a list, and shown in a saved preview.",- "Catalog notes cover book identifiers, titles, authors, and shelf labels. Bob can use that section to explain which details appear in a search result and which details the preview looks up for a selected book.",- "Reading-list notes cover adding books, arranging their order, and keeping an empty list as a starting point. The examples show how a saved selection can be opened again with the same titles in the same order.",- "Preview notes describe the list title, optional description, and total book count. Each book entry shows its title and author together, followed by the shelf label. The recorded selection supplies the order of those entries.",- "The print-view section explains how a saved list becomes a plain page for the library noticeboard. Opening that page leaves the reading list unchanged. Bob can return to the regular preview after preparing the printed copy.",- "Display preferences cover page size and the compact or spacious layout. An optional description can remain blank. Bob can refer to these examples when explaining how the same list appears in its preview and printable forms.",- "The saved-lists section describes recent lists and next-page links. The archive section describes how an archived list remains available on its own page. These paragraphs summarize the modules that Alice has already reviewed.",- "Bob maintains the shared checklist separately from Alice's review. Its pending entry records an earlier checklist state, while the completed findings record the finished review. Bob will bring the checklist up to date during handoff.",- "The handoff notes are saved, and the checkpoint marker is their reference. Alice and Bob can identify the two completed steps from the review completion marker and the checkpoint marker included in the final report.",- ],- };- },-});diff --git a/e2e/fixtures/agent-compaction-regressions/agent/tools/inspect-repository.ts b/e2e/fixtures/agent-compaction-regressions/agent/tools/inspect-repository.tsindex 85f191741..bed77d557 100644--- a/e2e/fixtures/agent-compaction-regressions/agent/tools/inspect-repository.ts+++ b/e2e/fixtures/agent-compaction-regressions/agent/tools/inspect-repository.ts@@ -2,39 +2,24 @@ import { defineState } from "eve/context";import { defineTool } from "eve/tools";import { z } from "zod";-const completionMarker = "REPOSITORY_INSPECTION_COMPLETE";-const invocationCount = defineState("compaction-regression.inspect-repository", () => 0);+import { repositoryFindings } from "../../release-findings";+import { reviewReferences, saveReleaseRecord } from "../../release-reports";++const invocationCount = defineState("storefront.inspect-repository", () => 0);export default defineTool({- description:- "Review the reading-list repository and return an overview of its modules for Alice and Bob's handoff.",- inputSchema: z.object({- scope: z.literal("repository"),- }),+ description: "Review the storefront repository and save a completed review record.",+ inputSchema: z.object({ scope: z.literal("repository") }),async execute() {const attempt = invocationCount.get() + 1;invocationCount.update(() => attempt);-- return {- completed: true,- completionMarker,- workUnit: "repository-inspection",- hardStop: attempt >= 10,- attempt,- findings: [- "The repository contains a small reading-list application. Its entry point loads the display settings and connects the book catalog, reading lists, previews, and saved-lists page to their repositories.",- "The catalog module owns book records with identifiers, titles, authors, and shelf labels. Its repository supports title searches and author filters, returning an empty list when a search has no matching records.",- "The reading-list module stores selected book identifiers in a chosen order. Adding a book already on the list keeps its existing position. A list with no books is a normal starting point for a new selection.",- "The preview module reads current titles and shelf labels from the catalog. It combines those details with the saved list order, then gives the template the list title, description, and selected books.",- "The list repository saves the list title and selected books together. It returns a list reference after saving. The preview page then reads that saved record so it displays the same selection when reopened.",- "Preview templates display book titles and author names as plain text. Each entry includes its shelf label on a separate line. The templates share simple helpers for spacing, headings, and the total book count.",- "The catalog helper checks that the selected books still have catalog entries. If a title has moved, the preview shows a note beside that entry and leaves the reading list available for a later update.",- "The preferences module stores the page size and the choice of a compact or spacious layout. A list description is optional. These settings are used consistently on the preview page and the printable version.",- "The print-view helper receives a saved list reference and prepares a plain page with the same titles. Opening that view leaves the saved reading list unchanged, making it easy to return to the regular preview.",- "The saved-lists page displays recently prepared lists first. Its repository uses bounded page sizes and a next-page reference. Each entry shows the saved title, book count, and a link to open its preview.",- "The archive action reads a list's current state before updating it. Selecting the action again leaves an already archived list in the same state. The list can still be found through the archive page.",- "Alice's repository overview is complete and ready for Bob's handoff. These notes cover finding books, arranging a reading list, viewing saved results, choosing display settings, and preparing a printable copy.",- ],+ const report = {+ reportId: reviewReferences.repository,+ subject: "repository" as const,+ status: "completed" as const,+ findings: repositoryFindings,};+ saveReleaseRecord(report);+ return { completed: true, ...report, attempt, hardStop: attempt >= 10 };},});diff --git a/e2e/fixtures/agent-compaction-regressions/agent/tools/perform-source-analysis.ts b/e2e/fixtures/agent-compaction-regressions/agent/tools/perform-source-analysis.tsindex bffa8a795..90dda9024 100644--- a/e2e/fixtures/agent-compaction-regressions/agent/tools/perform-source-analysis.ts+++ b/e2e/fixtures/agent-compaction-regressions/agent/tools/perform-source-analysis.ts@@ -3,46 +3,30 @@ import { defineTool } from "eve/tools";import { todo } from "eve/tools/todo";import { z } from "zod";-const completionMarker = "SOURCE_ANALYSIS_COMPLETE";-const invocationCount = defineState("compaction-regression.perform-source-analysis", () => 0);+import { checkoutFindings } from "../../release-findings";+import { reviewReferences, saveReleaseRecord } from "../../release-reports";++const invocationCount = defineState("storefront.perform-source-analysis", () => 0);export default defineTool({- description:- "Review the reading-list application's modules and return Alice's completed findings for Bob's handoff.",- inputSchema: z.object({- approach: z.string().min(1),- }),- async execute(input, ctx) {+ description: "Review the checkout implementation and save a completed review record.",+ inputSchema: z.object({ scope: z.literal("checkout") }),+ async execute(_input, ctx) {const attempt = invocationCount.get() + 1;invocationCount.update(() => attempt);await todo.execute({- todos: [{ content: "Complete source analysis", priority: "high", status: "pending" }],+ todos: [{ content: "Review checkout implementation", priority: "high", status: "pending" }],},ctx,);-- return {- completed: true,- completionMarker,- workUnit: "source-analysis",- hardStop: attempt >= 10,- attempt,- approach: input.approach,- findings: [- "The application entry point loads the display settings and connects the book catalog, reading lists, and preview pages. The catalog is ready before the first page is shown.",- "Catalog records contain a book identifier, title, author, and shelf label. A search with no matching books returns an empty list and a friendly note beside the search box.",- "Reading lists store book identifiers in the order chosen by the reader. Adding a book already on the list keeps its existing position, while an empty list remains a normal starting point.",- "The list preview combines the saved book identifiers with titles from the catalog. It shows the title and author together, followed by the shelf label on the next line.",- "The list repository saves the list title and its selected books together. It returns a list reference after saving, allowing the preview page to show the recorded selection.",- "Preview templates use the saved list data. Book titles appear as plain text, and the template includes a short count of the books followed by their ordered entries.",- "The catalog helper checks whether a selected book is still listed before preparing a preview. If a title has moved, the page keeps the reading list available for a later update.",- "Display preferences include the page size and the choice of a compact or spacious layout. Optional descriptions can remain blank when the reader prefers a simple list of titles.",- "The print-view helper receives the saved list reference. Opening the print view leaves the list unchanged, so the reader can return to the same selection afterward.",- "The saved-lists page shows recently prepared lists first. It uses a bounded page size and provides a next-page link when there are more lists to display.",- "The archive action reads the saved list state before updating it. A list already in the archive remains there when the same action is selected again.",- "Alice's source review is complete and these findings are ready for Bob. The shared checklist still shows the earlier pending entry because Bob updates it separately during the handoff.",- ],+ const report = {+ reportId: reviewReferences.checkout,+ subject: "checkout" as const,+ status: "completed" as const,+ findings: checkoutFindings,};+ saveReleaseRecord(report);+ return { completed: true, ...report, attempt, hardStop: attempt >= 10 };},});diff --git a/e2e/fixtures/agent-compaction-regressions/agent/tools/prepare-handoff.ts b/e2e/fixtures/agent-compaction-regressions/agent/tools/prepare-handoff.tsnew file mode 100644index 000000000..861afbfa3--- /dev/null+++ b/e2e/fixtures/agent-compaction-regressions/agent/tools/prepare-handoff.ts@@ -0,0 +1,38 @@+import { defineState } from "eve/context";+import { defineTool } from "eve/tools";+import { z } from "zod";++import { handoffNotes } from "../../release-findings";+import { handoffReferences, releaseRecords, saveReleaseRecord } from "../../release-reports";++const invocationCount = defineState("storefront.prepare-handoff", () => 0);++export default defineTool({+ description: "Prepare a release handoff from a completed storefront review record.",+ inputSchema: z.object({+ subject: z.enum(["repository", "checkout"]),+ reviewId: z.string().min(1),+ }),+ async execute(input) {+ const review = releaseRecords.get()[input.reviewId];+ if (review?.status !== "completed" || review.subject !== input.subject) {+ throw new Error("Complete the requested review before preparing its release handoff.");+ }+ const attempt = invocationCount.get() + 1;+ invocationCount.update(() => attempt);+ const report = {+ reportId: handoffReferences[input.subject],+ subject: input.subject,+ status: "completed" as const,+ findings: handoffNotes[input.subject],+ };+ saveReleaseRecord(report);+ return {+ completed: true,+ reviewId: review.reportId,+ ...report,+ attempt,+ hardStop: attempt >= 10,+ };+ },+});diff --git a/e2e/fixtures/agent-compaction-regressions/constants.ts b/e2e/fixtures/agent-compaction-regressions/constants.tsindex 53708e8ea..cab00de1e 100644--- a/e2e/fixtures/agent-compaction-regressions/constants.ts+++ b/e2e/fixtures/agent-compaction-regressions/constants.ts@@ -1,6 +1,3 @@-/** Fixture evidence emitted by the test-only second-compaction trigger tool. */-export const SECOND_CHECKPOINT_MARKER = "SECOND_CHECKPOINT_READY";-/** Trailing sentinel of the task-survival case's long task message. */export const TASK_TAIL_SENTINEL = "Include a short migration note for renamed settings.";diff --git a/e2e/fixtures/agent-compaction-regressions/evals/redundant-tool-calls.eval.ts b/e2e/fixtures/agent-compaction-regressions/evals/redundant-tool-calls.eval.tsindex 717b21863..d67b433bc 100644--- a/e2e/fixtures/agent-compaction-regressions/evals/redundant-tool-calls.eval.ts+++ b/e2e/fixtures/agent-compaction-regressions/evals/redundant-tool-calls.eval.ts@@ -1,36 +1,36 @@import { defineEval } from "eve/evals";-import { SECOND_CHECKPOINT_MARKER } from "../constants";+import { handoffReferences, reviewReferences } from "../release-reports";export default defineEval({tags: ["real-model"],- description: "Repository inspection reaches its final result across repeated compaction.",+ description: "A repository review and release handoff survive compaction without repeated work.",async test(t) {const turn = await t.send(- [- "[case: redundant-tool-calls]",- "Alice is reviewing a small reading-list application for the library and preparing a handoff for Bob.",- "Please complete one review with inspect-repository using scope repository, then use advance-checkpoint to record the handoff notes.",- "Use the completed findings for the handoff. Include REPOSITORY_INSPECTION_COMPLETE and the returned checkpoint marker in the final report so Alice and Bob can find both records.",- ].join("\n"),+ "Review the storefront repository and prepare a release handoff for the next maintainer. " ++ "Cover the catalog, cart, checkout, and order history, and call out the checks the maintainer should run before release. " ++ "Include the completed review and handoff record references in your final note.",);turn.expectOk();t.succeeded();t.calledTool("inspect-repository", {+ count: 1,input: { scope: "repository" },- output: { completed: true, completionMarker: "REPOSITORY_INSPECTION_COMPLETE" },+ output: { completed: true, reportId: reviewReferences.repository, status: "completed" },});- t.calledTool("advance-checkpoint", {- output: { checkpointMarker: SECOND_CHECKPOINT_MARKER, completed: true },+ t.calledTool("prepare-handoff", {+ count: 1,+ input: { subject: "repository", reviewId: reviewReferences.repository },+ output: { completed: true, reportId: handoffReferences.repository, status: "completed" },});t.event("compaction.completed", { count: (count) => count >= 2 });- t.messageIncludes("REPOSITORY_INSPECTION_COMPLETE");- t.messageIncludes(SECOND_CHECKPOINT_MARKER);+ t.messageIncludes(reviewReferences.repository);+ t.messageIncludes(handoffReferences.repository);t.noFailedActions();t.calledTool("inspect-repository", { count: 1 }).soft().label("no repeated inspection");- t.calledTool("advance-checkpoint", { count: 1 }).soft().label("no repeated checkpoint");+ t.calledTool("prepare-handoff", { count: 1 }).soft().label("no repeated handoff");t.event("compaction.completed", { count: 2 }).soft().label("compaction efficiency");},});diff --git a/e2e/fixtures/agent-compaction-regressions/evals/stale-todo-work.eval.ts b/e2e/fixtures/agent-compaction-regressions/evals/stale-todo-work.eval.tsindex 286e4b933..d9a1bba40 100644--- a/e2e/fixtures/agent-compaction-regressions/evals/stale-todo-work.eval.ts+++ b/e2e/fixtures/agent-compaction-regressions/evals/stale-todo-work.eval.ts@@ -1,36 +1,36 @@import { defineEval } from "eve/evals";-import { SECOND_CHECKPOINT_MARKER } from "../constants";+import { handoffReferences, reviewReferences } from "../release-reports";export default defineEval({tags: ["real-model"],- description: "Source analysis completes across compaction despite a stale pending todo.",+ description: "A completed checkout review stays complete when the task board has a stale todo.",async test(t) {const turn = await t.send(- [- "[case: stale-todo-work]",- "Alice and Bob are reviewing a small reading-list application for their library.",- "Alice needs one source review. Please prepare her findings with perform-source-analysis using approach initial.",- "Bob updates their shared checklist separately, so it may still say pending after Alice's review is complete.",- "Please use advance-checkpoint to record the handoff from those completed findings. Include SOURCE_ANALYSIS_COMPLETE and the returned checkpoint marker in the final report so Alice and Bob can find both records.",- ].join("\n"),+ "Review the checkout implementation and prepare a release handoff for the next maintainer. " ++ "Check pricing, inventory, order persistence, and customer notifications. The task board may be out of date; " ++ "use the completed review as the source of truth. Include the review and handoff record references in your final note.",);turn.expectOk();t.succeeded();t.calledTool("perform-source-analysis", {- output: { completed: true, workUnit: "source-analysis" },+ count: 1,+ input: { scope: "checkout" },+ output: { completed: true, reportId: reviewReferences.checkout, status: "completed" },});- t.calledTool("advance-checkpoint", {- output: { checkpointMarker: SECOND_CHECKPOINT_MARKER, completed: true },+ t.calledTool("prepare-handoff", {+ count: 1,+ input: { subject: "checkout", reviewId: reviewReferences.checkout },+ output: { completed: true, reportId: handoffReferences.checkout, status: "completed" },});t.event("compaction.completed", { count: (count) => count >= 2 });- t.messageIncludes("SOURCE_ANALYSIS_COMPLETE");- t.messageIncludes(SECOND_CHECKPOINT_MARKER);+ t.messageIncludes(reviewReferences.checkout);+ t.messageIncludes(handoffReferences.checkout);t.noFailedActions();t.calledTool("perform-source-analysis", { count: 1 }).soft().label("no repeated analysis");- t.calledTool("advance-checkpoint", { count: 1 }).soft().label("no repeated checkpoint");+ t.calledTool("prepare-handoff", { count: 1 }).soft().label("no repeated handoff");t.event("compaction.completed", { count: 2 }).soft().label("compaction efficiency");},});diff --git a/e2e/fixtures/agent-compaction-regressions/evals/task-survival.eval.ts b/e2e/fixtures/agent-compaction-regressions/evals/task-survival.eval.tsindex 4688615aa..be2a020e1 100644--- a/e2e/fixtures/agent-compaction-regressions/evals/task-survival.eval.ts+++ b/e2e/fixtures/agent-compaction-regressions/evals/task-survival.eval.ts@@ -12,7 +12,7 @@ export default defineEval({"Alice is updating the library's reading-list application. Please review the repository and confirm these requirements for Bob's handoff.",// Sized to a narrow window: long enough that a 280-char summarizer// input cap would destroy the tail sentinel, but short enough that- // the task alone cannot cross the fixture's ~640-token threshold —+ // the task alone cannot cross the fixture's ~640-token history budget —// otherwise compaction fires before the first model call and the// mock never generates pressure.[diff --git a/e2e/fixtures/agent-compaction-regressions/release-findings.ts b/e2e/fixtures/agent-compaction-regressions/release-findings.tsnew file mode 100644index 000000000..7ba3f1f88--- /dev/null+++ b/e2e/fixtures/agent-compaction-regressions/release-findings.ts@@ -0,0 +1,68 @@+export const repositoryFindings = [+ "Application startup loads configuration before registering the catalog, cart, checkout, and order routes. An invalid currency setting prevents the application from accepting requests and identifies the setting that needs correction.",+ "The catalog exposes product identifiers, display names, prices in cents, and availability. Product identifiers remain stable when a display name changes, so a saved cart continues to identify the intended product.",+ "Catalog searches return an empty collection when nothing matches. The storefront distinguishes that state from a failed search and offers a clear way to remove filters without losing the customer's current cart.",+ "The cart accepts positive integer quantities and rejects zero, negative, and fractional values. Adding an existing product updates its quantity, while removing the final product leaves an empty cart that can still be displayed.",+ "Checkout obtains current prices from the catalog instead of trusting totals submitted by the browser. A price change is shown for confirmation before the order is accepted, allowing the customer to review the revised amount.",+ "Inventory is checked again when an order is submitted. An unavailable product produces an explanation while preserving the other cart contents, so the customer can remove that item and continue without rebuilding the cart.",+ "Order persistence stores product descriptions and prices alongside quantities. Order history therefore continues to show what the customer purchased even if a product is later renamed, repriced, or removed from the catalog.",+ "The order confirmation reads the saved order rather than recalculating it from current catalog values. Its subtotal, delivery charge, and final total agree with the amounts presented at the time the order was accepted.",+ "Confirmation notifications are scheduled only after the order write succeeds. A delivery failure is recorded separately from the purchase, and retrying the notification does not create another order or charge the customer again.",+ "Order history uses a bounded page size and a continuation cursor. Results have a stable ordering for orders created at the same time, preventing duplicates or omissions when a customer moves between adjacent history pages.",+ "Cancellation checks the saved order status before changing inventory. Repeated cancellation requests return the already cancelled order, while an order that has entered fulfillment receives a clear explanation of why cancellation is unavailable.",+ "Customer supplied names and address labels are rendered as text in the storefront and confirmation. Long values wrap within their sections, and empty optional address lines do not create blank labels or misleading punctuation.",+ "The shared error response distinguishes invalid input, unavailable inventory, and temporary service failure. Customer messages omit internal details, while server diagnostics retain the originating error for the support investigation.",+ "The review covers startup, catalog, cart, checkout, saved orders, and notifications. Release validation should now concentrate on the purchase and cancellation journeys, including retries, without repeating this repository inspection.",+];++export const checkoutFindings = [+ "Checkout validates the cart before creating an order. Empty carts receive an actionable response, and malformed quantities are rejected before inventory is reserved or any payment request is prepared for the customer.",+ "Product prices are read from the current catalog during submission. The checkout comparison detects changes since the cart was displayed and asks the customer to accept the new total instead of silently using an outdated amount.",+ "Amounts are represented in integer cents throughout subtotal, delivery, and total calculations. Rounding occurs at the boundary where a price is displayed, so summing individual items produces the same amount as the saved order total.",+ "Delivery charges depend on the validated delivery selection. An unknown selection does not fall back to an arbitrary charge, and a previously chosen option is checked again when the customer changes the destination address.",+ "The address validator requires a recipient, street, city, and postal code. Optional address lines stay optional during validation and persistence, while surrounding whitespace is normalized before the confirmed address is shown.",+ "Availability is checked for every requested product before the order is accepted. A failed availability check preserves the cart and identifies the affected item, allowing correction without losing quantities for other products.",+ "A submission identifier connects retries of the same purchase. Repeating an accepted submission returns the original order, and a conflicting request with that identifier is rejected instead of replacing the saved purchase details.",+ "The saved order contains its items, quantities, accepted prices, delivery details, and final total together. The confirmation identifier is returned only after that write succeeds, avoiding a success page for an order that was never stored.",+ "Confirmation rendering uses the saved purchase values. Catalog updates after acceptance cannot change the receipt, and the customer can match each line item and the delivery charge to the final amount reported by checkout.",+ "Notification delivery begins after persistence and uses the existing order identifier. Temporary notification failures are retried independently, preserving the successful purchase and preventing a second order from being submitted.",+ "Cancellation reads the latest persisted status and applies the transition once. A repeated request reports the existing result without restoring inventory twice, while fulfillment that has already started prevents cancellation with a useful response.",+ "Order access is checked against the authenticated customer before saved details are returned. A missing or inaccessible order produces a generic response, and confirmation links cannot be used to inspect another customer's delivery address.",+ "The checkout failure paths leave enough information for a safe retry. Validation errors identify the field to correct, temporary service failures retain the cart, and uncertain submission outcomes can be resolved using the original submission identifier.",+ "The source analysis is complete and its findings are ready for the release handoff. The review task may still appear pending in the tracker; that bookkeeping state does not require another checkout analysis or repeated source inspection.",+];++export const handoffNotes = {+ repository: [+ "Repository review is complete for application startup, catalog browsing, cart updates, checkout, order history, and notifications. Carry these findings into release validation; the next reviewer should not repeat the completed inspection.",+ "Start release validation with a catalog containing available and unavailable products. Confirm that filters show an empty state when appropriate and that clearing a filter restores the product list while preserving the current cart contents.",+ "Exercise cart updates with a new product, an existing product, and removal of the final item. Include invalid quantities and confirm that rejected updates leave the last valid cart visible, with an explanation tied to the offending input.",+ "For the purchase journey, compare displayed prices, accepted prices, and the saved confirmation. Introduce a catalog price change before submission and verify that the customer must confirm the revised amount before an order is accepted.",+ "Test an inventory change between browsing and checkout. The unavailable item should be identified without discarding the rest of the cart, and removing it should allow the customer to continue through the same checkout session.",+ "Keep the resulting order identifier with the release evidence. Compare its stored line items and total against the confirmation, then update the catalog and confirm that the historical receipt still reflects the original purchase.",+ "Check the notification path after a successful purchase. A temporary delivery failure should be visible to operations without turning the accepted purchase into a failure, and a retry should reference the same order identifier.",+ "Validate cancellation before fulfillment and repeat the request. Confirm that the order stays cancelled, inventory changes only once, and a later attempt to cancel an order already in fulfillment receives an understandable response.",+ "Use enough saved orders to cross a history page boundary. Include equal creation times and verify stable ordering across consecutive pages, with no duplicate order cards and no missing records when following the continuation cursor.",+ "Review the customer-facing screens with long product names and address labels. Content should remain readable without being interpreted as markup, and optional empty address lines should not produce stray labels or confusing separators.",+ "During failure testing, record the customer-visible message and the corresponding internal error reference separately. Confirm that the customer can choose a recovery action without receiving private addresses, credentials, or server implementation details.",+ "The release owner should collect results for the purchase, cancellation, and notification journeys before approval. A failed journey needs its own reproduction and recovery check; a passed repository review does not replace that behavioral evidence.",+ "Keep unresolved release checks distinct from completed review work in the handoff. If validation exposes a new defect, record the new observation and affected journey rather than reopening the repository inspection without additional evidence.",+ "After the release checks are recorded, publish the concise handoff with the completed review result and checkpoint status. No further repository inspection is needed merely because an earlier tracker item has not yet been marked complete.",+ ],+ checkout: [+ "Checkout source analysis is complete, including price confirmation, validation, availability, submission retries, persistence, and cancellation. The next step is release validation using these findings, without rerunning the completed source analysis.",+ "Prepare a valid cart and address as the baseline purchase. Record the subtotal, delivery charge, and final total before submission, then compare those amounts with the saved order and customer confirmation after the purchase succeeds.",+ "Verify that an empty cart and each invalid quantity are rejected before acceptance. The error should identify what the customer can correct, and the application should preserve unrelated valid cart entries rather than forcing a complete restart.",+ "Change a product price after the cart is displayed but before checkout submission. Confirm that the new amount is presented for approval and that the order records only the price the customer explicitly accepted during that submission.",+ "Exercise the delivery selector with a valid option, an unknown option, and a destination change. The final charge must correspond to the validated selection and address, with no silent substitution that changes the customer's expected total.",+ "Check required address fields and optional secondary lines independently. Use whitespace around valid values and confirm that normalization does not discard meaningful address content or introduce empty labels in the saved confirmation.",+ "Make one cart product unavailable immediately before submission. Confirm that checkout names the affected product, preserves the other quantities, and allows the customer to continue after correcting the cart without creating a partial order.",+ "Submit the same purchase again with the original submission identifier. The result should reference the accepted order rather than create another purchase; a changed payload using that identifier must receive a conflict response instead of overwriting it.",+ "Simulate a failure before persistence completes and distinguish it from a lost response after a successful write. Recovery should use the submission identifier to determine the outcome before any retry can create a duplicate purchase or notification.",+ "After acceptance, compare the stored item descriptions and prices with the receipt. A later catalog edit must not alter this historical confirmation, and the delivery details should remain associated with the same order identifier.",+ "Interrupt notification delivery after the order has been stored, then retry delivery. The purchase must remain successful, and the notification retry should use the existing order without resubmitting payment or changing the accepted line items.",+ "For cancellation, test both a cancellable order and one already entering fulfillment. Repeat the successful cancellation and verify that inventory is adjusted once; record the customer explanation for the order that cannot be cancelled.",+ "Check order detail access using the owning customer and a different customer. Only the owner should receive the saved address and purchase details; the other response should avoid revealing whether that order belongs to someone else.",+ "Preserve the completed checkout findings in the release record even if the tracker still lists the analysis as pending. Update bookkeeping separately when appropriate, then finish the handoff with the analysis result and recorded checkpoint status.",+ ],+};diff --git a/e2e/fixtures/agent-compaction-regressions/release-reports.ts b/e2e/fixtures/agent-compaction-regressions/release-reports.tsnew file mode 100644index 000000000..fe15eea5b--- /dev/null+++ b/e2e/fixtures/agent-compaction-regressions/release-reports.ts@@ -0,0 +1,29 @@+import { defineState } from "eve/context";++export type ReviewSubject = "repository" | "checkout";++export const reviewReferences = {+ repository: "reviews/storefront/repository",+ checkout: "reviews/storefront/checkout",+} as const;++export const handoffReferences = {+ repository: "handoffs/storefront/repository",+ checkout: "handoffs/storefront/checkout",+} as const;++export interface ReleaseRecord {+ readonly reportId: string;+ readonly subject: ReviewSubject;+ readonly status: "completed";+ readonly findings: readonly string[];+}++export const releaseRecords = defineState<Record<string, ReleaseRecord>>(+ "storefront.release-records",+ () => ({}),+);++export function saveReleaseRecord(record: ReleaseRecord): void {+ releaseRecords.update((records) => ({ ...records, [record.reportId]: record }));+}diff --git a/e2e/fixtures/agent-compaction-regressions/report-evidence.ts b/e2e/fixtures/agent-compaction-regressions/report-evidence.tsnew file mode 100644index 000000000..f4cb2e0ef--- /dev/null+++ b/e2e/fixtures/agent-compaction-regressions/report-evidence.ts@@ -0,0 +1,15 @@+export function assistantHasReport(+ messages: readonly { role: string; text: string }[],+ reference: string,+): boolean {+ if (reference.length === 0) return false;++ const escapedReference = reference.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");+ const recordReference = new RegExp(`(?<![\\w/-])${escapedReference}(?![\\w/-])`);++ // Only successful tool results introduce these references. Requiring their+ // retention in assistant text proves they survived a checkpoint or trail.+ return messages.some(+ (message) => message.role === "assistant" && recordReference.test(message.text),+ );+}diff --git a/e2e/fixtures/agent-prompt-cache/evals/parallel-review.eval.ts b/e2e/fixtures/agent-prompt-cache/evals/parallel-review.eval.tsindex 6f6dac4fc..b4167fdf4 100644--- a/e2e/fixtures/agent-prompt-cache/evals/parallel-review.eval.ts+++ b/e2e/fixtures/agent-prompt-cache/evals/parallel-review.eval.ts@@ -17,14 +17,19 @@ export default ["first", "later"].map((launchTurn) =>async test(t) {if (launchTurn === "later") {const planning = await t.send(- "Eight workshops have twelve places each. How many places is that in total?",+ "Alice is planning a community centre event with eight workshops and twelve places per workshop. " ++ "Please calculate the total number of places. Bob is preparing the purchasing sheets and will send them next for review.",);expectHealthyTurn(planning);planning.messageIncludes("96");planning.notEvent("actions.requested");}- const started = await t.send(reviewPacket());+ const started = await t.send(+ launchTurn === "later"+ ? `Bob has the purchasing sheets ready for the event we just discussed.\n\n${reviewPacket()}`+ : reviewPacket(),+ );const taskIds = expectFiveReviewers(started);const turns = await waitForReviews(t, started, taskIds);await expectParallelReviews(t, turns);diff --git a/packages/eve/src/harness/compaction.test.ts b/packages/eve/src/harness/compaction.test.tsindex 118312ce1..7c3cbba98 100644--- a/packages/eve/src/harness/compaction.test.ts+++ b/packages/eve/src/harness/compaction.test.ts@@ -154,6 +154,34 @@ describe("getInputTokenCount", () => {expect(result).toBeGreaterThan(42 + 20);expect(result).toBeLessThan(42 + 40);});+ it("counts only positive envelope growth above the previous provider usage", () => {+ const messages: ModelMessage[] = [{ role: "user", content: "unchanged" }];+ const measured = {+ ...config,+ lastKnownInputTokens: 8_000,+ lastKnownPromptMessageCount: 1,+ };+ const stable = getInputTokenCount(messages, measured, 3_000, 3_000);+ expect(stable).toBe(8_000 + estimateTokens([]));+ expect(getInputTokenCount(messages, measured, 5_000, 3_000)).toBe(stable + 2_000);+ expect(getInputTokenCount(messages, measured, 1_000, 3_000)).toBe(stable);+ });++ it("includes the full envelope when provider usage cannot describe the current history", () => {+ const messages: ModelMessage[] = [{ role: "user", content: "replacement" }];+ expect(getInputTokenCount(messages, config, 3_000)).toBe(estimateTokens(messages) + 3_000);+ expect(+ getInputTokenCount(+ messages,+ {+ ...config,+ lastKnownInputTokens: 8_000,+ lastKnownPromptMessageCount: 5,+ },+ 3_000,+ ),+ ).toBe(estimateTokens(messages) + 3_000);+ });});describe("shouldCompact", () => {@@ -439,6 +467,44 @@ describe("compactMessages: tool-result cap heuristic", () => {expect(summarizer).not.toHaveBeenCalled();},);+ it("credits removed history against an explicit history-only token floor", async () => {+ const { generateText } = await import("ai");+ const [call, resultMsg] = toolExchange({ callId: "large", payloadChars: 40_000 });+ const messages = [user("investigate"), call, resultMsg, user("continue")];+ const result = await compactMessages(+ messages,+ {} as Parameters<typeof compactMessages>[1],+ { threshold: 10_000, recentWindowSize: 1 },+ undefined,+ undefined,+ undefined,+ undefined,+ false,+ 15_000,+ );+ expect(generateText).not.toHaveBeenCalled();+ expect(estimateTokens(result)).toBeLessThan(2_000);+ expect(result.map((entry) => entry.role)).toEqual(messages.map((entry) => entry.role));+ });++ it("summarizes when a no-op cannot satisfy the explicit history-only token floor", async () => {+ const { generateText } = await import("ai");+ vi.mocked(generateText).mockResolvedValue({ text: "summary" } as Awaited<+ ReturnType<typeof generateText>+ >);+ await compactMessages(+ [user("earlier"), assistant("reply"), user("continue")],+ {} as Parameters<typeof compactMessages>[1],+ { threshold: 2_000, recentWindowSize: 0 },+ undefined,+ undefined,+ undefined,+ undefined,+ false,+ 8_000,+ );+ expect(generateText).toHaveBeenCalledOnce();+ });it("caps oversized older tool results in place without calling the summarizer", async () => {const [call, resultMsg] = toolExchange({diff --git a/packages/eve/src/harness/compaction.ts b/packages/eve/src/harness/compaction.tsindex fbf7cea54..831a897f8 100644--- a/packages/eve/src/harness/compaction.ts+++ b/packages/eve/src/harness/compaction.ts@@ -37,6 +37,8 @@ const COMPACTION_PROMPT_OVERHEAD_TOKENS = estimateTokens([export function getInputTokenCount(messages: readonly ModelMessage[],config: CompactionConfig,+ requestEnvelopeTokens = 0,+ previousEnvelopeTokens = 0,): number {const prior = config.lastKnownInputTokens;const priorCount = config.lastKnownPromptMessageCount;@@ -48,10 +50,14 @@ export function getInputTokenCount(priorCount < 0 ||priorCount > messages.length) {- return estimateTokens(messages);+ return estimateTokens(messages) + requestEnvelopeTokens;}- return prior + estimateTokens(messages.slice(priorCount));+ return (+ prior ++ estimateTokens(messages.slice(priorCount)) ++ Math.max(0, requestEnvelopeTokens - previousEnvelopeTokens)+ );}/**@@ -61,10 +67,14 @@ export function getInputTokenCount(export function shouldCompact(messages: readonly ModelMessage[],config: CompactionConfig,+ requestEnvelopeTokens = 0,+ previousEnvelopeTokens = 0,): boolean {return (messages.length > 0 &&- getInputTokenCount(messages, config) + COMPACTION_PROMPT_OVERHEAD_TOKENS > config.threshold+ getInputTokenCount(messages, config, requestEnvelopeTokens, previousEnvelopeTokens) ++ COMPACTION_PROMPT_OVERHEAD_TOKENS >+ config.threshold);}@@ -194,6 +204,7 @@ export async function compactMessages(headers?: Record<string, string>,abortSignal?: AbortSignal,forceSummary = false,+ historyInputTokenCount?: number,): Promise<ModelMessage[]> {const { conversation, previousCheckpoint } = extractPreviousCheckpoint(messages);const recentConfig = forceSummary ? { ...config, recentWindowSize: 1 } : config;@@ -210,7 +221,7 @@ export async function compactMessages(// A new summary replaces that prompt, so it uses its own estimate below.const tokenEstimateAdjustment = Math.max(0,- getInputTokenCount(messages, config) - estimateTokens(messages),+ (historyInputTokenCount ?? getInputTokenCount(messages, config)) - estimateTokens(messages),);for (const heuristic of COMPACTION_HEURISTICS) {const outcome = heuristic({diff --git a/packages/eve/src/harness/request-envelope.test.ts b/packages/eve/src/harness/request-envelope.test.tsnew file mode 100644index 000000000..440b59c13--- /dev/null+++ b/packages/eve/src/harness/request-envelope.test.ts@@ -0,0 +1,85 @@+import { jsonSchema, type ModelMessage, type ToolSet } from "ai";+import { describe, expect, it } from "vitest";++import { z } from "#compiled/zod/index.js";+import { estimateRequestEnvelope } from "#harness/request-envelope.js";++const history: ModelMessage[] = [{ role: "user", content: "Continue." }];+const estimate = (tools: ToolSet, instructions = "System policy.") =>+ estimateRequestEnvelope({ history, instructions, messages: history, tools });++describe("effective request envelope", () => {+ it("includes authored Standard Schema descriptions without traversing schema internals", async () => {+ const small = await estimate({ search: { inputSchema: z.object({ query: z.string() }) } });+ const large = await estimate({+ search: {+ inputSchema: z.object({ query: z.string().describe("catalog policy ".repeat(1_000)) }),+ },+ });+ expect(large - small).toBeGreaterThan(3_000);+ });++ it("resolves lazy and asynchronous JSON schemas before estimating", async () => {+ const schema = jsonSchema(+ Promise.resolve({+ type: "object" as const,+ description: "catalog policy ".repeat(1_000),+ }),+ );+ let resolutions = 0;+ const eager = await estimate({ search: { inputSchema: schema } });+ const deferred = await estimate({+ search: {+ inputSchema: () => {+ resolutions++;+ return schema;+ },+ },+ });+ expect(deferred).toBe(eager);+ expect(deferred).toBeGreaterThan(3_000);+ expect(resolutions).toBe(1);+ });++ it("includes provider identifiers and configured arguments", async () => {+ const provider = (domain: string): ToolSet => ({+ search: {+ type: "provider",+ isProviderExecuted: true,+ id: "test.search",+ args: { domain },+ inputSchema: z.object({}),+ },+ });+ const small = await estimate(provider("example.com"));+ const large = await estimate(provider("example.com ".repeat(1_000)));+ expect(large - small).toBeGreaterThan(2_000);+ });++ it("counts only request-only additions beyond the projected history", async () => {+ const base = await estimateRequestEnvelope({+ history,+ messages: history,+ tools: {},+ instructions: "System policy.",+ });+ const repeatedHistory = [+ ...history,+ { role: "user" as const, content: "history ".repeat(1_000) },+ ];+ const stable = await estimateRequestEnvelope({+ history: repeatedHistory,+ messages: repeatedHistory,+ tools: {},+ instructions: "System policy.",+ });+ expect(stable).toBe(base);+ const withRetry = await estimateRequestEnvelope({+ history,+ messages: [...history, { role: "user", content: "Retry note ".repeat(1_000) }],+ tools: {},+ instructions: "System policy.",+ });+ expect(withRetry - base).toBeGreaterThan(2_000);+ });+});diff --git a/packages/eve/src/harness/request-envelope.ts b/packages/eve/src/harness/request-envelope.tsnew file mode 100644index 000000000..2b7807275--- /dev/null+++ b/packages/eve/src/harness/request-envelope.ts@@ -0,0 +1,56 @@+import type { ModelMessage, ToolSet } from "ai";+import type { HarnessSession } from "#harness/types.js";++import { serializeInputSchema, type ToolSchemaSource } from "#tools/schema.js";+import { estimateTokens } from "#harness/token-estimate.js";++/** Count only request content outside the durable model-visible history. */+export async function estimateRequestEnvelope(input: {+ readonly history: readonly ModelMessage[];+ readonly instructions: unknown;+ readonly messages: readonly ModelMessage[];+ readonly tools: ToolSet;+}): Promise<number> {+ const tools = await Promise.all(+ Object.entries(input.tools).map(async ([name, tool]) => {+ const schema = typeof tool.inputSchema === "function" ? tool.inputSchema() : tool.inputSchema;+ const inputSchema =+ schema === undefined+ ? undefined+ : "jsonSchema" in schema+ ? await schema.jsonSchema+ : serializeInputSchema(schema as ToolSchemaSource);+ return {+ name,+ description: tool.description,+ inputSchema,+ id: tool.type === "provider" ? tool.id : undefined,+ args: tool.type === "provider" ? tool.args : undefined,+ };+ }),+ );+ return Math.max(+ 0,+ estimateTokens({ instructions: input.instructions, messages: input.messages, tools }) -+ estimateTokens(input.history),+ );+}++const REQUEST_ENVELOPE_STATE_KEY = "eve.harness.requestEnvelopeTokens";++export function getRequestEnvelopeTokens(session: HarnessSession): number | undefined {+ const value = session.state?.[REQUEST_ENVELOPE_STATE_KEY];+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined;+}++export function setRequestEnvelopeTokens(+ session: HarnessSession,+ tokens: number | undefined,+): HarnessSession {+ if (tokens === undefined && session.state?.[REQUEST_ENVELOPE_STATE_KEY] === undefined)+ return session;+ const state = { ...session.state };+ if (tokens === undefined) delete state[REQUEST_ENVELOPE_STATE_KEY];+ else state[REQUEST_ENVELOPE_STATE_KEY] = tokens;+ return { ...session, state };+}diff --git a/packages/eve/src/harness/tool-loop-compaction-accounting.test.ts b/packages/eve/src/harness/tool-loop-compaction-accounting.test.tsindex 0254d47a9..b3a95acce 100644--- a/packages/eve/src/harness/tool-loop-compaction-accounting.test.ts+++ b/packages/eve/src/harness/tool-loop-compaction-accounting.test.ts@@ -1,3 +1,4 @@+import { getRequestEnvelopeTokens } from "#harness/request-envelope.js";import { generateText, jsonSchema, type LanguageModel, ToolLoopAgent } from "ai";import { afterEach, describe, expect, it, vi } from "vitest";@@ -91,7 +92,7 @@ function setupMockAgentSequence(results: readonly Record<string, unknown>[]): vo) {const { onStepEnd, onStepStart, prepareStep } = settings;- this.generate = vi.fn().mockImplementation(async (options: { messages: unknown[] }) => {+ const generate = vi.fn().mockImplementation(async (options: { messages: unknown[] }) => {const result = queue.shift();if (result === undefined) {throw new Error("No mock ToolLoopAgent result available.");@@ -125,7 +126,18 @@ function setupMockAgentSequence(results: readonly Record<string, unknown>[]): voreturn { ...result, responseMessages: getMockResponseMessages(result) };});- this.stream = vi.fn();+ this.generate = generate;+ this.stream = vi.fn(async (options: { messages: unknown[] }) => {+ const result = await generate(options);+ return {+ fullStream: new ReadableStream({+ start(controller) {+ controller.close();+ },+ }),+ responseMessages: Promise.resolve(result.responseMessages),+ };+ });return this as unknown as ToolLoopAgent;} as unknown as MockAgentConstructor);@@ -177,7 +189,9 @@ describe("tool-loop structured compaction accounting", () => {const runStep = createToolLoopHarness(createTestConfig({historyProjector: projectMemoryHistoryFromSessionState,- resolveModel: vi.fn().mockResolvedValue({ modelId: "test-model" } as LanguageModel),+ resolveModel: vi+ .fn()+ .mockResolvedValue({ provider: "test", modelId: "test-model" } as LanguageModel),}),);@@ -277,7 +291,9 @@ describe("tool-loop structured compaction accounting", () => {const runStep = createToolLoopHarness(createTestConfig({- resolveModel: vi.fn().mockResolvedValue({ modelId: "test-model" } as LanguageModel),+ resolveModel: vi+ .fn()+ .mockResolvedValue({ provider: "test", modelId: "test-model" } as LanguageModel),}),);@@ -445,3 +461,193 @@ describe("tool-loop structured compaction accounting", () => {).toEqual(largeOutput);});});++it("compacts history when dynamic instructions grow the request envelope", async () => {+ const { ContextContainer, contextStorage } = await import("#context/container.js");+ const { SessionDynamicInstructionsKey } = await import("#context/keys.js");+ vi.mocked(generateText).mockResolvedValue({ text: "summary" } as Awaited<+ ReturnType<typeof generateText>+ >);+ setupMockAgentSequence([+ {+ finishReason: "stop",+ response: { messages: [{ content: "Done.", role: "assistant" }] },+ text: "Done.",+ toolCalls: [],+ toolResults: [],+ },+ ]);+ const ctx = new ContextContainer();+ const dynamicInstructions = "tenant business policy ".repeat(1000);+ ctx.set(SessionDynamicInstructionsKey, {+ tenant: [{ role: "system", content: dynamicInstructions }],+ });+ const runStep = createToolLoopHarness(createTestConfig());+ await contextStorage.run(ctx, () =>+ runStep(+ createTestSession({+ compaction: {+ lastKnownInputTokens: 8000,+ lastKnownPromptMessageCount: 1,+ recentWindowSize: 0,+ threshold: 10000,+ },+ history: [{ role: "user", kind: "user", content: "earlier conversation ".repeat(1000) }],+ }),+ { message: "continue" },+ ),+ );+ expect(JSON.stringify(vi.mocked(ToolLoopAgent).mock.calls[0]?.[0].instructions)).toContain(+ dynamicInstructions,+ );+ expect(generateText).toHaveBeenCalledOnce();+});++describe("final request envelope compaction", () => {+ const completed = () => ({+ finishReason: "stop",+ response: { messages: [{ content: "Done.", role: "assistant" }] },+ text: "Done.",+ toolCalls: [],+ toolResults: [],+ usage: { inputTokens: 8_000 },+ });++ it("does not double-count stable instructions on later turns", async () => {+ const { ContextContainer, contextStorage } = await import("#context/container.js");+ const { SessionDynamicInstructionsKey } = await import("#context/keys.js");+ const ctx = new ContextContainer();+ ctx.set(SessionDynamicInstructionsKey, {+ tenant: [{ role: "system", content: "tenant policy ".repeat(1_000) }],+ });+ setupMockAgentSequence([completed(), completed(), completed()]);+ vi.mocked(generateText).mockResolvedValue({ text: "summary" } as Awaited<+ ReturnType<typeof generateText>+ >);+ const runStep = createToolLoopHarness(createTestConfig());+ const first = await contextStorage.run(ctx, () =>+ runStep(+ createTestSession({+ compaction: { recentWindowSize: 0, threshold: 10_000 },+ }),+ { message: "First" },+ ),+ );+ expect(getRequestEnvelopeTokens(first.session)).toBeGreaterThan(3_000);+ const second = await contextStorage.run(ctx, () =>+ runStep(first.session, { message: "Second" }),+ );+ expect(generateText).not.toHaveBeenCalled();+ expect(getRequestEnvelopeTokens(second.session)).toBe(getRequestEnvelopeTokens(first.session));+ ctx.set(SessionDynamicInstructionsKey, {+ tenant: [{ role: "system", content: "tenant policy ".repeat(2_000) }],+ });+ await contextStorage.run(ctx, () => runStep(second.session, { message: "Third" }));+ expect(generateText).toHaveBeenCalledOnce();+ });++ it("counts dynamic schemas resolved by step.started before calling the model", async () => {+ const { ContextContainer, contextStorage } = await import("#context/container.js");+ const { SessionDynamicToolMetadataKey, SessionIdKey } = await import("#context/keys.js");+ const ctx = new ContextContainer();+ ctx.set(SessionIdKey, "test-session");+ const schemaDescription = "connector catalog field ".repeat(1_000);+ const events: string[] = [];+ setupMockAgentSequence([completed()]);+ vi.mocked(generateText).mockResolvedValue({ text: "summary" } as Awaited<+ ReturnType<typeof generateText>+ >);+ const runStep = createToolLoopHarness(+ createTestConfig({+ resolveModel: vi+ .fn()+ .mockResolvedValue({ provider: "test", modelId: "test-model" } as LanguageModel),+ handleEvent: async (event) => {+ events.push(event.type);+ if (event.type === "step.started")+ ctx.set(SessionDynamicToolMetadataKey, [+ {+ name: "catalog",+ resolverSlug: "connector",+ entryKey: "catalog",+ description: "Connector catalog",+ inputSchema: { type: "object", description: schemaDescription },+ callbacks: { execute: { closure: {} } },+ },+ ]);+ },+ }),+ );+ await contextStorage.run(ctx, () =>+ runStep(+ createTestSession({+ compaction: {+ lastKnownInputTokens: 8_000,+ lastKnownPromptMessageCount: 1,+ recentWindowSize: 0,+ threshold: 10_000,+ },+ history: [{ role: "user", kind: "user", content: "earlier" }],+ }),+ { message: "continue" },+ ),+ );+ expect(generateText).toHaveBeenCalledOnce();+ expect(events.indexOf("compaction.requested")).toBeGreaterThan(events.indexOf("step.started"));+ expect(vi.mocked(ToolLoopAgent).mock.calls[0]?.[0].tools).toHaveProperty("catalog");+ });++ it("does not count a capability-filtered tool that the provider never sees", async () => {+ setupMockAgentSequence([completed()]);+ const runStep = createToolLoopHarness(+ createTestConfig({+ tools: new Map([+ [+ "hidden",+ {+ name: "hidden",+ description: "private catalog ".repeat(10_000),+ inputSchema: jsonSchema({ type: "object" }),+ behavior: { availability: ["requires-request-input"] },+ },+ ],+ ]),+ }),+ );+ await runStep(+ createTestSession({+ compaction: {+ lastKnownInputTokens: 8_000,+ lastKnownPromptMessageCount: 1,+ recentWindowSize: 0,+ threshold: 10_000,+ },+ history: [{ role: "user", kind: "user", content: "earlier" }],+ }),+ { message: "continue" },+ );+ expect(generateText).not.toHaveBeenCalled();+ expect(vi.mocked(ToolLoopAgent).mock.calls[0]?.[0].tools).not.toHaveProperty("hidden");+ });+ it("propagates a compaction callback failure without treating it as a model failure", async () => {+ const error = new Error("memory recall failed");+ const onCompaction = vi.fn(() => {+ throw error;+ });+ vi.mocked(generateText).mockResolvedValue({ text: "summary" } as Awaited<+ ReturnType<typeof generateText>+ >);+ const runStep = createToolLoopHarness(createTestConfig({ onCompaction }));+ await expect(+ runStep(+ createTestSession({+ compaction: { recentWindowSize: 0, threshold: 100 },+ history: [{ role: "user", kind: "user", content: "history ".repeat(1_000) }],+ }),+ { message: "continue" },+ ),+ ).rejects.toBe(error);+ expect(onCompaction).toHaveBeenCalledOnce();+ expect(ToolLoopAgent).not.toHaveBeenCalled();+ });+});diff --git a/packages/eve/src/harness/tool-loop-request-envelope.integration.test.ts b/packages/eve/src/harness/tool-loop-request-envelope.integration.test.tsnew file mode 100644index 000000000..2be9750f0--- /dev/null+++ b/packages/eve/src/harness/tool-loop-request-envelope.integration.test.ts@@ -0,0 +1,162 @@+import { getRequestEnvelopeTokens } from "#harness/request-envelope.js";+import type { LanguageModel } from "ai";+import { describe, expect, it } from "vitest";++import { ContextContainer, contextStorage } from "#context/container.js";+import { PendingSkillAnnouncementKey } from "#context/dynamic-skill-lifecycle.js";+import { SessionDynamicInstructionsKey } from "#context/keys.js";+import { mockModel, type MockModelRequest } from "#evals/mock-model.js";+import { createToolLoopHarness } from "#harness/tool-loop.js";+import type { HarnessSession } from "#harness/types.js";++function session(): HarnessSession {+ return {+ agent: {+ modelReference: { id: "task" },+ compactionModelReference: { id: "summary" },+ system: "You are a test assistant.",+ tools: [],+ },+ compaction: { recentWindowSize: 0, threshold: 10_000 },+ continuationToken: "http:envelope",+ history: [],+ sessionId: "envelope",+ };+}++function setInstructions(ctx: ContextContainer, repetitions: number): string {+ const content = "tenant business policy ".repeat(repetitions);+ ctx.set(SessionDynamicInstructionsKey, { tenant: [{ role: "system", content }] });+ return content;+}++describe("model request envelope accounting", () => {+ it("preserves provider usage for stable instructions and compacts when they grow", async () => {+ const ctx = new ContextContainer();+ setInstructions(ctx, 600);+ const requests: MockModelRequest[] = [];+ let summaries = 0;+ const task = mockModel({+ respond(request) {+ requests.push(request);+ return { text: "Done.", usage: { inputTokens: 8_000 } };+ },+ });+ const summary = mockModel({+ respond: () => {+ summaries++;+ return "Earlier work is summarized.";+ },+ });+ const runStep = createToolLoopHarness({+ mode: "conversation",+ tools: new Map(),+ resolveModel: async (reference) =>+ (reference.id === "summary" ? summary : task) as LanguageModel,+ });+ const first = await contextStorage.run(ctx, () =>+ runStep(session(), { message: "First task." }),+ );+ const second = await contextStorage.run(ctx, () =>+ runStep(first.session, { message: "Second task." }),+ );+ expect(summaries).toBe(0);+ expect(second.session.compaction.lastKnownInputTokens).toBe(8_000);+ expect(getRequestEnvelopeTokens(second.session)).toBe(getRequestEnvelopeTokens(first.session));++ const policy = setInstructions(ctx, 1_400);+ const third = await contextStorage.run(ctx, () =>+ runStep(second.session, { message: "Third task." }),+ );+ expect(summaries).toBe(1);+ expect(requests).toHaveLength(3);+ expect(requests[2]!.messages.some((message) => message.text.includes(policy))).toBe(true);+ expect(+ requests[2]!.messages.some((message) => message.text.includes("Earlier work is summarized.")),+ ).toBe(true);+ expect(third.session.history.some((message) => JSON.stringify(message).includes(policy))).toBe(+ false,+ );+ });++ it("does not let a persisted announcement mask later instruction growth", async () => {+ const ctx = new ContextContainer();+ ctx.set(PendingSkillAnnouncementKey, "Available skill description ".repeat(600));+ let summaries = 0;+ const task = mockModel({+ respond: () => ({ text: "Done.", usage: { inputTokens: 8_000 } }),+ });+ const summary = mockModel({+ respond: () => {+ summaries++;+ return "Earlier work is summarized.";+ },+ });+ const runStep = createToolLoopHarness({+ mode: "conversation",+ tools: new Map(),+ resolveModel: async (reference) =>+ (reference.id === "summary" ? summary : task) as LanguageModel,+ });+ const first = await contextStorage.run(ctx, () =>+ runStep(session(), { message: "First task." }),+ );+ expect(summaries).toBe(0);+ expect(JSON.stringify(first.session.history)).toContain("Available skill description");+ setInstructions(ctx, 600);+ await contextStorage.run(ctx, () => runStep(first.session, { message: "Second task." }));+ expect(summaries).toBe(1);+ });++ it("rechecks instructions added before an empty-response retry", async () => {+ const ctx = new ContextContainer();+ const requests: MockModelRequest[] = [];+ let summaries = 0;+ const task = mockModel({+ respond(request) {+ requests.push(request);+ if (requests.length === 1) {+ setInstructions(ctx, 1_400);+ return "";+ }+ return "Recovered after compaction.";+ },+ });+ const summary = mockModel({+ respond: () => {+ summaries++;+ return "Checkpoint before retry.";+ },+ });+ const runStep = createToolLoopHarness({+ mode: "conversation",+ tools: new Map(),+ resolveModel: async (reference) =>+ (reference.id === "summary" ? summary : task) as LanguageModel,+ });+ const initial = session();+ const result = await contextStorage.run(ctx, () =>+ runStep(+ {+ ...initial,+ compaction: {+ ...initial.compaction,+ lastKnownInputTokens: 8_000,+ lastKnownPromptMessageCount: 1,+ },+ history: [{ role: "user", kind: "user", content: "Earlier task." }],+ },+ { message: "Continue." },+ ),+ );+ expect(summaries).toBe(1);+ expect(requests).toHaveLength(2);+ expect(+ requests[1]!.messages.some((message) => message.text.includes("Checkpoint before retry.")),+ ).toBe(true);+ expect(result.session.history.at(-1)).toMatchObject({+ role: "assistant",+ content: expect.any(Array),+ });+ });+});diff --git a/packages/eve/src/harness/tool-loop.test.ts b/packages/eve/src/harness/tool-loop.test.tsindex c832e9d6a..55d835ebf 100644--- a/packages/eve/src/harness/tool-loop.test.ts+++ b/packages/eve/src/harness/tool-loop.test.ts@@ -9912,9 +9912,9 @@ describe("createToolLoopHarness", () => {"session.started","turn.started","message.received",+ "step.started","compaction.requested","compaction.completed",- "step.started","message.completed","step.completed","turn.completed",@@ -9943,7 +9943,7 @@ describe("createToolLoopHarness", () => {});});- it("selects the model from the pre-compaction view and dispatches step consumers after rewrite", async () => {+ it("resolves model and step capabilities before compacting the final request", async () => {vi.mocked(shouldCompact).mockReturnValue(true);const compactedHistory: HarnessModelMessage[] = [{ content: "Summary of our conversation so far:", kind: "context.compaction", role: "user" },@@ -9999,7 +9999,7 @@ describe("createToolLoopHarness", () => {];expect(preCompactionModelViews).toEqual([preCompactionView]);expect(vi.mocked(compactMessages).mock.calls[0]?.[0]).toEqual(preCompactionView);- expect(stepViews).toEqual([compactedHistory]);+ expect(stepViews).toEqual([preCompactionView]);});it("clears static and dynamic user instructions without rerunning lifecycle events", async () => {@@ -10236,9 +10236,11 @@ describe("createToolLoopHarness", () => {expect(call?.[2]).toEqual(expect.objectContaining({recentWindowSize: 10,- threshold: 100_000,+ threshold: expect.any(Number),}),);+ expect(call?.[2].threshold).toBeLessThan(100_000);+ expect(call?.[2].threshold).toBeGreaterThan(99_000);expect(call?.[3]).toBeUndefined();});@@ -12995,6 +12997,8 @@ describe("createToolLoopHarness", () => {{ content: "Hi", kind: "user" as const, role: "user" },],session.compaction,+ expect.any(Number),+ undefined,);expect(vi.mocked(compactMessages).mock.calls[0]?.[0]).toEqual([{ content: "earlier", kind: "user" as const, role: "user" },diff --git a/packages/eve/src/harness/tool-loop.ts b/packages/eve/src/harness/tool-loop.tsindex 4de66dc19..c7dca1b94 100644--- a/packages/eve/src/harness/tool-loop.ts+++ b/packages/eve/src/harness/tool-loop.ts@@ -23,6 +23,11 @@ import { resolveProviderHeaders } from "#internal/gateway.js";import { createErrorId, createLogger, formatError, logError } from "#internal/logging.js";import { formatLanguageModelGatewayId } from "#internal/runtime-model.js";import { contextStorage } from "#context/container.js";+import {+ estimateRequestEnvelope,+ getRequestEnvelopeTokens,+ setRequestEnvelopeTokens,+} from "#harness/request-envelope.js";import {AuthKey,HistoryStateKey,@@ -81,6 +86,7 @@ import {shouldCompact,} from "#harness/compaction.js";import { createCurrentMessages } from "#harness/current-messages.js";+import { estimateTokens } from "#harness/token-estimate.js";import {accumulateTurnUsage,getTurnUsageState,@@ -624,6 +630,7 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {messages: [...session.history],model: resolvedModel.model,onCompaction: config.onCompaction,+ requestEnvelopeTokens: getRequestEnvelopeTokens(session),resolveModel: config.resolveModel,runtimeIdentity: config.runtimeIdentity,session,@@ -1196,42 +1203,7 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {const cachePath = detectPromptCachePath(model);const marker = cachePath.kind === "anthropic-direct" ? getAnthropicCacheMarker() : undefined;- // --- Compaction ---------------------------------------------------------- //- // Runs before `agent.stream()` so the compacted messages flow through- // `messages` (which the harness uses to rebuild session history).const attributionHeaders = buildGatewayAttributionHeaders(model, config.runtimeIdentity);-- const clientContextTailLength =- turnClientContext === undefined- ? undefined- : Math.max(0, messages.length - turnClientContext.insertionIndex);- const compaction = await maybeCompact({- abortSignal: config.abortSignal,- auth: ctx?.get(AuthKey) ?? null,- emit,- emissionState,- historyProjector: config.historyProjector,- messages: [...messages],- model,- onCompaction: config.onCompaction,- promptMessages: createModelMessages(messages),- resolveModel: config.resolveModel,- runtimeIdentity: config.runtimeIdentity,- session,- telemetry: stepInstrumentation?.telemetry(),- });- session = compaction.session;- if (compaction.compacted) {- messages = compaction.messages;- if (turnClientContext !== undefined && clientContextTailLength !== undefined) {- turnClientContext = {- ...turnClientContext,- insertionIndex: Math.max(0, messages.length - clientContextTailLength),- };- session = setTurnClientContextState(session, turnClientContext);- }- }projectedMessages = validateHarnessModelMessages(normalizeModelMessages(projectHistory(createModelMessages(messages), session.state)),);@@ -1272,34 +1244,37 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {* `console.error(error)` handler inside `streamText`. Errors are* handled by the harness catch block and emitted as stream events.*/- // Persist framework announcements before the new input, or after earlier- // tool results on a continuation, so later requests retain the full prefix.- const currentMessages = createCurrentMessages(messages, {- historyState: ctx?.get(HistoryStateKey),- currentTurnMessages: preparedTurnInput,- projectedMessages,- });- if (ctx !== undefined) {- currentMessages.addSystem(buildDynamicInstructionMessages(ctx));- }- const taskContext =- ctx?.get(TurnTaskDeliveryKey) === "initiating"- ? resolveInitiatingTaskContext({ state: session.state, turnId })- : undefined;- currentMessages.addAnnouncements({- availableSkills: ctx?.get(PendingSkillAnnouncementKey),- taskState: taskContext?.context,- deliveryInstruction: deliveryPolicy.instruction,- });- const pendingApprovals = renderPendingApprovalsInstruction(- getPendingInputBatches(session.state).flatMap((batch) => batch.requests),- );- if (pendingApprovals !== undefined) {- currentMessages.add(pendingApprovals, "context.state", {- cacheFriendly: false,+ const createRequestMessages = () => {+ // Persist framework announcements before the new input, or after earlier+ // tool results on a continuation, so later requests retain the full prefix.+ const currentMessages = createCurrentMessages(messages, {+ historyState: ctx?.get(HistoryStateKey),+ currentTurnMessages: preparedTurnInput,+ projectedMessages,});- }- const promptMessages = currentMessages.history;+ if (ctx !== undefined) {+ currentMessages.addSystem(buildDynamicInstructionMessages(ctx));+ }+ const taskContext =+ ctx?.get(TurnTaskDeliveryKey) === "initiating"+ ? resolveInitiatingTaskContext({ state: session.state, turnId })+ : undefined;+ currentMessages.addAnnouncements({+ availableSkills: ctx?.get(PendingSkillAnnouncementKey),+ taskState: taskContext?.context,+ deliveryInstruction: deliveryPolicy.instruction,+ });+ const pendingApprovals = renderPendingApprovalsInstruction(+ getPendingInputBatches(session.state).flatMap((batch) => batch.requests),+ );+ if (pendingApprovals !== undefined) {+ currentMessages.add(pendingApprovals, "context.state", {+ cacheFriendly: false,+ });+ }+ return currentMessages;+ };+ let currentMessages = createRequestMessages();let interruptedUsage: TokenUsageDelta | undefined;const finishSteeredStep = (): StepResult => {throwIfTurnAborted(config.abortSignal);@@ -1318,7 +1293,7 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {steered: true,next: runStep,session: setHarnessEmissionState(- { ...session, history: [...promptMessages] },+ { ...session, history: [...currentMessages.history] },advanceStep(emissionState),),};@@ -1326,9 +1301,15 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {// Hydrate `eve-sandbox:` ref FileParts into inline bytes for the model call// only. Session history remains ref-only across future step boundaries.- const modelMessages = await hydrateSandboxAttachments(currentMessages.nonSystemMessages);+ let modelMessages: ModelMessage[] = [];- const prepareModelCallInput = (extraSystemNote?: string) => {+ const withTrailingUserNote = (+ messages: readonly ModelMessage[],+ note?: string,+ ): ModelMessage[] =>+ note ? [...messages, createFrameworkUserMessage("execution.retry", note)] : [...messages];++ const prepareModelInstructions = (extraSystemNote?: string) => {const extraSystemEntry: SystemModelMessage[] = extraSystemNote? [{ role: "system" as const, content: extraSystemNote }]: [];@@ -1348,6 +1329,11 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {? mergeSystemInstructions(markedInstructions): (session.agent.system ?? undefined);+ return instructions;+ };++ const prepareModelCallInput = (extraSystemNote?: string) => {+ const instructions = prepareModelInstructions(extraSystemNote);return {instructions,telemetryRuntimeContext: stepInstrumentation?.resolveRuntimeContext({@@ -1376,31 +1362,18 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {type ModelCallOptions = {disabledProviderTools?: ReadonlySet<string>;extraSystemNote?: string;- preparedInput?: ReturnType<typeof prepareModelCallInput>;retryReason?: "empty-response";suppressStepStartedEmission?: boolean;trailingUserNote?: string;};let modelCallCoordinationTools = config.tools;+ let requestEnvelopeTokens = 0;+ let compactionFailure: { readonly error: unknown } | undefined;+ const throwIfCompactionFailed = () => {+ if (compactionFailure !== undefined) throw compactionFailure.error;+ };- const runSingleModelCall = async (- opts: ModelCallOptions & { readonly attemptIndex: number },- ): Promise<HarnessStepResult> => {- generation.begin();- const { instructions, telemetryRuntimeContext = {} } =- opts.preparedInput ?? prepareModelCallInput(opts.extraSystemNote);- // Label the reissued call's telemetry; without this a retry is only- // visible as a second LLM span under one step.- if (opts.retryReason) {- telemetryRuntimeContext["eve.retry.reason"] = opts.retryReason;- }- // Trailing rather than an extraSystemNote prepend: keeps the provider's- // cached prompt prefix valid, and handleStepResult rebuilds history- // from the step's prompt messages, so the note exists only on this- // call's wire request.- const callMessages = opts.trailingUserNote- ? [...modelMessages, createFrameworkUserMessage("execution.retry", opts.trailingUserNote)]- : [...modelMessages];+ const prepareModelTools = async (opts: ModelCallOptions) => {const harnessTools = buildHarnessToolsWithDynamicSubagents(config.tools, ctx);const backgroundBatch = createBackgroundToolCallBatch();const advertisedHarnessTools = getAdvertisedTools({@@ -1470,6 +1443,102 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {};}+ return { effectiveTools, backgroundBatch, advertisedHarnessTools };+ };++ const runSingleModelCall = async (+ opts: ModelCallOptions & { readonly attemptIndex: number },+ ): Promise<HarnessStepResult> => {+ let { effectiveTools, backgroundBatch, advertisedHarnessTools } =+ await prepareModelTools(opts);+ currentMessages = createRequestMessages();+ requestEnvelopeTokens = await estimateRequestEnvelope({+ history: projectedMessages,+ instructions: prepareModelInstructions(opts.extraSystemNote),+ messages: withTrailingUserNote(currentMessages.nonSystemMessages, opts.trailingUserNote),+ tools: effectiveTools,+ });+ const clientContextTailLength =+ turnClientContext === undefined+ ? undefined+ : Math.max(0, messages.length - turnClientContext.insertionIndex);+ const compaction = await (async () => {+ try {+ return await maybeCompact({+ abortSignal: config.abortSignal,+ auth: ctx?.get(AuthKey) ?? null,+ emit,+ emissionState,+ historyProjector: config.historyProjector,+ messages: [...messages],+ model,+ onCompaction: config.onCompaction,+ promptMessages: createModelMessages(messages),+ requestEnvelopeTokens,+ resolveModel: config.resolveModel,+ runtimeIdentity: config.runtimeIdentity,+ session,+ telemetry: stepInstrumentation?.telemetry(),+ });+ } catch (error) {+ compactionFailure = { error };+ throw error;+ }+ })();+ session = compaction.session;+ if (compaction.compacted) {+ messages = compaction.messages;+ if (turnClientContext !== undefined && clientContextTailLength !== undefined) {+ turnClientContext = {+ ...turnClientContext,+ insertionIndex: Math.max(0, messages.length - clientContextTailLength),+ };+ session = setTurnClientContextState(session, turnClientContext);+ }+ session = {+ ...session,+ compaction: {+ recentWindowSize: session.compaction.recentWindowSize,+ threshold: session.compaction.threshold,+ thresholdPercent: session.compaction.thresholdPercent,+ },+ };+ projectedMessages = validateHarnessModelMessages(+ normalizeModelMessages(projectHistory(createModelMessages(messages), session.state)),+ );+ currentMessages = createRequestMessages();+ ({ effectiveTools, backgroundBatch, advertisedHarnessTools } =+ await prepareModelTools(opts));+ requestEnvelopeTokens = await estimateRequestEnvelope({+ history: projectedMessages,+ instructions: prepareModelInstructions(opts.extraSystemNote),+ messages: withTrailingUserNote(currentMessages.nonSystemMessages, opts.trailingUserNote),+ tools: effectiveTools,+ });+ }+ // New announcements join durable history, so they must not inflate the+ // envelope baseline and hide instruction growth on the next step.+ requestEnvelopeTokens = Math.max(+ 0,+ requestEnvelopeTokens -+ (estimateTokens(currentMessages.history) - estimateTokens(messages)),+ );+ generation.begin();+ modelMessages = await hydrateSandboxAttachments(currentMessages.nonSystemMessages);+ const { instructions, telemetryRuntimeContext = {} } = prepareModelCallInput(+ opts.extraSystemNote,+ );+ // Label the reissued call's telemetry; without this a retry is only+ // visible as a second LLM span under one step.+ if (opts.retryReason) {+ telemetryRuntimeContext["eve.retry.reason"] = opts.retryReason;+ }+ // Trailing rather than an extraSystemNote prepend: keeps the provider's+ // cached prompt prefix valid, and handleStepResult rebuilds history+ // from the step's prompt messages, so the note exists only on this+ // call's wire request.+ const callMessages = withTrailingUserNote(modelMessages, opts.trailingUserNote);+const instrumentationTurnId = activeTurnId(emissionState);const attempt = stepInstrumentation?.prepareAttempt({attemptIndex: opts.attemptIndex,@@ -1535,7 +1604,7 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {runtimeContext: telemetryRuntimeContext,stopWhen: isStepCount(1),telemetry: attempt?.telemetry,- toolApproval: buildToolApproval(modelTools),+ toolApproval: buildToolApproval(effectiveTools),tools: effectiveTools,};const agent = new ToolLoopAgent(agentSettings);@@ -1658,20 +1727,16 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {runSingleModelCall({...opts,attemptIndex: nextModelAttemptIndex++,- preparedInput: attempt === 1 ? opts.preparedInput : undefined,suppressStepStartedEmission: attempt === 1 ? opts.suppressStepStartedEmission : true,}),{sessionId: session.sessionId,turnId: emissionState.turnId,+ canRetry: () => compactionFailure === undefined,},generation.signal,);- // Resolve first-attempt instrumentation after step.started dynamic- // capabilities have updated the effective prompt and toolset.- const initialModelCallInput = prepareModelCallInput();-const limitResult = await enforceSessionUsageLimit({config,emit,@@ -1686,10 +1751,10 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {let result: HarnessStepResult;try {result = await runOneModelCall({- preparedInput: initialModelCallInput,suppressStepStartedEmission: true,});} catch (error) {+ throwIfCompactionFailed();throwIfTurnAborted(config.abortSignal);if (generation.interrupted) {@@ -1720,6 +1785,7 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {}),],});+ throwIfCompactionFailed();throwIfTurnAborted(config.abortSignal);if (generation.interrupted) return finishSteeredStep();@@ -1947,11 +2013,12 @@ export function createToolLoopHarness(config: ToolLoopHarnessConfig): StepFn {emissionState: generation.outputStarted? { ...emissionState, assistantOutputStarted: true }: emissionState,+ requestEnvelopeTokens,durableModelPromptMessageCount:turnClientContext === undefined || turnClientContext.messages.length === 0? modelMessages.length: undefined,- promptMessages,+ promptMessages: currentMessages.history,result,runStep,session,@@ -2489,6 +2556,7 @@ async function handleStepResult(input: {readonly emit?: ToolLoopHarnessConfig["handleEvent"];readonly emissionState: ReturnType<typeof getHarnessEmissionState>;readonly durableModelPromptMessageCount?: number;+ readonly requestEnvelopeTokens?: number;readonly promptMessages: readonly HarnessModelMessage[];readonly result: HarnessStepResult;readonly runStep: StepFn;@@ -2539,14 +2607,19 @@ async function handleStepResult(input: {});const responseMessages = normalizedProviderHistory.messages;- const baseSession: HarnessSession = {- ...session,- compaction: createNextCompactionConfig(- session.compaction,- input.durableModelPromptMessageCount,- result,- ),- };+ const baseSession = setRequestEnvelopeTokens(+ {+ ...session,+ compaction: createNextCompactionConfig(+ session.compaction,+ input.durableModelPromptMessageCount,+ result,+ ),+ },+ result.usage?.inputTokens !== undefined && input.durableModelPromptMessageCount !== undefined+ ? input.requestEnvelopeTokens+ : undefined,+ );const approvalRequests = extractToolApprovalInputRequests({content: result.content ?? [],@@ -3115,6 +3188,7 @@ async function maybeCompact(input: {readonly onCompaction?: ToolLoopHarnessConfig["onCompaction"];/** Model-visible prompt used only to decide whether durable history needs compaction. */readonly promptMessages?: readonly HarnessModelMessage[];+ readonly requestEnvelopeTokens?: number;readonly resolveModel: ToolLoopHarnessConfig["resolveModel"];readonly runtimeIdentity?: ToolLoopHarnessConfig["runtimeIdentity"];readonly session: HarnessSession;@@ -3132,7 +3206,13 @@ async function maybeCompact(input: {input.historyProjector?.({ messages: promptMessages, state: session.state }) ?? promptMessages,);const needsSummary =- input.force === true || shouldCompact(projectedPromptMessages, session.compaction);+ input.force === true ||+ shouldCompact(+ projectedPromptMessages,+ session.compaction,+ input.requestEnvelopeTokens,+ getRequestEnvelopeTokens(session),+ );const needsMemoryCanonicalization = shouldCanonicalizeMemory(messages);if (!needsSummary && !needsMemoryCanonicalization) {@@ -3164,7 +3244,12 @@ async function maybeCompact(input: {sequence: emissionState.sequence,sessionId: session.sessionId,turnId: emissionState.turnId,- usageInputTokens: getInputTokenCount(projectedPromptMessages, session.compaction),+ usageInputTokens: getInputTokenCount(+ projectedPromptMessages,+ session.compaction,+ input.requestEnvelopeTokens,+ getRequestEnvelopeTokens(session),+ ),}),projectedPromptMessages,);@@ -3175,16 +3260,40 @@ async function maybeCompact(input: {input.historyProjector?.({ messages: canonical.ordinary, state: session.state }) ??canonical.ordinary,);+ const requestEnvelopeTokens = input.requestEnvelopeTokens ?? 0;+ const historyCompaction: CompactionConfig = {+ ...session.compaction,+ threshold: Math.max(1, session.compaction.threshold - requestEnvelopeTokens),+ lastKnownInputTokens:+ session.compaction.lastKnownInputTokens === undefined+ ? undefined+ : Math.max(+ 0,+ session.compaction.lastKnownInputTokens -+ Math.min(getRequestEnvelopeTokens(session) ?? 0, requestEnvelopeTokens),+ ),+ };const compactedOrdinary = needsSummary? await compactMessages([...ordinary],compaction.model,- session.compaction,+ historyCompaction,providerOptions,input.telemetry,buildGatewayAttributionHeaders(compaction.model, input.runtimeIdentity),input.abortSignal,input.force === true,+ input.requestEnvelopeTokens === undefined+ ? undefined+ : Math.max(+ 0,+ getInputTokenCount(+ projectedPromptMessages,+ session.compaction,+ requestEnvelopeTokens,+ getRequestEnvelopeTokens(session),+ ) - requestEnvelopeTokens,+ ),): [...ordinary];messages = validateHarnessModelMessages([...canonical.memory, ...compactedOrdinary]);@@ -3246,7 +3355,11 @@ function resolveApprovalKeyFromTools(*/async function runModelCallWithRetries<T>(fn: (attempt: number) => Promise<T>,- diag: { readonly sessionId: string; readonly turnId: string },+ diag: {+ readonly sessionId: string;+ readonly turnId: string;+ readonly canRetry?: () => boolean;+ },signal: AbortSignal,): Promise<T> {for (let attempt = 1; ; attempt++) {@@ -3255,7 +3368,11 @@ async function runModelCallWithRetries<T>(return await fn(attempt);} catch (error) {signal.throwIfAborted();- if (attempt === MODEL_CALL_MAX_ATTEMPTS || classifyModelCallError(error) !== "retry") {+ if (+ diag.canRetry?.() === false ||+ attempt === MODEL_CALL_MAX_ATTEMPTS ||+ classifyModelCallError(error) !== "retry"+ ) {throw error;}const delayMs =diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex aecb4c6fb..af2ab57db 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -697,6 +697,25 @@ importers:specifier: 'catalog:'version: 7.0.2+ e2e/fixtures/agent-compaction-envelope:+ dependencies:+ '@eve-e2e/config':+ specifier: workspace:*+ version: link:../e2e-config+ '@workflow/world-postgres':+ specifier: 'catalog:'+ version: 5.0.0-beta.42(@opentelemetry/[email protected])(@types/[email protected])(@upstash/[email protected])([email protected])([email protected])([email protected])+ eve:+ specifier: workspace:*+ version: link:../../../packages/eve+ devDependencies:+ '@types/node':+ specifier: 'catalog:'+ version: 24.13.3+ typescript:+ specifier: 'catalog:'+ version: 7.0.2+e2e/fixtures/agent-compaction-measured:dependencies:'@eve-e2e/config':