docs(examples): fix unrunnable Python snippets included by the docs - #2030
Open
GWeale wants to merge 1 commit into
Open
docs(examples): fix unrunnable Python snippets included by the docs#2030GWeale wants to merge 1 commit into
GWeale wants to merge 1 commit into
Conversation
✅ 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.
The
examples/python/**snippets are pulled into the docs with--8<--, so abroken snippet renders as broken documentation. 14 of them did not run, and one
did not even parse.
Verified against
google/adk-python@ main by importing and introspecting everysymbol, not by reading. Compile sweep over
examples/python/**: 50/64 filesparsed before, 64/64 after.
What was wrong
tools/overview/doc_analysis.py—awaitinside a plaindef, so the wholefile was a
SyntaxError;load_artifactandsearch_memoryare coroutinesand were not awaited;
MemoryEntry.eventsdoes not exist (the field iscontent).tools/overview/customer_support_agent.py—sub_agentsassigned afterconstruction, which skips
model_post_init's parent linking, soparent_agentstayedNone.tools/auth/agent_cli.py,tools/built-in-tools/agent_search.py—create_sessionis a coroutine and was not awaited, so the run raisedSessionNotFoundError.tools/auth/tools_and_agent.py—tools=toolset.get_tools()passed acoroutine, raising
TypeError: 'coroutine' object is not iterable.tools/auth/helpers.py— read the function-call argauth_config, but ADKserialises with
by_alias=True, so the key isauthConfig; the helper alwaysraised.
tools/built-in-tools/{spanner,bigtable}.py— sync wrappers returned anun-awaited coroutine from
execute_sql.tools/built-in-tools/agent_search.py—grounding_attributionsdoes notexist on
types.GroundingMetadata.callbacks/{before,after}_agent_callback.py—event.is_error()andevent.error_detailshave never been part of theEventAPI.callbacks/after_agent_callback.py— comments said the callback replacesthe agent's output; it appends a new event.
callbacks/after_tool_callback.py— comments saidtool_responseis{"result": <value>}; the callback receives the raw return value.Also in this PR
await; the driver is wrapped inasync def main()underif __name__ == "__main__", matching the pattern already used in eachdirectory.
event.content.parts[0].textdereferences underis_final_response()now carry the guard already used elsewhere in this repo.is_final_response()never inspectscontent, so the unguarded form crasheson safety-blocked turns, state-only events and grounding-only responses.
tutorial/agent_team/adk_tutorial.ipynb— the same four defects corrected indocs/tutorials/agent-team.md, so the notebook and the page agree.