Skip to content

Fix two examples that break under the spawn start method - #472

Closed
ling-senpeng13 wants to merge 2 commits into
mainfrom
fix/16k-adk-spawn-safe-tool
Closed

Fix two examples that break under the spawn start method#472
ling-senpeng13 wants to merge 2 commits into
mainfrom
fix/16k-adk-spawn-safe-tool

Conversation

@ling-senpeng13

@ling-senpeng13 ling-senpeng13 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Worker processes are launched with the default spawn start method, which re-imports the module in a fresh interpreter. Two examples relied on state that only survives fork:

16kcheck_github_auth was a closure inside create_adk_agent(), so a worker could not be pickled by qualified name and 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'"))

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. Needs CONDUCTOR_SECRET_GITHUB_TOKEN in 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 with 2**100 = 1267650600228229401496703205376, Tool calls: 1, FinishReason.STOP.

Same class as #450/#451.

Also replaces 16k's hardcoded model="gemini-2.5-flash" with settings.llm_model: it routed to Vertex AI (no Google credentials), contradicted the file's own docstring, and every sibling framework example already reads settings.llm_model.

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
ling-senpeng13 force-pushed the fix/16k-adk-spawn-safe-tool branch from 2293558 to bca4e35 Compare August 12, 2026 21:16
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>
@ling-senpeng13 ling-senpeng13 changed the title Fix 16k ADK credentials example: tool not spawn-safe Fix two examples that break under the spawn start method Aug 13, 2026
@ling-senpeng13

Copy link
Copy Markdown
Contributor Author

patch to #477

@ling-senpeng13
ling-senpeng13 deleted the fix/16k-adk-spawn-safe-tool branch August 13, 2026 03:08
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