Skip to content

feat(project): add project add memory - #2025

Open
notgitika wants to merge 12 commits into
aws:refactorfrom
notgitika:feat/project-add-memory
Open

feat(project): add project add memory#2025
notgitika wants to merge 12 commits into
aws:refactorfrom
notgitika:feat/project-add-memory

Conversation

@notgitika

@notgitika notgitika commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

This PR adds agentcore project add memory, which validates and appends a memory resource to spec.memories in agentcore.json. Memory resources do not scaffold any application files and are deployed through the generated CDK application.

Example:

  agentcore project add memory \
    --name UserFacts \
    --strategies SEMANTIC,EPISODIC

To maintain parity with the xisting CLI functionality, while also adding more configurability and customization, --strategies supports 2 input types:

  • Comma-separated managed strategy types using default namespaces
  • JSON MemoryStrategyInput[] for explicit names, descriptions, and namespaces (there is a parameter help in --help for ease of understanding for the user)

The command also supports expiry duration, indexed keys, stream delivery, encryption and execution roles, descriptions, and tags (description is a new optional field. Here is the CDK PR for it https://github.com/aws/agentcore-l3-cdk-constructs/pull/325 )

Callouts:

  • CUSTOM strategies are not supported because their extraction configuration cannot yet be represented by the project schema.

Validation

I tested it myself e2e with different combinations, flags, strategy conversions and validation failures. It all works well. I also tested it with agetncore project build

TODO: check compatibility with harness resource

@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Aug 18, 2026
@codecov-commenter

codecov-commenter commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.15254% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.16%. Comparing base (33e2d2f) to head (4a06960).

Files with missing lines Patch % Lines
src/handlers/project/add/memory/index.ts 99.12% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           refactor    #2025      +/-   ##
============================================
+ Coverage     97.14%   97.16%   +0.02%     
============================================
  Files           382      383       +1     
  Lines         22884    23120     +236     
============================================
+ Hits          22231    22465     +234     
- Misses          653      655       +2     

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

Comment thread src/core/project/manager.tsx Outdated
Comment thread src/core/project/manager.tsx Outdated
Comment thread src/handlers/project/add/memory/index.ts Outdated
Comment thread src/handlers/project/add/memory/index.ts Outdated
Comment thread src/handlers/project/add/memory/index.ts Outdated
@notgitika
notgitika force-pushed the feat/project-add-memory branch from d114ff9 to a332f9b Compare August 19, 2026 01:27
@notgitika

notgitika commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

My agent ran focused testing for project add memory after the latest validation changes:

  • 122 focused project tests pass, plus build/typecheck/lint/format
  • Rebuilt CLI verified valid JSON persistence and atomic rejection for the new edge cases
  • Covered strategy unions, unsupported fields, indexed keys, stream delivery, tags, malformed JSON, and boundary inputs
  • Live AWS lifecycles passed for minimal memory, all four managed strategies, and Kinesis stream delivery (CREATE_COMPLETE followed by cleanup)
  • Confirmed no test stacks, memories, or streams remain

The testing surfaced and we fixed empty shorthand entries, recursive unsupported-field stripping (including __proto__), missing JSON strategy names, and the JSON-object diagnostic. The remaining long default strategy-name boundary is in the existing project schema/CDK naming layer rather than this handler.

Comment thread src/core/project/manager.tsx
Registers a `memory` leaf under `project add`, following the same
SDK-union -> flat project-schema conversion pattern as `project add
harness`. A memory scaffolds no files, so the command only appends an
entry to `spec.memories` in agentcore.json; the L3 CDK turns that into
an `AWS::BedrockAgentCore::Memory` at deploy time.

Flags: --name, --event-expiry-duration, --strategies, --indexed-keys,
--stream-delivery-resources, --encryption-key-arn, --execution-role-arn,
--tags.

--strategies accepts two forms: a comma-separated list of strategy types
expanded with the CLI's default namespace templates, or a JSON
MemoryStrategyInput[] mirroring the CreateMemory API for strategies that
need explicit names, descriptions, or namespaces.

clientToken is excluded (it is CreateMemory idempotency and this command
makes no API call), and description is excluded until the L3 CDK schema
supports it.
Stores an optional memory description in agentcore.json, matching the
CreateMemory API's description field (max 4096 characters).

The generated CDK app pins @aws/agentcore-cdk 0.1.0-alpha.45, whose
MemorySchema is a non-strict z.object with no description field, so the key
is stripped at synth rather than rejected until
aws/agentcore-l3-cdk-constructs#325 ships and that pin is bumped. The flag
help text says so.
The CDK's memory schema already models CUSTOM (@aws/agentcore-cdk
0.1.0-alpha.45 maps it to CFN customMemoryStrategy), so the CLI's four-type
enum was the outlier. A customMemoryStrategy in the --strategies JSON now
converts to { type: 'CUSTOM', name, description, namespaceTemplates }.

The shorthand form still takes managed types only: CUSTOM has no default
namespaces to expand. An extraction configuration or memoryRecordSchema is
rejected rather than dropped, since the CDK schema carries neither.

Also names the offending field in the memory validation error.
Reverts 87be86e. I added CUSTOM because the CDK schema already had it in
MemoryStrategyTypeSchema, which turns out to be the argument PR aws#694 made --
and aws#713 reverted a day later.

The CLI has removed CUSTOM twice on purpose. Offering the type without
somewhere to put its extraction configuration is aws#241 ("select custom memory
strategy, note there is no option to add prompts"); aws#266 removed it as a P0 to
stop users picking an unsupported option, aws#694/aws#696 added it back with
semanticOverride, and aws#713 reverted both as premature. aws#676 tracks doing it
properly. The CDK keeping CUSTOM in its enum without a configuration field is
the same hole, not a licence.

So both forms are rejected again, now with an error that says why and points
at aws#676. The one thing kept from the reverted commit: memory validation errors
name the offending field, since issue.path was being dropped.
The one-line flag description is enough; the deploy-time caveat lives in the
PR discussion rather than in help output.
@notgitika
notgitika force-pushed the feat/project-add-memory branch from 6d965bf to 4a06960 Compare August 20, 2026 04:48
flag(
"event-expiry-duration",
"how long raw events are retained, in days (3-365)",
z.number().int().min(3).max(365).default(DEFAULT_EVENT_EXPIRY_DURATION),

@nborges-aws nborges-aws Aug 20, 2026

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.

Is 3 day min here correct? I thought min was 7 in CDK

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants