Fix two examples that break under the spawn start method - #472
Closed
ling-senpeng13 wants to merge 2 commits into
Closed
Fix two examples that break under the spawn start method#472ling-senpeng13 wants to merge 2 commits into
ling-senpeng13 wants to merge 2 commits into
Conversation
check_github_auth was defined inside create_adk_agent(), so worker
registration failed before any workflow started:
SpawnSafetyError: worker 'check_github_auth' is not spawn-safe
(AttributeError("Can't get local object
'create_adk_agent.<locals>.check_github_auth'"))
Worker processes are started with the default spawn method, which re-imports
the callable by qualified name; a closure cannot be pickled that way. Moved
it to module level. Same class as #450/#451.
Also replaces the hardcoded model="gemini-2.5-flash" with settings.llm_model:
it routed to Vertex AI (no Google credentials configured), contradicted the
file's own docstring, and every sibling framework example already reads
settings.llm_model.
Verified on openai/gpt-4o-mini and anthropic/claude-sonnet-4-5 — the answer
quotes the ghp_... prefix from the tool's return value, so the worker
registered, executed, and received its injected credential.
ling-senpeng13
force-pushed
the
fix/16k-adk-spawn-safe-tool
branch
from
August 12, 2026 21:16
2293558 to
bca4e35
Compare
Worker processes are launched with the default spawn start method, which re-imports the module in a fresh interpreter. A module-level _start_mock_server() therefore tries to bind 127.0.0.1:9753 again in every worker. The example hung indefinitely (>6m40s with no output past its header). Verified: now completes with the correct answer — 2**100 = 1267650600228229401496703205376, Tool calls: 1, FinishReason.STOP — so the code round-trips through the mock serverless endpoint. Same spawn-safety class as the 16k closure fix in this PR. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
patch to #477 |
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.
Worker processes are launched with the default
spawnstart method, which re-imports the module in a fresh interpreter. Two examples relied on state that only survivesfork:16k —
check_github_authwas a closure insidecreate_adk_agent(), so a worker could not be pickled by qualified name and registration failed before any workflow started:Moved to module level. Verified: tool task COMPLETED with
{"result": "GitHub token is set (starts with ghp_...)"}, so the worker registered, executed, and received its injected credential. NeedsCONDUCTOR_SECRET_GITHUB_TOKENin the server env.39c —
_start_mock_server(port=9753)ran at module level, so every worker re-bound the port. The example hung indefinitely (>6m40s with no output past its header). Moved inside__main__. Verified: now completes with2**100 = 1267650600228229401496703205376,Tool calls: 1,FinishReason.STOP.Same class as #450/#451.
Also replaces 16k's hardcoded
model="gemini-2.5-flash"withsettings.llm_model: it routed to Vertex AI (no Google credentials), contradicted the file's own docstring, and every sibling framework example already readssettings.llm_model.