Skip to content

docs(memory): use public preload_memory tool API in examples#1804

Open
garyzava wants to merge 2 commits into
google:mainfrom
garyzava:fix/preload-memory-tool-docs
Open

docs(memory): use public preload_memory tool API in examples#1804
garyzava wants to merge 2 commits into
google:mainfrom
garyzava:fix/preload-memory-tool-docs

Conversation

@garyzava

Copy link
Copy Markdown

Summary

The Memory docs and the express-mode weather agent notebook show the preload
tool as adk.tools.preload_memory_tool.PreloadMemoryTool(). Copy-pasting that
throws 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 how load_memory
is shown on the same page.

Fixes #1771

What changed

  • docs/sessions/memory.md - both Python tabs now import preload_memory and
    pass the preload_memory instance in tools=[...].
  • examples/python/notebooks/express-mode-weather-agent.ipynb - same fix in the
    import cell and the agent definition.

Go, Java, Kotlin and TypeScript tabs are left as-is.

Why

google.adk.tools exports the tool through a lazy __getattr__ as the instance
preload_memory (from .preload_memory_tool import preload_memory_tool as preload_memory). The preload_memory_tool submodule isn't an attribute of the
package, so the documented adk.tools.preload_memory_tool.PreloadMemoryTool()
fails. Using preload_memory directly matches the existing load_memory
example (from google.adk.tools import load_memory -> tools=[load_memory]).

How I tested

Checked against google-adk==2.1.0:

# new form (what this PR documents) works:
>>> from google.adk.tools import preload_memory
>>> type(preload_memory).__name__, preload_memory.name
('PreloadMemoryTool', 'preload_memory')

# old documented form raises the error from #1771:
>>> from google import adk
>>> adk.tools.preload_memory_tool.PreloadMemoryTool()
AttributeError: module 'google.adk.tools' has no attribute 'preload_memory_tool'.
                Did you mean: 'preload_memory'?

mkdocs build passes, and the rendered sessions/memory/ page now only shows
preload_memory.

Backward compatibility

Docs/examples only. from google.adk.tools.preload_memory_tool import PreloadMemoryTool still works; this just documents the supported public form.
No code changes.

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
@netlify

netlify Bot commented May 30, 2026

Copy link
Copy Markdown

Deploy Preview for adk-docs-preview ready!

Name Link
🔨 Latest commit 6e770c5
🔍 Latest deploy log https://app.netlify.com/projects/adk-docs-preview/deploys/6a2ca30d8b4b4a0008b1965c
😎 Deploy Preview https://deploy-preview-1804--adk-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@garyzava

Copy link
Copy Markdown
Author

Friendly bump — this fixes the AttributeError reported in #1771 (the memory docs and the express-mode notebook reference adk.tools.preload_memory_tool.PreloadMemoryTool(), which isn't exported; the public API is from google.adk.tools import preload_memory, matching load_memory). I've just synced the branch with main; the Netlify preview builds clean. Happy to adjust if anything's needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: module 'google.adk.tools' has no attribute 'preload_memory_tool'

1 participant