docs(memory): use public preload_memory tool API in examples#1804
Open
garyzava wants to merge 1 commit into
Open
docs(memory): use public preload_memory tool API in examples#1804garyzava wants to merge 1 commit into
garyzava wants to merge 1 commit into
Conversation
The memory docs and the express-mode weather agent notebook referenced `adk.tools.preload_memory_tool.PreloadMemoryTool()`, which raises `AttributeError: module 'google.adk.tools' has no attribute 'preload_memory_tool'` because the submodule is not exposed via the package's lazy `__getattr__`. Use the documented public API `from google.adk.tools import preload_memory` and pass the `preload_memory` instance directly, consistent with how the sibling `load_memory` tool is shown in the same page. Fixes google#1771
✅ Deploy Preview for adk-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Memory docs and the express-mode weather agent notebook show the preload
tool as
adk.tools.preload_memory_tool.PreloadMemoryTool(). Copy-pasting thatthrows
AttributeError: module 'google.adk.tools' has no attribute 'preload_memory_tool'. This PR changes the Python examples to the public API,from google.adk.tools import preload_memory, which is also howload_memoryis shown on the same page.
Fixes #1771
What changed
docs/sessions/memory.md- both Python tabs now importpreload_memoryandpass the
preload_memoryinstance intools=[...].examples/python/notebooks/express-mode-weather-agent.ipynb- same fix in theimport cell and the agent definition.
Go, Java, Kotlin and TypeScript tabs are left as-is.
Why
google.adk.toolsexports the tool through a lazy__getattr__as the instancepreload_memory(from .preload_memory_tool import preload_memory_tool as preload_memory). Thepreload_memory_toolsubmodule isn't an attribute of thepackage, so the documented
adk.tools.preload_memory_tool.PreloadMemoryTool()fails. Using
preload_memorydirectly matches the existingload_memoryexample (
from google.adk.tools import load_memory->tools=[load_memory]).How I tested
Checked against
google-adk==2.1.0:mkdocs buildpasses, and the renderedsessions/memory/page now only showspreload_memory.Backward compatibility
Docs/examples only.
from google.adk.tools.preload_memory_tool import PreloadMemoryToolstill works; this just documents the supported public form.No code changes.