Task 3 · 8 tasks

File sessions

Persist the conversation to disk so the agent still knows Alice after a restart.

15 minEasy
Alice’s ask

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.

You

Build it

  1. Make the conversation survive a restart

    Challenge

    Give the Task 2 agent a session that is saved under SESSIONS_DIR with the id alice_session.

    Work in phase1/starter/t3_sessions.py (look for TODO; an unfinished one prints [starter] TODO …) and run it with uv run bootcamp.py phase1 t3 --starter. The reference solution is phase1/t3_sessions.py; uv run bootcamp.py phase1 t3 runs 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 only
    session_manager = FileSessionManager(session_id=..., storage_dir=str(SESSIONS_DIR))
    Solution
    phase1/t3_sessions.py
    session_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)
  2. Introduce yourself, then restart

    terminal · your starter file
    uv 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 solution
    uv 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:

    terminal
    ls phase1/sessions/session_alice_session/agents/agent_default/messages/
  3. Experiments

    • Open a message_*.json file. What exactly is persisted?
    • What happens when two people share alice_session? That's the isolation problem AgentCore Memory solves in Phase 2.

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.