Skip to content

feat(memory)!: generated agent code reads MEMORY_<NAME>_ID - #2583

Merged
notgitika merged 1 commit into
aws:refactorfrom
notgitika:feat/v0-memory-env-var-name
Oct 13, 2026
Merged

notgitika merged 1 commit into
aws:refactorfrom
notgitika:feat/v0-memory-env-var-name

Conversation

@notgitika

Copy link
Copy Markdown
Contributor

Description

Agent code the CLI generates reads MEMORY_<NAME>_ID for the deployed memory id, the name the v0 CLI deployed, instead of AGENTCORE_MEMORY_<NAME>_ID. memoryEnvVarName() is the single source of that name: the runtime templates ({{memoryEnvVarName}} in memory/session.py and memory/memory.ts), the Bedrock agent import translators and export harness all call it, so one function changes.

The matching library change is aws/agentcore-l3-cdk-constructs#418, which sets MEMORY_<NAME>_ID on the runtime. Both sides have to agree: if the deploy sets one name and the code reads the other, os.getenv returns None and the template runs with memory off, with no error. With both changes in, v0 agent code keeps finding its memory after migration without edits, and new v1 projects read the name the deploy sets.

  • Only the memory variable changes. Project gateway (AGENTCORE_GATEWAY_<NAME>_*) and payment (AGENTCORE_PAYMENT_*) names are the same in v0 and v1, and the CLI composes no other discovery names.
  • Pairs with aws/agentcore-l3-cdk-constructs#418. The next @aws/agentcore-cdk bump brings the library side; refactor is unreleased, so the order does not matter.

BREAKING CHANGE: agent code generated by earlier v1 release candidates reads AGENTCORE_MEMORY_<NAME>_ID and must switch to MEMORY_<NAME>_ID.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

  • I ran bun test (3975 passed)
  • End-to-end tests are not applicable: the generated variable name changes; covered by the template, import translator and export unit tests
  • I ran bun run typecheck
  • I ran bun run lint:check
  • I ran bun run format:check

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

memoryEnvVarName() returns MEMORY_<NAME>_ID, the name the v0 CLI deployed, instead of AGENTCORE_MEMORY_<NAME>_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_<NAME>_ID and must switch to MEMORY_<NAME>_ID.
@github-actions github-actions Bot added the size/xs PR size: XS label Oct 13, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added agentcore-harness-reviewing AgentCore Harness review in progress claude-security-reviewing Claude Code /security-review in progress labels Oct 13, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Oct 13, 2026

@agentcore-devx-automation agentcore-devx-automation Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AgentCore Harness Review

Verdict: Looks good

This is a straightforward correctness fix. The memoryEnvVarName helper in src/projectSchemas/memory.ts was producing AGENTCORE_MEMORY_<NAME>_ID, but the CDK construct (AgentCoreMemory.ts:226 in agentcore-l3-cdk-constructs) actually sets MEMORY_<NAME>_ID on the runtime. That mismatch meant generated harness Python (memory/session.py) and TS (memory.ts) templates were reading an env var the deployed runtime never populated, so MEMORY_ID would be None/undefined at runtime for any agent using memory.

Verified:

  • All callers (runtime.ts, export.ts, strandsTranslator.ts, langGraphTranslator.ts) funnel through this one helper, so the single-line change covers every template.
  • Other parts of the CLI (schema-mapper.ts, dev/memory-env.ts, import/actions.ts) were already using the MEMORY_<NAME>_ID convention — this change finally makes the harness consistent with them and with the CDK.
  • All four impacted tests are updated.
  • No stale AGENTCORE_MEMORY_ references remain (the one hit in import/actions.ts is the unrelated legacy BEDROCK_AGENTCORE_MEMORY_ID shown in a migration message).

Nothing else needs to change before merge.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Oct 13, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.50%. Comparing base (609ae00) to head (5ebb24b).

Additional details and impacted files
@@            Coverage Diff            @@
##           refactor    #2583   +/-   ##
=========================================
  Coverage     97.50%   97.50%           
=========================================
  Files           635      635           
  Lines         47250    47250           
=========================================
  Hits          46071    46071           
  Misses         1179     1179           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nborges-aws nborges-aws left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR LGTM. Though I only see the memory prefix updated here. Based on the CDK PR we need to flip AGENTCORE_CREDENTIAL_ to CREDENTIAL_ also. Or in a follow up to this perhaps

@notgitika
notgitika marked this pull request as ready for review October 13, 2026 18:08
@notgitika
notgitika merged commit 262aae3 into aws:refactor Oct 13, 2026
21 of 22 checks passed
@notgitika
notgitika deleted the feat/v0-memory-env-var-name branch October 13, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xs PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants