Skip to content

fix: scope summaries retrieval to actor for cross-session memory recall#1299

Merged
notgitika merged 1 commit into
aws:mainfrom
notgitika:fix-cross-session-memory-retrieval
May 20, 2026
Merged

fix: scope summaries retrieval to actor for cross-session memory recall#1299
notgitika merged 1 commit into
aws:mainfrom
notgitika:fix-cross-session-memory-retrieval

Conversation

@notgitika
Copy link
Copy Markdown
Contributor

Summary

  • Remove /{session_id} from the summaries namespace path in the generated memory/session.py template
  • Fixes all three protocol variants (HTTP, A2A, AGUI) so agents with --memory longAndShortTerm can retrieve conversation summaries across sessions via hierarchical prefix matching
  • Updates asset snapshots to reflect the template change

Problem

The generated retrieval config scoped summaries to /summaries/{actor_id}/{session_id}, meaning the agent could only recall summaries from the current session. This completely defeated the purpose of long-term memory for returning users.

Fix

Change the retrieval path from /summaries/{actor_id}/{session_id} to /summaries/{actor_id}. The SDK's retrieve_memories() uses hierarchical prefix matching, so this now finds summaries stored under any session for the actor.

Writes still store under /summaries/{actor_id}/{session_id} (SDK behavior), so session-level organization is preserved — only the read scope is widened.

Test plan

  • npm run test:update-snapshots — snapshots regenerated
  • Asset snapshot tests pass (109/109)
  • Pre-commit hooks pass (typecheck, lint, secretlint)
  • Manual verification: create agent with --memory longAndShortTerm, invoke across two sessions, confirm second session retrieves first session's summaries

Closes #1279

…on memory

The generated session.py template included {session_id} in the summaries
namespace path, limiting retrieval to the current session only. This
prevented agents with longAndShortTerm memory from recalling conversation
summaries across sessions. Remove {session_id} so the hierarchical prefix
match finds summaries from all sessions for the given actor.

Closes aws#1279
@notgitika notgitika requested a review from a team May 18, 2026 21:49
@github-actions github-actions Bot added the size/xs PR size: XS label May 18, 2026
@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress claude-security-reviewing Claude Code /security-review in progress and removed claude-security-reviewing Claude Code /security-review in progress labels May 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-0.12.1.tgz

How to install

npm install https://github.com/aws/agentcore-cli/releases/download/pr-1299-tarball/aws-agentcore-0.12.1.tgz

Copy link
Copy Markdown

@agentcore-cli-automation agentcore-cli-automation left a comment

Choose a reason for hiding this comment

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

Fix looks correct and consistent with how retrieve_memories does hierarchical prefix matching. The write-side namespace (/summaries/{actorId}/{sessionId}) configured on the SUMMARIZATION strategy is unchanged, so existing data still organizes by session — only the read scope widens. Nice touch that this also brings create-time templates in line with the import translators (langgraph-translator.ts, strands-translator.ts), which already used /summaries/{user_id}/.

One thing worth addressing before merging:

docs/memory.md (line 95) still shows the buggy pattern this PR is fixing:

f"/summaries/{actor_id}/{session_id}": RetrievalConfig(top_k=3, relevance_score=0.5)

Since that section is the canonical "set up memory by hand" example, leaving it as-is will steer users toward the same bug the PR fixes in the templates. Suggest updating it to f"/summaries/{actor_id}" to match, with a short note explaining the asymmetry (writes go under /summaries/{actor_id}/{session_id}, reads use prefix matching for cross-session recall).

@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label May 18, 2026
@notgitika notgitika merged commit 1402057 into aws:main May 20, 2026
29 of 32 checks passed
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.

Incorrect namespace for cross-session memory retrieval in generated code

4 participants