omarcevi.dev / workshops / deploy-agents / 3 · Remember

Step 3 · Remember

6 min

In this step, you tell the agent about yourself one time. Then the agent uses this information in later conversations, and it does not ask again.

checkpoint branch step-3-remember

How it works

Sessions compared with Memory Bank during one week. Monday, session A: the employee says that they are on the platform team in the Istanbul office and like Fridays off. Each session contains one conversation. A new session does not see the old one. Memory Bank keeps data for each app and user. (1) It extracts two facts from the Monday turn: team_and_office and work_preferences. (2) On Wednesday, session B recalls the facts at the start of the turn and answers the leave question with Istanbul rules. (3) On Friday, session C uses the office and team to book next Friday. It also tells the employee about the on-call swap.
A session is one conversation. Memory Bank keeps facts about one user for all sessions.

Sessions contain the events and state of one conversation. Agent Runtime stores them for you, and the agent uses VertexAiSessionService. A new session starts empty.

Memory Bank contains facts about a user, for each app and user id. After each turn, a plugin sends the turn to Memory Bank. Memory Bank uses an LLM to extract facts on the topics that you allow. Then it merges these facts with the facts that it has. At the start of the next turn, PreloadMemoryTool searches the facts with the new message. It adds the matches to the instructions of the model.

app/memory.pythe save side
1class MemoryBankPlugin(BasePlugin):2    async def after_run_callback(self, *, invocation_context):3        events = [e for e in session.events if e.invocation_id == invocation_context.invocation_id]4        await memory.add_events_to_memory(..., events=events,5            custom_metadata={"wait_for_completion": False})
A plugin runs after each turn, for all agents. The extraction runs in Memory Bank, not in your container.

You choose the facts that Memory Bank keeps. infra/memory/memory-bank.json limits the extraction to two topics, team_and_office and work_preferences, and to explicit instructions. In step 2, grant_agent_access.sh applied this file.

Run

Monday (session A). Each agents-cli run starts a new session.

agents-cli run --url "$AGENT_URL" --mode adk \
  "Hi! I'm on the platform team in the Istanbul office, and I prefer to take Fridays off."

Memory Bank extracts facts in the background, usually in one to two minutes. See the facts that it stored:

uv run python scripts/memory_bank.py list

Wednesday and Friday (new sessions; you do not give the context again):

agents-cli run --url "$AGENT_URL" --mode adk "How many leave days do I have?"
agents-cli run --url "$AGENT_URL" --mode adk "Book next Friday off."

Optional: in the console, open Deployments → workplace-assistant → Sessions and Memories. These tabs show the two stores.

Expected result

$ uv run python scripts/memory_bank.py list - I work on the platform team in the Istanbul office. [team_and_office] - I prefer to take Fridays off. [work_preferences] [leave_agent]: I have submitted your leave request for Friday, 30 October 2026 (1 day). It is pending approval by your team lead, Ayşe Demir (LV-1103). Reminder for Platform team members: if you are on call that day, arrange a swap before your team lead approves it [01-leave-policy.md#platform-team-on-call].

The on-call reminder comes from the memory. The Friday session did not say that you are on the platform team.

Check

./scripts/check.sh 3
- I work on the platform team in the Istanbul office. [team_and_office] ✔ remembers the team ✔ remembers the office ==> Step 3 checks passed.
If this fails
No memories yet for user 'cli-user'
The extraction is asynchronous. Wait one minute. Then list the memories again. If no memories appear after three minutes, send the Monday message again.
Memories exist, but the agent does not use them
The agent recalls memories at the start of a turn, and it matches them with the message. Ask a related question (“book leave”, “my office”).
Different user
Memory Bank keeps memories for each user id. agents-cli run always uses cli-user. With scripts/ask.py --user you@example.com, you can choose the user. Then use the same user with memory_bank.py list --user.
Start again
uv run python scripts/memory_bank.py clear deletes the memories of cli-user.