Skip to content

docs: make process_document async and await artifact and memory calls in tool example - #2083

Open
Syed-Umer-Ali wants to merge 8 commits into
google:mainfrom
Syed-Umer-Ali:docs/fix-doc-analysis-await
Open

docs: make process_document async and await artifact and memory calls in tool example#2083
Syed-Umer-Ali wants to merge 8 commits into
google:mainfrom
Syed-Umer-Ali:docs/fix-doc-analysis-await

Conversation

@Syed-Umer-Ali

Copy link
Copy Markdown
Contributor

What

The example tool process_document is a sync def but calls await tool_context.save_artifact(...), which is a SyntaxError. Additionally load_artifact() and search_memory() return coroutines that were never awaited.

Why

ToolContext.save_artifact, ToolContext.load_artifact, and ToolContext.search_memory are all async methods (verified via inspect.iscoroutinefunction). Running the file as written raises SyntaxError: 'await' outside async function. The example is embedded in docs/tools-custom/index.md, so the rendered docs contain the same broken code. FunctionTool supports async callables (see function_tool.py which detects coroutine functions), so making the function async is valid.

Fix

  • Changed def process_document to async def process_document
  • Added await to load_artifact, search_memory, and save_artifact calls

Verification

python -m py_compile passes on the file.

@netlify

netlify Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploy Preview for adk-docs-preview ready!

Name Link
🔨 Latest commit 4e0e201
🔍 Latest deploy log https://app.netlify.com/projects/adk-docs-preview/deploys/6a74bd4275ee23000810c5b6
😎 Deploy Preview https://deploy-preview-2083--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.

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.

1 participant