awslabs / awslabs/agentcore-samples
01-tutorials - 01-short-term-memory/01-single-agent/with-langgraph-agent
- Dominant language
- Python
- Stars
- 3.4k
- Forks
- 1.3k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 30
Description
**Which component is impacted by this improvement?**
- [X] 04-AgentCore-memory
**Improvement Description**
# Feature Request: Fix Primary AgentCore Memory + LangGraph Tutorial
## Issue
The tutorial at `01-tutorials/04-AgentCore-memory/01-short-term-memory/01-single-agent/with-langgraph-agent/personal-fitness-coach.ipynb` is the **first example** developers encounter when looking for AgentCore Memory + LangGraph integration patterns.
However, instead of demonstrating the **idiomatic stateless agent pattern** that developers actually want to learn, this example shows a confusing hybrid approach that:
- Uses **LangGraph MessagesState as the primary memory source** (stateful agent)
- Treats **AgentCore Memory as a redundant backup** that saves conversations as side-effects
- **Never loads full conversation history** from AgentCore Memory at invocation start
- Adds an optional memory retrieval tool that's rarely needed since the agent already has LangGraph state
- Requires maintaining conversation state in LangGraph between invocations
## What Developers Actually Want to See
An **idiomatic stateless agent** that demonstrates AgentCore Memory as the primary conversation persistence layer:
```python
def call_agent(user_query, session_id):
# Load full conversation history from AgentCore Memory
messages = retrieve_agentcore_memory_shortterm(session_id)
messages.append(format_user_query(user_query))
# Stateless agent call with complete context
response = agent.invoke({"messages": messages})
# Save updated conversation back to AgentCore Memory
save_agentcore_memory_shortterm(messages + [response], session_id)
return response
```
This pattern shows:
- **True stateless operation**: Agent doesn't maintain internal state
- **AgentCore Memory as primary source**: Conversation persistence handled externally
- **Clean separation of concerns**: Memory management separate from agent logic
- **Cross-session continuity**: Conversations survive agent restarts/deployments
## Impact
IMO this tutorial confuses developers about AgentCore Memory's value proposition and teaches a stateful anti-pattern instead of the clean stateless architecture that makes AgentCore Memory valuable.
## Recommendation
Replace with a clear example showing AgentCore Memory as the **primary** conversation memory mechanism that enables truly stateless LangGraph agents.
Contributor guide
Assessment
This issue has not been assessed yet.