From 5ebb24b885a42063ef143b03eec6c56bfac872e2 Mon Sep 17 00:00:00 2001 From: notgitika Date: Mon, 12 Oct 2026 23:48:40 -0400 Subject: [PATCH] feat(memory)!: generated agent code reads MEMORY__ID memoryEnvVarName() returns MEMORY__ID, the name the v0 CLI deployed, instead of AGENTCORE_MEMORY__ID. @aws/agentcore-cdk sets the same name as of aws/agentcore-l3-cdk-constructs#418, so the templates, the Bedrock agent import translators and export harness read the variable the deploy actually sets. BREAKING CHANGE: agent code generated by earlier v1 release candidates reads AGENTCORE_MEMORY__ID and must switch to MEMORY__ID. --- src/core/project/bedrockAgentImport/translator.test.ts | 2 +- src/core/project/manager.export.test.ts | 2 +- src/core/project/manager.test.ts | 4 +--- src/core/project/templates/export.test.ts | 2 +- src/projectSchemas/memory.ts | 8 ++++++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/core/project/bedrockAgentImport/translator.test.ts b/src/core/project/bedrockAgentImport/translator.test.ts index fa645bcc13..a73894dd93 100644 --- a/src/core/project/bedrockAgentImport/translator.test.ts +++ b/src/core/project/bedrockAgentImport/translator.test.ts @@ -389,7 +389,7 @@ test.each([ }).translate(); expect(plan.files[file]).toContain( - `MEMORY_ID = os.getenv("AGENTCORE_MEMORY_${"A".repeat(42)}MEMORY_ID")`, + `MEMORY_ID = os.getenv("MEMORY_${"A".repeat(42)}MEMORY_ID")`, ); }, ); diff --git a/src/core/project/manager.export.test.ts b/src/core/project/manager.export.test.ts index 8d70ddfef4..064cd0d8c0 100644 --- a/src/core/project/manager.export.test.ts +++ b/src/core/project/manager.export.test.ts @@ -185,7 +185,7 @@ describe("FsProjectManager.exportHarness rendered tree", () => { const result = await drain(subject.exportHarness(project, exportInput())); const session = await Bun.file(join(result.agentPath, "memory", "session.py")).text(); - expect(session).toContain('MEMORY_ID = os.getenv("AGENTCORE_MEMORY_CHAT_HISTORY_ID")'); + expect(session).toContain('MEMORY_ID = os.getenv("MEMORY_CHAT_HISTORY_ID")'); expect(await Bun.file(join(result.agentPath, "main.py")).text()).toContain( "from memory.session import get_memory_session_manager", ); diff --git a/src/core/project/manager.test.ts b/src/core/project/manager.test.ts index 62489c496f..9967cd361f 100644 --- a/src/core/project/manager.test.ts +++ b/src/core/project/manager.test.ts @@ -273,9 +273,7 @@ describe("FsProjectManager.create", () => { const session = await Bun.file( join(directory, "example", "app", "agent_python_strands", "memory", "session.py"), ).text(); - expect(session).toContain( - 'MEMORY_ID = os.getenv("AGENTCORE_MEMORY_AGENT_PYTHON_STRANDSMEMORY_ID")', - ); + expect(session).toContain('MEMORY_ID = os.getenv("MEMORY_AGENT_PYTHON_STRANDSMEMORY_ID")'); }); test("writes a deploy-ready agentcore.json registering the template agent", async () => { diff --git a/src/core/project/templates/export.test.ts b/src/core/project/templates/export.test.ts index 7c5d02941f..3631208e1f 100644 --- a/src/core/project/templates/export.test.ts +++ b/src/core/project/templates/export.test.ts @@ -544,7 +544,7 @@ describe("mapHarnessToExportPlan memory", () => { }); expect(result.hasMemory).toBe(true); - expect(result.context.memoryEnvVarName).toBe("AGENTCORE_MEMORY_CHAT_HISTORY_ID"); + expect(result.context.memoryEnvVarName).toBe("MEMORY_CHAT_HISTORY_ID"); expect(result.context.memoryStrategies).toEqual(["SEMANTIC"]); expect(result.context.actorId).toBe("actor-1"); expect(result.notes).toEqual([]); diff --git a/src/projectSchemas/memory.ts b/src/projectSchemas/memory.ts index b8dabf7d01..738ff8c8eb 100644 --- a/src/projectSchemas/memory.ts +++ b/src/projectSchemas/memory.ts @@ -184,9 +184,13 @@ export const MemorySchema = z }); export type Memory = z.infer; -/** Derives the env var name the CDK backend injects with the deployed memory id. */ +/** + * The env var the CDK backend sets on the runtime with the deployed memory id: `MEMORY__ID`, the + * memory name uppercased. This is the name the v0 CLI deployed, kept so v0 agent code keeps finding its + * memory after migration; @aws/agentcore-cdk sets the same name (aws/agentcore-l3-cdk-constructs#418). + */ export function memoryEnvVarName(memoryName: string): string { - return `AGENTCORE_MEMORY_${memoryName.toUpperCase()}_ID`; + return `MEMORY_${memoryName.toUpperCase()}_ID`; } export function defaultMemoryName(runtimeName: string): string {