Skip to content

fix(memory): Phase 0.2 AgentCore Memory fixes from the baseline audit - #1292

Merged
philmerrell merged 1 commit into
developfrom
feature/memory-phase0-fixes
Sep 25, 2026
Merged

philmerrell merged 1 commit into
developfrom
feature/memory-phase0-fixes

Conversation

@philmerrell

@philmerrell philmerrell commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Shared Projects Phase 0.2: the fixes found by the AgentCore Memory baseline audit (#1291, docs/specs/memory-baseline-decision.md).

Fix Change Where
Fix 1 Relevance cut 0.7 → 0.5. In dev, a natural question about a stored fact scored 0.57–0.67 and unrelated records ≤ 0.40. At 0.7, no turn ever received memory context: 0 hits in 7 days, and the two-chat test failed. agents/main_agent/config/constants.py
Fix 2 Session delete purges that session's summary records. It matches the exact per-session namespace, deletes in batches of 100, and runs even after the session's events have expired. sessions/services/session_service.py
Fix 3 Share-fork events skip long-term extraction (extractionMode="SKIP"). The owner's messages stay in the fork's history but no longer become the forker's "memories". shares/service.py
Fix 4 Runtime IAM parity. Both memory statements share RUNTIME_MEMORY_ACTIONS. The scoped statement lacked GetMemory, under a comment wrongly saying it was not a real IAM action. inference-api-iam-roles.ts, inference-agentcore-construct.ts
Fix 5 Stale "write-only" lines corrected. In two specs, plus the app_context_dispatch.py docstring, which cited a deleted analysis doc. docs, docstring
Fix 6 CDK test pins strategy names, no custom namespaces, 90-day expiry, and identical Runtime memory action sets. infrastructure/test/agentcore-memory.test.ts

Worth a careful look

  • Fix 1: changes what users' turns contain. Turns with a relevant record gain a <user_context> block on the user message. It sits after the prompt-cache point, so the cached system prefix is untouched.
    • The value is a code default only. The Runtime is at 47 of 50 env vars, and the existing AGENTCORE_MEMORY_RELEVANCE_SCORE already overrides it per environment when set.
    • After this deploys to dev, re-run the two-chat test. Its result confirms or overturns option C in the decision record.
  • Fix 2: deliberately leaves semantic facts and preferences alone. Records carry only type and timestamp metadata, no source session, and those strategies consolidate across sessions, so no record can be attributed to one session.
  • Fix 3: wraps the fork's own session-manager data-plane client, because the SDK's create_message has no extraction argument. A test drives the pinned SDK's real MemoryClient.create_event, so an upgrade that bypasses the wrapper fails CI.
  • Fix 4: changes no effective permissions. The account-wide statement already carried every action. The scoped statement now matches it instead of silently depending on it.

Test plan

  • Backend: new test_session_delete_memory_purge.py (5) and fork-extraction tests in test_share_export.py (3); test_session_factory.py default updated
  • Full backend suite (10,228 passed)
  • Infrastructure: tsc --noEmit, full jest (932 passed, incl. 4 new)
  • tests/supply_chain/ (31 passed; the audit's copy of the relevance cut now pins 0.5)
  • Dev after deploy: two-chat memory test (chat A states a fact, chat B recalls it; runtime log shows Retrieved N customer context items)

🤖 Generated with Claude Code

- Relevance cut 0.7 -> 0.5 (constants default). In dev, questions about a
  stored fact scored 0.57-0.67 and unrelated records <= 0.40, so 0.7 dropped
  every realistic hit and no turn ever received memory context.
- Session delete also purges that session's SUMMARIZATION records (exact
  per-session namespace, batches of 100), even after its events expired.
  Semantic facts/preferences carry no source session and are left alone.
- Share-fork writes events with extractionMode="SKIP", so another user's
  messages stay in the fork's history but never feed the forker's
  long-term extraction.
- Runtime role: both memory statements share RUNTIME_MEMORY_ACTIONS (the
  scoped one lacked GetMemory under a wrong comment).
- Stale "write-only" lines corrected in two specs and the
  app_context_dispatch docstring (which cited a deleted analysis doc).
- CDK test pins strategy names, no custom namespaces, 90-day expiry and
  identical Runtime memory action sets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@philmerrell
philmerrell merged commit c1b81ec into develop Sep 25, 2026
7 checks passed
@philmerrell
philmerrell deleted the feature/memory-phase0-fixes branch September 25, 2026 03:45
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.

1 participant