Task 3 · 8 tasks
File sessions
Persist the conversation to disk so the agent still knows Alice after a restart.
The “Goldfish” problem
Alice introduced herself. One restart later the agent greeted her like a stranger. Give it short-term memory that survives the process.
Build it
Make the conversation survive a restart
Challenge
Give the Task 2 agent a session that is saved under
SESSIONS_DIRwith the idalice_session.Work in
phase1/starter/t3_sessions.py(look forTODO; an unfinished one prints[starter] TODO …) and run it withuv run bootcamp.py phase1 t3 --starter. The reference solution isphase1/t3_sessions.py;uv run bootcamp.py phase1 t3runs it.Hint 1
Strands has session managers that plug into the agent lifecycle. Look at
strands.session.FileSessionManager. See Strands: session management.Hint 2
Create it once, before the agent, and pass it as
session_manager=.sketchread onlysession_manager = FileSessionManager(session_id=..., storage_dir=str(SESSIONS_DIR))Solution
phase1/t3_sessions.pysession_manager = FileSessionManager(session_id="alice_session", storage_dir=str(SESSIONS_DIR)) with make_mcp_client() as mcp_client: agent = Agent( name="Data Engineer", model=make_model(), system_prompt=SYSTEM_PROMPT, tools=mcp_client.list_tools_sync(), session_manager=session_manager, ) run(agent)Introduce yourself, then restart
terminal · your starter fileuv run bootcamp.py phase1 t3 --starter "My name is Alice Chen, CEO of DataStream Corp" uv run bootcamp.py phase1 t3 --starter "What's my name?"terminal · reference solutionuv run bootcamp.py phase1 t3 "My name is Alice Chen, CEO of DataStream Corp" uv run bootcamp.py phase1 t3 "What's my name?"Two separate processes, one memory. Look at what was stored:
terminalls phase1/sessions/session_alice_session/agents/agent_default/messages/Experiments
- Open a
message_*.jsonfile. What exactly is persisted? - What happens when two people share
alice_session? That's the isolation problem AgentCore Memory solves in Phase 2.
- Open a
Check your work
Phase 1 has no automated test: you check it by running the task and looking for the result below.
After a restart, “What's my name?” comes back with Alice, without you re-introducing yourself. JSON message files appear under phase1/sessions/.
Under the hood
FileSessionManager hooks into the agent lifecycle: it restores messages when the agent is created and appends every new message as a JSON file. It's ideal for local work and useless for a fleet of containers, which is why Phase 2 swaps it for AgentCoreMemorySessionManager with almost the same call site.