The Open Framework for Building Agents
fix(eve): remove self-modification registry_add approval (#4056)
prha7e4ceb80221f
diff --git a/.changeset/selfmod-registry-mount-guard.md b/.changeset/selfmod-registry-mount-guard.mdnew file mode 100644index 000000000..7ccae05d3--- /dev/null+++ b/.changeset/selfmod-registry-mount-guard.md@@ -0,0 +1,5 @@+---+"eve": patch+---++The self-modification `registry_add` tool no longer pauses for approval before installing an official registry item. It now refuses items that would replace the self-modification subagent's own mount, and `search_registry` hides them.diff --git a/e2e/fixtures/agent-self-modification/evals/self-modification/harness.ts b/e2e/fixtures/agent-self-modification/evals/self-modification/harness.tsindex 1a716b50f..5a3d037f9 100644--- a/e2e/fixtures/agent-self-modification/evals/self-modification/harness.ts+++ b/e2e/fixtures/agent-self-modification/evals/self-modification/harness.ts@@ -192,32 +192,6 @@ export class SelfModificationHarness {return { child, parent, session: liveParent.session };}- /** Approves the registry install the parent turn paused on and observes the resumed child turn. */- async approveRegistry(run: SelfModificationRun): Promise<EveEvalTurn> {- const toolName = "registry_add";- const session = run.session;- session.requireInputRequest({ toolName });- const childSessionId = run.child.sessionId;- const previousChild = [...this.#turns]- .reverse()- .find((turn) => turn.sessionId === childSessionId);- if (previousChild === undefined) throw new Error("Missing registry child session cursor.");- const child = this.#t.target.watchTurn(childSessionId, {- startIndex: previousChild.session.state.streamIndex,- });- this.#turns.add(child);- const responses = session.pendingInputRequests.map((request) => ({- optionId: "approve",- requestId: request.requestId,- }));- const parent = await session.startRespond(responses);- this.#turns.add(parent);- const [childTurn, parentTurn] = await Promise.all([child.result(), parent.result()]);- childTurn.expectOk();- parentTurn.expectOk();- return childTurn;- }-followUp(session: EveEvalSession, prompt: string): Promise<EveEvalTurn> {return this.#runTurn(session, prompt);}diff --git a/e2e/fixtures/agent-self-modification/evals/self-modification/registry-install.ts b/e2e/fixtures/agent-self-modification/evals/self-modification/registry-install.tsindex 921cc0648..2603b8d9f 100644--- a/e2e/fixtures/agent-self-modification/evals/self-modification/registry-install.ts+++ b/e2e/fixtures/agent-self-modification/evals/self-modification/registry-install.ts@@ -10,12 +10,7 @@ export async function verifyRegistryHandoff(input: {}): Promise<void> {const { address, run, selfMod } = input;assertDiscovered(run, address);- const pending = run.child.toolCalls.filter((call) => call.name === "registry_add");- if (pending.length !== 1 || pending[0]?.input.address !== address) {- throw new Error(`Self-modification did not request ${address} exactly once.`);- }- const handoff = await selfMod.approveRegistry(run);- const result = handoff.toolCalls.find((call) => call.name === "registry_add");+ const result = requireSingleRegistryAdd(run, address);if (result?.status !== "completed" ||(result.output as { nextCommand?: unknown; status?: unknown } | undefined)?.status !==@@ -36,12 +31,7 @@ export async function verifyRegistryInstall(input: {}): Promise<void> {const { address, source, target, run, selfMod } = input;assertDiscovered(run, address);- const pending = run.child.toolCalls.filter((call) => call.name === "registry_add");- if (pending.length !== 1 || pending[0]?.input.address !== address) {- throw new Error(`Self-modification did not request ${address} exactly once.`);- }- const installed = await selfMod.approveRegistry(run);- const result = installed.toolCalls.find((call) => call.name === "registry_add");+ const result = requireSingleRegistryAdd(run, address);if (result?.status !== "completed" ||(result.output as { status?: unknown } | undefined)?.status !== "installed"@@ -54,6 +44,15 @@ export async function verifyRegistryInstall(input: {if (actual !== expected) throw new Error(`${target} is not the official registry scaffold.`);}+function requireSingleRegistryAdd(run: SelfModificationRun, address: string) {+ const calls = run.child.toolCalls.filter((call) => call.name === "registry_add");+ const [call] = calls;+ if (calls.length !== 1 || call?.input.address !== address) {+ throw new Error(`Self-modification did not request ${address} exactly once.`);+ }+ return call;+}+function assertDiscovered(run: SelfModificationRun, address: string): void {run.child.calledTool("search_registry");const discovered = run.child.toolCalls.some((call) => {diff --git a/packages/eve/src/self-modification/extension/classify-registry-item.ts b/packages/eve/src/self-modification/extension/classify-registry-item.tsindex e11dda9b5..dd81f1915 100644--- a/packages/eve/src/self-modification/extension/classify-registry-item.ts+++ b/packages/eve/src/self-modification/extension/classify-registry-item.ts@@ -14,7 +14,17 @@ import type { CatalogEntry } from "./subagents/agent/tools/search_registry.js";*/export function classifyCatalogEntry(entry: CatalogEntry,-): { readonly kind: "installable" } | { readonly kind: "needs-terminal"; readonly reason: string } {+):+ | { readonly kind: "installable" }+ | { readonly kind: "needs-terminal"; readonly reason: string }+ | { readonly kind: "self-modification-mount"; readonly reason: string } {+ if (entry.selfModificationMount === true) {+ return {+ kind: "self-modification-mount",+ reason:+ "Installing a registry item cannot replace the self-modification subagent's own mount. Edit its authored mount directly instead.",+ };+ }if (entry.declaresSetup === true) {return {kind: "needs-terminal",diff --git a/packages/eve/src/self-modification/extension/subagents/agent/tools/registry_add.ts b/packages/eve/src/self-modification/extension/subagents/agent/tools/registry_add.tsindex 27a018ce9..d30431d72 100644--- a/packages/eve/src/self-modification/extension/subagents/agent/tools/registry_add.ts+++ b/packages/eve/src/self-modification/extension/subagents/agent/tools/registry_add.ts@@ -1,6 +1,5 @@import { getLocalDevCapability, type LocalDevCapability } from "eve/local-dev";import { defineDynamic, defineTool, type ToolContext } from "eve/tools";-import { once } from "eve/tools/approval";import {resolveSelfModificationConfig,@@ -247,6 +246,9 @@ export async function addLocalRegistryItem(}const classification = classifyCatalogEntry(entry);+ if (classification.kind === "self-modification-mount") {+ throw new Error(classification.reason);+ }if (classification.kind === "needs-terminal") {const handoff = handoffMessage({address,@@ -341,6 +343,10 @@ async function addProductionRegistryItem(if (entry === undefined) {throw new Error(`No official eve registry item is published at "${address}".`);}+ const classification = classifyCatalogEntry(entry);+ if (classification.kind === "self-modification-mount") {+ throw new Error(classification.reason);+ }const sandbox = await context.getSandbox();const result = await withSelfModificationWorkspaceLock(`sandbox:${context.session.id}`,@@ -365,7 +371,6 @@ async function addProductionRegistryItem(function localRegistryAddTool() {return defineTool({- approval: once(),description:"Install an item from the configured eve registry into this project. Items that need setup are handed to the local setup flow instead. Search first, then call this with the exact item address.",inputSchema: localInputSchema,@@ -382,7 +387,6 @@ function localRegistryAddTool() {function productionRegistryAddTool(deployed: ResolvedDeployedSelfModificationConfig) {return defineTool({- approval: once(),description:"Install an exact item from the official eve registry into the current production change proposal. If setup pauses, call this tool again with the non-secret answers and the installed state from its result. External authorization and secret binding must be completed by the developer.",inputSchema: productionInputSchema,diff --git a/packages/eve/src/self-modification/extension/subagents/agent/tools/search_registry.ts b/packages/eve/src/self-modification/extension/subagents/agent/tools/search_registry.tsindex 37a9b1493..3a36de7d1 100644--- a/packages/eve/src/self-modification/extension/subagents/agent/tools/search_registry.ts+++ b/packages/eve/src/self-modification/extension/subagents/agent/tools/search_registry.ts@@ -19,6 +19,7 @@ const CACHE_TTL_MS = 5 * 60_000;/** The sandbox mounts the authored `agent/` directory here in development. */const AUTHORED_SOURCE_MOUNT = "/source";const AUTHORED_PREFIX = "agent/";+const SELF_MODIFICATION_MOUNT = "agent/extensions/self-modification";const inputSchema = {type: "object",@@ -99,6 +100,8 @@ export interface CatalogEntry {readonly authoredTarget?: string;/** Whether `meta.eve.setup` declares one or more setup commands. */readonly declaresSetup?: boolean;+ /** Whether any file would replace the self-modification extension mount. */+ readonly selfModificationMount?: boolean;/** Names of environment variables the item declares. */readonly envVars?: readonly string[];}@@ -166,6 +169,12 @@ function eveMetadata(entry: Record<string, unknown>): Record<string, unknown> {return isRecord(eve) ? eve : {};}+function targetsSelfModificationMount(target: string): boolean {+ return (+ target === `${SELF_MODIFICATION_MOUNT}.ts` || target.startsWith(`${SELF_MODIFICATION_MOUNT}/`)+ );+}+/** First authored file the item installs; identifies an existing install. */function authoredTargetOf(entry: Record<string, unknown>): string | undefined {const files = entry.files;@@ -178,6 +187,16 @@ function authoredTargetOf(entry: Record<string, unknown>): string | undefined {return undefined;}+function targetsSelfModificationMountOf(entry: Record<string, unknown>): boolean {+ const files = entry.files;+ return (+ Array.isArray(files) &&+ files.some(+ (file) => isRecord(file) && targetsSelfModificationMount(optionalString(file.target) ?? ""),+ )+ );+}+/** Names of environment variables the item declares, used to report unset ones after install. */function declaredEnvVars(entry: Record<string, unknown>): readonly string[] {const envVars = entry.envVars;@@ -200,6 +219,7 @@ export function parseRegistryIndex(value: unknown): readonly CatalogEntry[] {if (address === undefined) continue;const eve = eveMetadata(item);if (eve.hidden === true) continue;+ const authoredTarget = authoredTargetOf(item);const entry: {address: string;@@ -209,6 +229,7 @@ export function parseRegistryIndex(value: unknown): readonly CatalogEntry[] {description?: string;envVars?: readonly string[];requires?: string;+ selfModificationMount?: boolean;title: string;} = { address, title: optionalString(item.title) ?? titleFromAddress(address) };@@ -218,9 +239,9 @@ export function parseRegistryIndex(value: unknown): readonly CatalogEntry[] {if (description !== undefined) entry.description = description;const requires = optionalString(eve.requires);if (requires !== undefined) entry.requires = requires;- const authoredTarget = authoredTargetOf(item);if (authoredTarget !== undefined) entry.authoredTarget = authoredTarget;if (eve.setup !== undefined && eve.setup !== null) entry.declaresSetup = true;+ if (targetsSelfModificationMountOf(item)) entry.selfModificationMount = true;const envVars = declaredEnvVars(item);if (envVars.length > 0) entry.envVars = envVars;@@ -485,7 +506,7 @@ export default defineTool({limit?: number;offset?: number;query?: string;- } = { entries };+ } = { entries: entries.filter((entry) => entry.selfModificationMount !== true) };const category = typeof input.category === "string" ? input.category : undefined;if (category !== undefined && isCategory(category)) selection.category = category;if (typeof input.limit === "number") selection.limit = input.limit;diff --git a/packages/eve/src/self-modification/registry-add.test.ts b/packages/eve/src/self-modification/registry-add.test.tsindex ca4ab6b94..4d9763b1a 100644--- a/packages/eve/src/self-modification/registry-add.test.ts+++ b/packages/eve/src/self-modification/registry-add.test.ts@@ -36,6 +36,11 @@ const INDEX = {envVars: { BROWSERBASE_API_KEY: "", BROWSERBASE_PROJECT_ID: "" },files: [{ target: "agent/extensions/browserbase.ts" }],},+ {+ name: "eve/self-modification",+ title: "Self-modification",+ files: [{ target: "agent/extensions/self-modification/extension.ts" }],+ },{name: "channel/slack",title: "Slack",@@ -259,6 +264,12 @@ describe("addLocalRegistryItem", () => {).rejects.toThrow(/No item in the configured eve registry is published/u);});+ it("directs self-modification mount changes to the authored mount", async () => {+ await expect(+ addLocalRegistryItem("eve/self-modification", { getCapability: () => capability() }),+ ).rejects.toThrow(/cannot replace the self-modification subagent's own mount/u);+ });+it("installs a no-setup item with a fixed argv and reports unset envVars", async () => {const { calls, spawn } = fakeSpawn({code: 0,diff --git a/packages/eve/src/self-modification/search-registry.test.ts b/packages/eve/src/self-modification/search-registry.test.tsindex 4a44ed4ad..ae90ea1c8 100644--- a/packages/eve/src/self-modification/search-registry.test.ts+++ b/packages/eve/src/self-modification/search-registry.test.ts@@ -128,11 +128,42 @@ describe("parseRegistryIndex", () => {expect(parseRegistryIndex({items: [- { name: "eve/self-modification" },- { name: "experimental/self-modification", meta: { eve: { hidden: true } } },+ { name: "eve/toolkit" },+ { name: "experimental/toolkit", meta: { eve: { hidden: true } } },],}).map((entry) => entry.address),- ).toEqual(["eve/self-modification"]);+ ).toEqual(["eve/toolkit"]);+ });++ it("marks items that would scaffold the self-modification mount", () => {+ expect(+ parseRegistryIndex({+ items: [+ {+ name: "eve/self-modification",+ files: [+ { target: "agent/tools/unrelated.ts" },+ { target: "agent/extensions/self-modification/extension.ts" },+ ],+ },+ {+ name: "acme/self-modification",+ files: [{ target: "agent/extensions/self-modification.ts" }],+ },+ {+ name: "extension/self-modification-tools",+ files: [{ target: "agent/extensions/self-modification-tools/extension.ts" }],+ },+ ],+ }).map((entry) => ({+ address: entry.address,+ selfModificationMount: entry.selfModificationMount,+ })),+ ).toEqual([+ { address: "eve/self-modification", selfModificationMount: true },+ { address: "acme/self-modification", selfModificationMount: true },+ { address: "extension/self-modification-tools", selfModificationMount: undefined },+ ]);});it("reads whether an item declares a setup flow, used by selfmod__registry_add's split rule", () => {@@ -316,6 +347,28 @@ describe("selfmod__search_registry", () => {} as never;}+ it("does not return self-modification mount scaffolds in search results", async () => {+ stubFetch({+ body: {+ items: [+ {+ name: "eve/self-modification",+ files: [{ target: "agent/extensions/self-modification/extension.ts" }],+ },+ { name: "extension/browserbase" },+ ],+ },+ ok: true,+ });++ const result = await run({}, ctx());++ expect(result).toMatchObject({+ items: [{ address: "extension/browserbase" }],+ total: 1,+ });+ });+it("returns catalog rows with installed state from the source mount", async () => {stubFetch({ body: INDEX, ok: true });