The Open Framework for Building Agents
fix(eve): align workspace workflow IDs (#3629)
e0-gh-vercel-connect[bot]3e2bf95f6e65
diff --git a/.changeset/fix-workspace-workflow-ids.md b/.changeset/fix-workspace-workflow-ids.mdnew file mode 100644index 000000000..5d56627ea--- /dev/null+++ b/.changeset/fix-workspace-workflow-ids.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Fix background workflow tools in workspace agents to use app-relative workflow IDs so dispatch matches the registered workflow.diff --git a/packages/eve/src/internal/application/compiled-artifacts.ts b/packages/eve/src/internal/application/compiled-artifacts.tsindex 75019dbca..4621ea7ee 100644--- a/packages/eve/src/internal/application/compiled-artifacts.ts+++ b/packages/eve/src/internal/application/compiled-artifacts.ts@@ -81,6 +81,7 @@ export async function writeCompiledArtifactsFiles(input: {JSON.parse(await readFile(input.compileResult.paths.sandboxPreparedArtifactsPath, "utf8")),);const prepared = await prepareAuthoredRuntimeModules({+ appRoot: input.compileResult.project.appRoot,manifest: input.compileResult.manifest,moduleMapPath: input.compileResult.paths.moduleMapPath,});diff --git a/packages/eve/src/internal/authored-module-loader.scenario.test.ts b/packages/eve/src/internal/authored-module-loader.scenario.test.tsindex 7dd39b868..b045db820 100644--- a/packages/eve/src/internal/authored-module-loader.scenario.test.ts+++ b/packages/eve/src/internal/authored-module-loader.scenario.test.ts@@ -252,6 +252,7 @@ export default defineWorkflowTool({ description: "Probe", inputSchema: { type: "const manifest = await compileAgentManifest(discovered.manifest);const { code } = await bundleAuthoredModuleMapForGeneration({+ appRoot: app.appRoot,manifest,moduleMapPath: join(app.appRoot, ".eve", "compile", "module-map.mjs"),});diff --git a/packages/eve/src/internal/authored-module-loader.ts b/packages/eve/src/internal/authored-module-loader.tsindex 0820e6b0d..21c08bdc4 100644--- a/packages/eve/src/internal/authored-module-loader.ts+++ b/packages/eve/src/internal/authored-module-loader.ts@@ -277,9 +277,12 @@ export interface AuthoredModuleMapBundle {}export async function bundleAuthoredModuleMapForGeneration(input: {+ readonly appRoot: string;readonly manifest: CompiledAgentManifest;readonly moduleMapPath: string;}): Promise<AuthoredModuleMapBundle> {+ // The package root owns dependency resolution, while the selected app root+ // owns authored workflow IDs and must match the workflow driver.const packageRoot = resolveAuthoredPackageRoot(input.manifest.agentRoot);const programmaticLoaderImportSpecifier = resolvePackageSourceFilePath("src/internal/programmatic-source-loader.ts",@@ -306,7 +309,7 @@ export async function bundleAuthoredModuleMapForGeneration(input: {})),),);- const workflowSources = new AuthoredWorkflowSourceRecorder(packageRoot);+ const workflowSources = new AuthoredWorkflowSourceRecorder(input.appRoot);const plugins = [createVirtualGenerationModuleMapPlugin({id: input.moduleMapPath,@@ -314,7 +317,7 @@ export async function bundleAuthoredModuleMapForGeneration(input: {}),createExternalRuntimeImportPlugin(programmaticLoaderImportSpecifier),// Before callback stamping, which must see the stub and never the directive.- createAuthoredWorkflowDirectivePlugin({ appRoot: packageRoot, recorder: workflowSources }),+ createAuthoredWorkflowDirectivePlugin({ appRoot: input.appRoot, recorder: workflowSources }),createDynamicCapabilityTransformPlugin({workflowFunctions: (id) => workflowSources.workflowFunctions(id),}),diff --git a/packages/eve/src/internal/authored-runtime-modules.ts b/packages/eve/src/internal/authored-runtime-modules.tsindex 2eee0f2ea..37ea9a447 100644--- a/packages/eve/src/internal/authored-runtime-modules.ts+++ b/packages/eve/src/internal/authored-runtime-modules.ts@@ -22,6 +22,7 @@ export interface PreparedAuthoredRuntimeModules {/** Builds the authored runtime graph before a development or production host packages it. */export async function prepareAuthoredRuntimeModules(input: {+ readonly appRoot: string;readonly manifest: CompiledAgentManifest;readonly moduleMapPath: string;}): Promise<PreparedAuthoredRuntimeModules> {diff --git a/packages/eve/src/internal/nitro/dev-generation-artifacts.scenario.test.ts b/packages/eve/src/internal/nitro/dev-generation-artifacts.scenario.test.tsindex 89d7511c3..32373b9f4 100644--- a/packages/eve/src/internal/nitro/dev-generation-artifacts.scenario.test.ts+++ b/packages/eve/src/internal/nitro/dev-generation-artifacts.scenario.test.ts@@ -691,6 +691,51 @@ describe("development generation artifacts", () => {expect(plainChanged.fingerprint).not.toBe(helperChanged.fingerprint);});+ it("uses an app-relative workflow id for a workspace agent", async () => {+ const app = await scenarioApp({+ files: {+ "agents/assistant/agent/agent.mjs": 'export default { model: "openai/gpt-5.4" };\n',+ "agents/assistant/agent/instructions.md": "Use the background tool.",+ "agents/assistant/agent/tools/request_mission_plan.mjs": [+ 'import { defineWorkflowTool } from "eve/tools";',+ "",+ "export default defineWorkflowTool({",+ ' description: "Run a mission plan.",',+ ' execution: "background",',+ " inputSchema: {},",+ " async execute() {",+ ' "use workflow";',+ ' return { status: "complete" };',+ " },",+ "});",+ "",+ ].join("\n"),+ "agents/monitor/agent/agent.mjs": 'export default { model: "openai/gpt-5.4" };\n',+ "agents/monitor/agent/instructions.md": "Monitor events.",+ },+ installDependencies: true,+ name: "workspace-workflow-tool-id",+ });+ const appRoot = join(app.appRoot, "agents", "assistant");+ const compileResult = await compileAgent({ startPath: appRoot });+ const generation = await stageDevelopmentGeneration(compileResult);+ const moduleMap = await loadCompiledModuleMapFromAuthoredSource({+ compiledArtifactsSource: createAuthoredSourceRuntimeCompiledArtifactsSource(+ generation.runtimeAppRoot,+ ),+ });+ const sourceId = compileResult.manifest.tools.find(+ (tool) => tool.name === "request_mission_plan",+ )?.sourceId;+ const tool = moduleMap.nodes[ROOT_COMPILED_AGENT_NODE_ID]?.modules[sourceId!] as {+ default: { execute: { workflowId?: string } };+ };++ expect(tool.default.execute.workflowId).toBe(+ "workflow//./agent/tools/request_mission_plan//execute",+ );+ });+it("rejects module-level authored workflow directives", async () => {const app = await scenarioApp({files: {diff --git a/packages/eve/src/internal/nitro/development-generation.test.ts b/packages/eve/src/internal/nitro/development-generation.test.tsindex dfe5cb7fa..e4b8e726e 100644--- a/packages/eve/src/internal/nitro/development-generation.test.ts+++ b/packages/eve/src/internal/nitro/development-generation.test.ts@@ -46,6 +46,7 @@ describe("development generation staging", () => {const compileResult = {manifest: {},paths: { moduleMapPath: "/tmp/app/modules.mjs" },+ project: { appRoot: "/tmp/app" },} as CompileAgentResult;beforeEach(() => {mocks.prepare.mockReset();@@ -61,7 +62,11 @@ describe("development generation staging", () => {mocks.stage.mockReturnValue(staging.promise);mocks.materialize.mockResolvedValue({ fingerprint: "ready" });const result = stageDevelopmentGeneration(compileResult);- expect(mocks.prepare).toHaveBeenCalledOnce();+ expect(mocks.prepare).toHaveBeenCalledWith({+ appRoot: "/tmp/app",+ manifest: compileResult.manifest,+ moduleMapPath: "/tmp/app/modules.mjs",+ });expect(mocks.stage).toHaveBeenCalledOnce();preparation.resolve({ authoredWorkflowModules: {} });await Promise.resolve();diff --git a/packages/eve/src/internal/nitro/development-generation.ts b/packages/eve/src/internal/nitro/development-generation.tsindex 54ddb1c37..c0d866952 100644--- a/packages/eve/src/internal/nitro/development-generation.ts+++ b/packages/eve/src/internal/nitro/development-generation.ts@@ -32,6 +32,7 @@ export async function stageDevelopmentGeneration(// Drain both operations before discarding a failed candidate's snapshot.const [preparation, staging] = await Promise.allSettled([prepareAuthoredRuntimeModules({+ appRoot: compileResult.project.appRoot,manifest: compileResult.manifest,moduleMapPath: compileResult.paths.moduleMapPath,}),