fix(harness): --no-memory disables managed memory instead of omitting it#1629
Closed
aidandaly24 wants to merge 1 commit into
Closed
fix(harness): --no-memory disables managed memory instead of omitting it#1629aidandaly24 wants to merge 1 commit into
aidandaly24 wants to merge 1 commit into
Conversation
In the gated-off path, add harness --no-memory wrote a spec that omitted the memory config entirely. The AgentCore service treats omitted memory as 'auto-provision a managed memory', so a 'no memory' harness got a managed memory harness_<physicalName>_<hash> its execution role wasn't scoped for — invoke then failed with AccessDenied on bedrock-agentcore:ListEvents. CDK #287 granted permissions for the omitted case as a workaround, because the CFN Harness resource could not express a memory opt-out then. That is no longer true: Memory: { Disabled: {} } shipped in the CDK (#273) and the vended project resolves ^0.1.0-alpha.19 to the latest published alpha, which has it. buildLegacyMemoryRef now returns { mode: 'disabled' } for --no-memory instead of undefined, a true opt-out that maps to CFN Memory: { Disabled: {} } — no memory is created, no grant is needed. Strengthen the --no-memory integ test to assert the spec carries memory.mode 'disabled'. Closes #1628
Contributor
|
Claude Security Review: no high-confidence findings. (run) |
Contributor
Package TarballHow to installgh release download pr-1629-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-0.20.2.tgz |
agentcore-cli-automation
approved these changes
Jun 23, 2026
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
Looks good to merge.
Verified the fix:
- The legacy (gated-OFF)
buildLegacyMemoryRefnow correctly emits{ mode: 'disabled' }for--no-memoryinstead of returningundefined, which prevents the AgentCore service from auto-provisioning an unwanted managed memory the harness role can't read. - The gated-ON path (
buildMemoryRefat lines 1216–1218) already handledskipMemorycorrectly, so the change is correctly scoped to just the legacy path. - The narrowed condition (
skipMemoryis the only way to reach the!options.memoryArn && !namebranch in legacy mode, sinceautoCreateMemoryNameis otherwise${name}Memory) means the: undefinedfallback is effectively defensive — fine. - Pulled
@aws/agentcore-cdk@0.1.0-alpha.39(which the vended^0.1.0-alpha.19resolves to under npm prerelease semver) and confirmed it both mapsmode === 'disabled'→Memory: { Disabled: {} }inharness-cfn-mapping.jsand gates the memory role grant viamanagedMemory = spec.memory?.mode !== 'disabled'inAgentCoreHarnessEnvironment.js. So the CLI-only change is sufficient end-to-end. - The integ-test addition asserts
spec.memory?.mode === 'disabled'against a real on-diskharness.jsonwritten by the CLI — no mocking concerns. - No new telemetry instrumentation needed; the existing return value
memoryMode: memoryRef?.mode(line 442) will now naturally report'disabled'for this path instead ofundefined, which is actually an improvement for observability.
Contributor
Coverage Report
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
agentcore add harness --no-memory(gated-off path) wrote a harness spec that omitted the memory config entirely. The AgentCore service treats an omitted memory config as "auto-provision a managed memory", so a "no memory" harness ended up with a managed memoryharness_<physicalName>_<hash>it never asked for — and the execution role wasn't scoped for it, so invoke failed:This is a contributing cause of the
harness-custom-jwtE2E failure (that test uses--no-memory).Background. CDK #287 made the harness role grant memory permissions for the omitted case (
managedMemory = spec.memory?.mode !== 'disabled') — specifically because the CFNHarnessresource couldn't express a memory opt-out at the time, so "no memory" still got a service-auto-created memory that needed the grant. That CFN limitation is gone:Memory: { Disabled: {} }shipped in the CDK (#273, alpha.20+) and the vended project resolves^0.1.0-alpha.19→ the latest published0.1.0-alpha.39, which has it.Fix.
buildLegacyMemoryRefnow returns{ mode: 'disabled' }for--no-memoryinstead ofundefined. That maps to CFNMemory: { Disabled: {} }— no memory is provisioned, noListEventsgrant is needed, no AccessDenied. CLI-only change; the CFNdisabledmapping and the schema'sdisabledarm are already live and ungated.Related Issue
Closes #1628
Documentation PR
N/A
Type of Change
Testing
How have you tested the change?
npm run test:unitandnpm run test:integnpm run typecheck(clean)npm run lint(0 errors; 31 pre-existing warnings)npm run test:integ—add-remove-harness.test.ts35/35 pass (strengthened the--no-memorytest to assertspec.memory.mode === 'disabled')Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.