Skip to content

Fix Python snippets in the docs that do not parse - #2347

Open
AAliKKhan wants to merge 1 commit into
google:mainfrom
AAliKKhan:fix/invalid-python-snippets
Open

AAliKKhan wants to merge 1 commit into
google:mainfrom
AAliKKhan:fix/invalid-python-snippets

Conversation

@AAliKKhan

Copy link
Copy Markdown
Contributor

What

Two documented Python examples raise SyntaxError if a reader copies them.

File Line Change
docs/sessions/memory.md 412 ... -> ..., (missing comma in a call)
docs/tutorials/multi-tool-agent.md 448 bare ... -> closing ) for the unclosed Agent( call

Why

docs/sessions/memory.md

runner = adk.Runner(
    ...
    memory_service=memory_service
)

Two arguments with no separating comma:

SyntaxError: invalid syntax. Perhaps you forgot a comma?  (line 11, on "...")

Adding the trailing comma matches the shape used by the other Runner and
service snippets on the same page.

docs/tutorials/multi-tool-agent.md

root_agent = Agent(
    name="weather_time_agent",
    model="replace-me-with-model-id", #e.g. gemini-live-2.5-flash-native-audio
    ...

Two errors at once: '(' was never closed, and - once you close it -
positional argument follows keyword argument, because ... is a positional
expression placed after keyword arguments. The surrounding text is "Your code
should look something like", so the statement is simply closed after the model
argument rather than trying to keep an ellipsis that Python rejects there.

Verification

Every Python fence on both pages is extracted, textwrap.dedent-ed and passed
through ast.parse(): all pass after the change (the two above are the only
failures before it).

mkdocs build --strict passes.

@netlify

netlify Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for adk-docs-preview ready!

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

Two documented examples raise SyntaxError if a reader copies them.

docs/sessions/memory.md: the Runner(...) call spreads "..." and then
sets memory_service= with no separating comma ("Perhaps you forgot a
comma"). Add the trailing comma, which also matches the pattern used by
the other snippets on the page.

docs/tutorials/multi-tool-agent.md: the Agent( call is never closed and
ends with a bare "..." placed after keyword arguments, so Python reports
both "'(' was never closed" and "positional argument follows keyword
argument". Close the call after the model argument; the surrounding text
("Your code should look something like") does not rely on the
placeholder.

Every Python fence on both pages now passes ast.parse.
@AAliKKhan
AAliKKhan force-pushed the fix/invalid-python-snippets branch from a26a512 to 0e469f4 Compare October 19, 2026 11:51

This branch has not been deployed

No deployments
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