Description
Environment
- AgentCore CLI Version: 0.14.0
- Command used:
agentcore create --memory longAndShortTerm
- Framework: Strands (Python)
Description
When creating a new agent with long-term memory, the CLI generates a memory/session.py file that incorrectly scopes summary retrieval to only the current session, preventing cross-session memory recall.
Technical Explanation
According to the bedrock_agentcore.memory SDK implementation:
- The
retrieve_customer_context() method in AgentCoreMemorySessionManager resolves namespace templates and passes them to memory_client.retrieve_memories()
- When using
namespace_path parameter, it performs hierarchical prefix matching
- By including the specific
{session_id} in the path, it only matches records under that exact session
- Removing
/{session_id} allows prefix matching across all sessions for the actor
Reference: bedrock_agentcore/memory/integrations/strands/session_manager.py lines 847-871
Impact
- High: Affects all agents created with
--memory longAndShortTerm
- Returning users don't benefit from conversation history across sessions
- Significantly reduces the value proposition of long-term memory
- Users may not notice the issue immediately, leading to suboptimal agent behavior in production
Workaround
Manually edit the generated memory/session.py to remove /{session_id} from the summaries namespace path.
Suggested Fix
Update the code generation template for Python/Strands agents with long-term memory to omit {session_id} from the summaries namespace configuration.
Steps to Reproduce
Reproduction Steps
- Run:
agentcore create --project-name TestAgent --name TestAgent --language Python --framework Strands --model-provider Bedrock --memory longAndShortTerm
- Open:
TestAgent/app/TestAgent/memory/session.py
- Observe line 22:
f"/summaries/{actor_id}/{session_id}": RetrievalConfig(...)
Expected Behavior
Expected Behavior
Summaries should be retrieved across all sessions for the actor to enable true long-term memory:
retrieval_config = {
f"/users/{actor_id}/facts": RetrievalConfig(top_k=3, relevance_score=0.5),
f"/users/{actor_id}/preferences": RetrievalConfig(top_k=3, relevance_score=0.5),
f"/summaries/{actor_id}": RetrievalConfig(top_k=3, relevance_score=0.5), # ← Fixed: removed /{session_id}
}
Actual Behavior
Current Behavior (Bug)
The generated retrieval_config in app/<AgentName>/memory/session.py includes {session_id} in the summaries namespace:
retrieval_config = {
f"/users/{actor_id}/facts": RetrievalConfig(top_k=3, relevance_score=0.5),
f"/users/{actor_id}/preferences": RetrievalConfig(top_k=3, relevance_score=0.5),
f"/summaries/{actor_id}/{session_id}": RetrievalConfig(top_k=3, relevance_score=0.5), # ← Bug here
}
This means the agent only retrieves summaries from the current session, not from previous sessions.
CLI Version
0.14.0
Operating System
macOS
Additional Context
Additional Context
This issue was discovered when analyzing memory retrieval behavior in a banking assistant agent. The agent was unable to recall conversation summaries from previous sessions, which broke the personalization experience for returning users.
Description
Environment
agentcore create --memory longAndShortTermDescription
When creating a new agent with long-term memory, the CLI generates a
memory/session.pyfile that incorrectly scopes summary retrieval to only the current session, preventing cross-session memory recall.Technical Explanation
According to the
bedrock_agentcore.memorySDK implementation:retrieve_customer_context()method inAgentCoreMemorySessionManagerresolves namespace templates and passes them tomemory_client.retrieve_memories()namespace_pathparameter, it performs hierarchical prefix matching{session_id}in the path, it only matches records under that exact session/{session_id}allows prefix matching across all sessions for the actorReference:
bedrock_agentcore/memory/integrations/strands/session_manager.pylines 847-871Impact
--memory longAndShortTermWorkaround
Manually edit the generated
memory/session.pyto remove/{session_id}from the summaries namespace path.Suggested Fix
Update the code generation template for Python/Strands agents with long-term memory to omit
{session_id}from the summaries namespace configuration.Steps to Reproduce
Reproduction Steps
agentcore create --project-name TestAgent --name TestAgent --language Python --framework Strands --model-provider Bedrock --memory longAndShortTermTestAgent/app/TestAgent/memory/session.pyf"/summaries/{actor_id}/{session_id}": RetrievalConfig(...)Expected Behavior
Expected Behavior
Summaries should be retrieved across all sessions for the actor to enable true long-term memory:
Actual Behavior
Current Behavior (Bug)
The generated
retrieval_configinapp/<AgentName>/memory/session.pyincludes{session_id}in the summaries namespace:This means the agent only retrieves summaries from the current session, not from previous sessions.
CLI Version
0.14.0
Operating System
macOS
Additional Context
Additional Context
This issue was discovered when analyzing memory retrieval behavior in a banking assistant agent. The agent was unable to recall conversation summaries from previous sessions, which broke the personalization experience for returning users.