Skip to content

feat(templates): wire in memory to the runtime templates - #2116

Open
Hweinstock wants to merge 7 commits into
aws:refactorfrom
Hweinstock:memory-in-templates
Open

feat(templates): wire in memory to the runtime templates#2116
Hweinstock wants to merge 7 commits into
aws:refactorfrom
Hweinstock:memory-in-templates

Conversation

@Hweinstock

@Hweinstock Hweinstock commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Dependent on #2099 (ignore this until that is merged)

Problem

Memory is currently hardcoded to none. The old CLI defaulted to a real memory, and allowed none | longAndShort | short options.

Solutions

  • mirror old CLI arguments for memory with the same default.
  • wire that memory through to the template resolver.
  • refactor the fsTreeNode asset resolver to accept transformations and filters for added flexibility.

Testing

created a project with the memory template then deployed, verified the project and my cdk stack included a memory. Also verified the memory code was included in the asset rendering.

 > agentcore project create --name testP --template strands-python
 ...
 > ls testP/app/strands_agent
 README.md  main.py  mcp_client  memory  model  pyproject.toml  skills  uv.lock
 [ shows the memory folder which is conditionally rendered ] 

> cat testP/agentcore/agentcore.json | jq 

{
  "name": "testP",
  "version": 1,
  "managedBy": "CDK",
  "runtimes": [
    {
      "name": "strands_agent",
      "build": "CodeZip",
      "entrypoint": "main.py",
      "codeLocation": "app/strands_agent",
      "runtimeVersion": "PYTHON_3_14",
      "protocol": "HTTP"
    }
  ],
  "memories": [
    {
      "name": "strands_agentMemory",
      "eventExpiryDuration": 30,
      "strategies": [
        {
          "type": "SEMANTIC",
          "namespaceTemplates": [
            "/users/{actorId}/facts"
          ]
        },
        {
          "type": "USER_PREFERENCE",
          "namespaceTemplates": [
            "/users/{actorId}/preferences"
          ]
        },
        {
          "type": "SUMMARIZATION",
          "namespaceTemplates": [
            "/summaries/{actorId}/{sessionId}"
          ]
        },
        {
          "type": "EPISODIC",
          "namespaceTemplates": [
            "/episodes/{actorId}/{sessionId}"
          ],
          "reflectionNamespaceTemplates": [
            "/episodes/{actorId}"
          ]
        }
      ]
    }
  ]
}

[shows the memory config]
 
> agentcore project deploy
...

went to console and invoked it, and verified the memory was created.

  • unit tests!

@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 26, 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 Aug 26, 2026
@codecov-commenter

codecov-commenter commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.24%. Comparing base (059e1a5) to head (3c10f37).

Additional details and impacted files
@@            Coverage Diff            @@
##           refactor    #2116   +/-   ##
=========================================
  Coverage     97.24%   97.24%           
=========================================
  Files           471      472    +1     
  Lines         28911    28978   +67     
=========================================
+ Hits          28114    28181   +67     
  Misses          797      797           

☔ 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.

@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

I traced through the refactor and the new strands-http-python template. The extraction into templates/{project,runtime,harness,renderer,types,fsTree}.ts is coherent, the manager's addResource rollback semantics are preserved (mutating projectSpec in place is fine because it isn't written on the error path), the new fromTextFile correctly reads Dockerfile content from disk (so getHarnessTemplateResolver matches the old copyFile behavior, minus the pre-write existence check — the error is still thrown at write time via InputValidationError), and the manifest snapshot confirms memory/ is filtered out when --memory is not set.

Two very minor observations that are not blocking:

  • mergeSpecEntries in src/core/project/templates/project.ts merges runtimes/credentials/memories but ignores harnesses, even though SpecEntries includes it. Currently unreachable since createProjectTree only invokes the runtime resolver, so the omission is harmless — worth fixing if a future template contributes harnesses at project-create time.
  • src/assets/templates/strands-http-python/main.py references a pyJsonStr helper ({{pyJsonStr inputSchema}} and {{pyJsonStr litellmAdditionalParams}}) that isn't registered in HandlebarsTemplateRenderer. Guarded behind inlineFunctionTools / litellmAdditionalParams, both of which are never set in the current runtime.ts context, so it's latent — but it will blow up the day someone flips those flags on.

Neither of these needs to hold up the merge.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Aug 26, 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 Aug 26, 2026
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 26, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Aug 26, 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 Aug 26, 2026
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 26, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Aug 26, 2026
@Hweinstock
Hweinstock force-pushed the memory-in-templates branch from 1b25e3b to f07f985 Compare August 26, 2026 21:51
@github-actions github-actions Bot removed the size/xl PR size: XL label Aug 26, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added the size/xl PR size: XL label Aug 26, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added claude-security-reviewing Claude Code /security-review in progress and removed claude-security-reviewing Claude Code /security-review in progress labels Aug 26, 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 Aug 26, 2026
@Hweinstock
Hweinstock force-pushed the memory-in-templates branch from f07f985 to 9088f13 Compare August 26, 2026 22:25
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 26, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Aug 26, 2026
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Aug 27, 2026
@Hweinstock
Hweinstock marked this pull request as ready for review August 27, 2026 19:37

@notgitika notgitika 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.

pretty straightforward we are mostly just porting over what already exists on main so I don't wanna comment about improvements in the templates themselves that we can bring in later.

LGTM just 2 questions

Comment thread src/handlers/project/shortcuts.ts Outdated

export const MEMORY_SHORTCUTS = {
none: (_runtimeName: string) => undefined,
short: (runtimeName: string): Memory => ({

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.

just wanna point out that this renames shortTerm / longAndShortTerm that exist in CLI main, so existing CLI commands fail. was that intended?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oh good catch, I actually thought this is what was on main, let me swap it to match.

export const MEMORY_SHORTCUTS = {
none: (_runtimeName: string) => undefined,
short: (runtimeName: string): Memory => ({
name: `${runtimeName}Memory`,

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.

I haven't fully confirmed this but just wanted to make sure that when we append "Memory" here we are staying under the character limit of the service API, which is 48 chars? can we make sure the runtimeName then stays 42 chars max?

once bitten, twice shy 😊

@Hweinstock Hweinstock Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good call! These are the types of edge cases that only someone who has implemented this before would know :)

@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Aug 27, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Aug 27, 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 Aug 27, 2026
@github-actions github-actions Bot added size/l PR size: L and removed size/m PR size: M labels Aug 27, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Aug 27, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

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

notgitika
notgitika previously approved these changes Aug 28, 2026

@notgitika notgitika 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.

LGTM thanks for addressing comments :)

@github-actions github-actions Bot added size/l PR size: L and removed size/l PR size: L labels Aug 28, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Aug 28, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: the review did not analyze this PR (model took 0 turns). See the run for details; a later push or re-run is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants