adk-samples / cross-session-memory
AGENTS.md11k starsChanged 45 days agoApache-2.0View on GitHub
A clone-and-study ADK agent that remembers user preferences and facts across sessions using Vertex AI Memory Bank. The agent itself is a deliberately mundane demo (weather/time tools); the interesting part is the Memory Bank wiring — how memories are written after each turn (generate_memories_callback → add_session_to_memory()) and recalled at the start of a later session (PreloadMemoryTool), a single shared memory_bank_config that declares which topics to extract, and two deploy paths (Agent Engine and Cloud Run) that both enable Memory Bank…
- Reads credentials
1 other project uses a version of this.
Trending
More talk lately.about the whole repository
Most recently taken up by
- google/adk-recipesword for word, first seen Oct 13, 2026
Who's talking about google/adk-samples
- @stephanjanssen.be“Google just open sourced a Python Agent Development Kit @ github.com/google/adk-p... Native Streaming and …”Bluesky · Apr 9, 2025 · 12 likes
- google/adk-python“stream_query and HTTP Streaming to Vertex AI Agent Return Empty/Exhausted Responses (Works via ADK Web)”GitHub · Jul 8, 2025 · 5 reactions
- google/adk-recipes“Support running agents fully locally without Vertex AI (offline mode)”GitHub · Apr 14, 2025 · 4 reactions
- google/adk-recipes“[BUG]: Deployment of Data Science agent to Agent Engine fails ”GitHub · Oct 1, 2025 · 3 reactions
- A Hacker News story“CaMeL-Powered Secure Agent Demo with ADK”Hacker News · Aug 9, 2025 · 3 points
The biggest 5 of 32 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 32
Talked about on GitHub, Bluesky, Hacker News and Stack Overflow (32 times).
On GitHub · 23
- Jul 8, 2025stream_query and HTTP Streaming to Vertex AI Agent Return Empty/Exhausted Responses (Works via ADK Web) — google/adk-python5 reactions
- Apr 14, 2025Support running agents fully locally without Vertex AI (offline mode) — google/adk-recipes4 reactions · 7 comments
- Oct 1, 2025[BUG]: Deployment of Data Science agent to Agent Engine fails — google/adk-recipes3 reactions · 1 comment
- Oct 28, 2026docs: fix 5 broken internal anchor links and 1 dead external link — google-gemini/gemini-cli1 reaction · 4 comments
- Oct 20, 2026Update adk-samples references and python/agents discovery paths for google/adk-recipes restructure — google/agents-cli1 reaction · 2 comments
18 more on GitHub
- Oct 12, 2026list: scan the template dir we cloned, not the clone root — GoogleCloudPlatform/agent-starter-pack1 reaction
- Feb 12, 2026interrupted sometimes didn't work — google/adk-python1 reaction · 10 comments
- Jan 8, 2026Implement 5 ADK agent projects that can be easily run by newbies — addyosmani/adk-product-engineers1 reaction
- Nov 20, 2025[BUG]: deep-search/gemini-fullstack: Wrong prompt to access session state — google/adk-recipes1 reaction
- Jun 21, 2025unable to import StdioServerParameters — google/adk-recipes1 reaction · 2 comments
- Jun 17, 2025VertexAiRagRetrieval needs llama-index package — google/adk-recipes1 reaction · 3 comments
- Jun 5, 2025Bug: display_name in file uploads causes error with Google.GenAI backend (non-Vertex) — google/adk-python1 reaction · 6 comments
- May 18, 2025Missing Image — google/adk-recipes1 reaction
- Apr 11, 2025Duplicate key name — google/adk-recipes1 reaction · 1 comment
- Oct 18, 2026Fix(audit,#17387): Day4 Track2 tranche 1 -- Lab8/Lab9 reformulations honnetes, cures accents — jsboige/CoursIA0 reactions · 14 comments
- Sep 17, 2026Rename sample references to recipe across repository — google/adk-recipes0 reactions
- Sep 12, 2026docs(deep-search): fix cloud deployment instructions and scaffold path (#2575) — google/adk-recipes0 reactions · 4 comments
- Sep 12, 2026docs: fix 404 link to relocated Deep Search sample — google/adk-docs0 reactions · 1 comment
- Sep 9, 2026Add repo skills instructions and documentation links to AI issue response workflow — google/adk-recipes0 reactions
- Jul 24, 2026Fix broken adk-samples links from deleted sample agents and notebooks — google/adk-docs0 reactions · 1 comment
- Jun 12, 2026ci: run the spam-detection bot via the adk-samples reusable workflow — google/adk-go0 reactions · 1 comment
- May 27, 2026Add Deep Search Agent project to portfolio showcase — asafsilner/silner-showcase-prime0 reactions
- Feb 12, 2026fix: path typo in story teller example — google/adk-recipes0 reactions · 3 comments
On Bluesky · 4
- Apr 9, 2025Google just open sourced a Python Agent Development Kit @ github.com/google/adk-p... Native Streaming and #MCP support out of the box 👀… — @stephanjanssen.be12 likes and reposts
- Jul 12, 2026Exploring the ADK Samples repo from Google—it’s like a guidebook for building intelligent agents. Seeing multi-language support reflects… — @iam.slys.dev1 likes and repost
- Dec 9, 2025📦 google / adk-samples ⭐ 6,900 (+67) 🗒 Python A collection of sample agents built with Agent Development Kit (ADK) — @github-trending.bsky.social1 likes and repost
- May 20, 2025Explore practical use-cases & build! 🧪 Hands-on Patent Search Codelab: codelabs.developers.google.com/patent-searc... 📚 Check out sample… — @kweinmeister.bsky.social0 likes and reposts · 1 reply
On Hacker News · 3
- Aug 9, 2025CaMeL-Powered Secure Agent Demo with ADK3 points · 1 comment
- Jun 13, 2025A collection of sample agents built with Agent Development (ADK)2 points
- Aug 13, 2025CaMeL agent to protect against indirect prompt injection1 point · 1 comment
On Stack Overflow · 2
- Aug 30, 2025Google ADK SequentialAgent sub_agents not waiting for user input1 vote
- Aug 29, 2025Issue with deploying ADK Agent on Google Agent Engine0 votes
Other versions1 project uses a version of this.
Word for word · 1
- google/adk-recipes★ 11k100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository43 other files it gives its agents.
- AGENTS.mdAGENTS.md
- contrib/kotlin/llm-auditor/AGENTS.mdAGENTS.md
- core/python/adk-voice-agent/AGENTS.mdAGENTS.md
- core/python/adk-voice-agent/sandbox/home/AGENTS.mdAGENTS.md
- core/python/adk-voice-agent/tests/eval/fixtures/alex/repos/portland-trip/AGENTS.mdAGENTS.md
- core/python/ambient-expense-agent/AGENTS.mdAGENTS.md
- core/python/ambient-quality-agent/AGENTS.mdAGENTS.md
- core/python/deep-search/AGENTS.mdAGENTS.md
- core/python/genmedia-for-commerce/AGENTS.mdAGENTS.md
- core/python/long-horizon-harness/AGENTS.mdAGENTS.md
- core/python/oauth-user-consent-flow/AGENTS.mdAGENTS.md
- core/python/rag-agent-search/AGENTS.mdAGENTS.md
- core/python/rag-vector-search/AGENTS.mdAGENTS.md
- core/python/safety-plugins/AGENTS.mdAGENTS.md
- core/python/adk-voice-agent/sandbox/home/CLAUDE.mdCLAUDE.md
- core/python/genmedia-for-commerce/CLAUDE.mdCLAUDE.md
- align-recipe-pyprojectSkill
- extract-python-environment-variablesSkill
- generate-manifestSkill
- generate-python-runnability-testSkill
- github-pr-reviewSkill
- make-python-recipe-deployableSkill
- prepare-python-recipeSkill
- repo-oracleSkill
- scaffold-python-recipeSkill
- blog-writerSkill
- content-research-writerSkill
- approvalsSkill
- coding-workflowSkill
- connected-apps-mcpSkill
- deliverablesSkill
- filesystemSkill
- recommendationsSkill
- agents-cli-aquaSkill
- custom-investigationSkill
- rcaSkill
- bootstrap-google-toolsSkill
- find-skillsSkill
- google-workspaceSkill
- policySkill
- routinesSkill
- retail-product-searchSkill
- retail-virtual-tryonSkill
The file
We split this AGENTS.md into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 131
Write path: After each turn generate_memories_callback (after_agent_callback) calls callback_context.add_session_to_memory(), sending the …
- Very specific: line 140
Topics gate persistence: Only USER_PERSONAL_INFO / USER_PREFERENCES / EXPLICIT_INSTRUCTIONS (set in memory_config.py) are extracted.
- Very specific: line 203
The memory wiring is two lines in any ADK agent: add PreloadMemoryTool() to tools (recall) and …
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Cross-Session Memory — Vertex AI Memory Bank
Intent
A clone-and-study ADK agent that remembers user preferences and facts across
sessions using Vertex AI Memory Bank. The agent itself is a deliberately
mundane demo (weather/time tools); the interesting part is the Memory Bank
wiring — how memories are written after each turn
(generate_memories_callback → add_session_to_memory()) and recalled at
the start of a later session (PreloadMemoryTool), a single shared
memory_bank_config that declares which topics to extract, and two deploy
paths (Agent Engine and Cloud Run) that both enable Memory Bank via a
ReasoningEngineContextSpec.
When To Use
- The user wants an agent that persists user preferences/facts across sessions without building or maintaining a memory store — Memory Bank extracts and consolidates them for you.
- The user wants a worked example of ADK's memory hooks:
PreloadMemoryTool(automatic recall) plusafter_agent_callback/add_session_to_memory(automatic write). - The user needs the same agent code deployable to both Agent Engine (Agent Runtime) and Cloud Run, with Memory Bank enabled either way.
- The user wants to see how managed memory topics
(
USER_PERSONAL_INFO/USER_PREFERENCES/EXPLICIT_INSTRUCTIONS) are configured and passed to the platform.
Eval
- Scenarios Path: none — this recipe ships no eval datasets and no
agents-clieval config. Do not look fortests/eval/. - Tests live in
tests/:tests/test_runnability.py— import-time check thatroot_agentandappare defined (patchesgoogle.auth.defaultso it runs credential-less).tests/unit/test_dummy.py— pure logic tests forget_weather/get_current_time(no GCP, no LLM).tests/integration/test_agent.py—test_agent_has_memory_wiredis the only test that asserts the memory wiring (after_agent_callback == generate_memories_callbackand aPreloadMemoryToolintools);test_agent_streamruns the agent through aRunnerwith a mock LLM and anInMemoryMemoryService.tests/integration/test_agent_engine_app.py—register_feedbackonAgentEngineApp(external services mocked viaINTEGRATION_TEST).tests/integration/test_server_e2e.py— spins up the FastAPI server (USE_IN_MEMORY_SESSION=true, Gemini patched by_e2e_bootstrap) and hits/run_sse+/feedback.
- None of these prove cross-session recall end-to-end (they all mock the LLM
and use in-memory services). To add real eval, drop an
agents-cliconfig + datasets undertests/eval/(as the RAG recipes do) and wire it into theMakefile; a meaningful memory eval needs a live Memory Bank instance (--memory_service_uri=agentengine://…) and multi-session scenarios.
End-to-end flow
Session 1 (user tells the agent something)
user: "I live in Austin."
-> agent replies; after_agent_callback = generate_memories_callback
-> callback_context.add_session_to_memory() ships the turn's events to
VertexAiMemoryBankService
-> Memory Bank extracts + consolidates facts under the configured topics
(USER_PERSONAL_INFO / USER_PREFERENCES / EXPLICIT_INSTRUCTIONS)
Session 2 (a new session, later)
user: "What's the weather?"
-> PreloadMemoryTool queries Memory Bank at turn start and injects
"lives in Austin" into the system instruction
-> model answers for Austin without being remindedLocally the memory service is InMemoryMemoryService (nothing persists); the
real VertexAiMemoryBankService is used only when memory_service_uri points at
an agentengine:// instance (Cloud Run wires this automatically; adk web
needs the flag).
Most interesting files to study (in order)
Memory Bank config & deploy paths (the bulk of the logic)
app/app_utils/memory_config.py— the sharedmemory_bank_config, aReasoningEngineContextSpecMemoryBankConfigwhosecustomization_configsenable three managed topics:USER_PERSONAL_INFO,USER_PREFERENCES,EXPLICIT_INSTRUCTIONS(KEY_CONVERSATION_DETAILSis available but left off). This single object is the one place you declare what Memory Bank extracts, and it is consumed by both deploy paths. Custom topics are supported viaCustomMemoryTopic(label=..., description=...).app/app_utils/deploy.py— the Agent Engine deploy CLI (make deploy-agent-engineruns it). The memory-relevant part: it wrapsmemory_bank_configin aReasoningEngineContextSpecand passes it viacontext_specinAgentEngineConfig, so the created/updated Agent Engine has Memory Bank enabled. Aclickcommand that also handles create-or-update bydisplay_name, env vars/secrets, resource limits, and optional--agent-identityIAM setup.app/fast_api_app.py— the Cloud Run entry point and its memory-enabling path. On startup it finds an existing Agent Engine bydisplay_nameor creates one, passingmemory_bank_configvia the samecontext_spec; then sets bothsession_service_uriandmemory_service_urito the sameagentengine://<resource>URI and hands them toget_fast_api_app(). Settingmemory_service_uriis what makes ADK useVertexAiMemoryBankService(soPreloadMemoryTool+ the callback hit real Memory Bank).USE_IN_MEMORY_SESSION=truebypasses all of this for local dev.app/agent_engine_app.py— the Agent Engine runtime object (agent_engine), anAgentEngineApp(AdkApp)wrappingapp.agent.app. Adds telemetry/logging setup and aregister_feedbackoperation. This is the--entrypoint-objectthatdeploy.pydeploys; note it does not re-declare Memory Bank — the config is applied at instance-creation time bydeploy.py.
Support
app/app_utils/telemetry.py—setup_telemetry(): OpenTelemetry / GenAI telemetry, optional prompt/response upload to GCS (LOGS_BUCKET_NAME, forced toNO_CONTENTmetadata-only mode). No memory logic.app/app_utils/typing.py— PydanticRequest/Feedbackmodels used by the FastAPI/feedbackendpoint andregister_feedback.
Agent (thin layer — read last)
app/agent.py— the actual agent, deliberately generic (get_weather/get_current_timedemo tools). The two lines that matter:PreloadMemoryTool()intools(recall — injects memories into the system instruction at turn start) andafter_agent_callback=generate_memories_callback(write —callback_context.add_session_to_memory()ships the turn's events to Memory Bank). Model comes from theMODEL_NAMEenv var; exportsapp = App(root_agent=root_agent, name="app").app/__init__.pybootstraps env (load_dotenv, ADC project discovery, defaultGOOGLE_CLOUD_LOCATION=global,GOOGLE_GENAI_USE_VERTEXAI=True).
Data handling
- No datastore of your own. Memory Bank (a managed Vertex AI service living on an Agent Engine instance) stores and consolidates memories. The only inputs are conversation events.
- Write path. After each turn
generate_memories_callback(after_agent_callback) callscallback_context.add_session_to_memory(), sending the session's events toVertexAiMemoryBankService, which extracts facts under the configured topics. (Alternative:add_events_to_memory(events=...)to send only a subset for incremental processing.) - Recall path.
PreloadMemoryToolqueries Memory Bank at the start of each turn and injects matching memories into the system instruction — no explicit tool call. (Alternative:LoadMemoryToolfor on-demand recall.) - Topics gate persistence. Only
USER_PERSONAL_INFO/USER_PREFERENCES/EXPLICIT_INSTRUCTIONS(set inmemory_config.py) are extracted; anything outside those topics is not persisted. - Local vs deployed. Locally ADK uses
InMemoryMemoryService(nothing persists across restarts). Real Memory Bank is used only whenmemory_service_uri=agentengine://…— Cloud Run wires this automatically;adk webneeds the flag. - Consolidation is asynchronous. Memories are extracted/consolidated after the turn, so a fact told in session 1 shows up in a later session, not necessarily instantly within the same one.
Gotchas / things to know
- Cloud Run still needs an Agent Engine. Even the "container" path finds or creates an Agent Engine instance for session + memory storage and points both service URIs at it — Memory Bank always lives on Agent Engine.
- Both deploy paths enable Memory Bank the same way: wrap
memory_bank_configinReasoningEngineContextSpec→context_spec. The two paths differ on updates:deploy.py(Agent Engine) re-appliescontext_specviaagent_engines.update(...), but the Cloud Run path (fast_api_app.py) matches an existing engine bydisplay_nameand reuses it as-is — a pre-existing engine there will not pick upmemory_bank_configchanges. - Local memory is in-memory only.
make playgroundusesInMemoryMemoryService; memories vanish on restart. To exercise real Memory Bank locally:uv run adk web . --port 8501 --memory_service_uri=agentengine://<RESOURCE_NAME>. app/__init__.pydefaultsGOOGLE_CLOUD_LOCATION=global, but Agent Engine / Memory Bank need a real region —deploy.pyandfast_api_app.pydefault tous-west1, anddeploy-cloud-runhard-codesus-west1. Keep them consistent.- Model comes from the
MODEL_NAMEenv var..env.examplesetsgemini-3.5-flash; the e2e test/stubs default togemini-3.5-flash. SetMODEL_NAMEexplicitly (repo policy: usegemini-3.5-flash, not the deprecated 2.x models). INTEGRATION_TEST=TRUEmocks external services (Cloud Logging, artifacts) so tests run credential-less;test_server_e2e.pyalso setsUSE_IN_MEMORY_SESSION=trueand patches Gemini via_e2e_bootstrap.- Only one automated test asserts the memory wiring
(
test_agent_has_memory_wired); every other test mocks the LLM and uses in-memory services, so cross-session recall is not covered end-to-end.
Where to run things
Makefile targets:
make install—uv sync(installsuvfirst if missing).make playground— local ADK web UI on port8501(usesInMemoryMemoryService; select theappfolder).make local-server— run the Cloud Run entry point (app.fast_api_app:app) locally with hot-reload viauvicorn(PORToverridable).make deploy-agent-engine— deploy to Agent Engine viaapp/app_utils/deploy.py(AGENT_IDENTITY=true,SECRETS="KEY=SECRET_ID,…"optional).make deploy-cloud-run—gcloud beta run deploy memory-bank-sample(regionus-west1;IAP=true,PORT=…optional).make test—uv run pytest tests/unitthentests/integration.make lint—codespell+ruff check+ruff format --check+ty check.
Reuse (copy as-is)
app/app_utils/memory_config.pyis the reusable core. Self-contained (onlyvertexai._genai.types) — copy it to declare which managed/custom topics Memory Bank should extract; both deploy paths consume it unchanged.- The memory wiring is two lines in any ADK agent: add
PreloadMemoryTool()totools(recall) andafter_agent_callback=generate_memories_callback(write, viaadd_session_to_memory()). There is no coupling to the demoget_weather/get_current_timetools. - The deploy entrypoints are drop-in:
app/agent_engine_app.py+app/app_utils/deploy.py(Agent Engine) andapp/fast_api_app.py(Cloud Run) each readmemory_bank_configand enable Memory Bank viaReasoningEngineContextSpec/context_spec— copy whichever target you need. app/app_utils/telemetry.pyandtyping.pyare generic (OpenTelemetry setup + PydanticFeedback/Requestmodels) and carry no memory logic — reuse independently.- Dependencies:
google-adkplusgoogle-cloud-aiplatform[agent-engines](Memory Bank types live undervertexai._genai.types);fastapi/uvicornare needed only for the Cloud Run path.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

