Skip to content

Fix 7 Google ADK examples that crash with SpawnSafetyError - #449

Merged
kowser-orkes merged 1 commit into
mainfrom
fix/google-adk-spawn-safety
Jul 28, 2026
Merged

Fix 7 Google ADK examples that crash with SpawnSafetyError#449
kowser-orkes merged 1 commit into
mainfrom
fix/google-adk-spawn-safety

Conversation

@kowser-orkes

Copy link
Copy Markdown
Contributor

Pull Request type

  • Bugfix
  • Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • WHOSUSING.md
  • Other (please describe):

NOTE: Please remember to run poetry run ruff format && poetry run ruff check --fix to fix
any format violations.

Changes in this PR

  • examples/agents/adk/14_callbacks.py-20_blog_writer.py (7 files) defined tool functions as
    closures nested inside main() — raises SpawnSafetyError at registration, since spawn
    can't pickle a function with qualname main.<locals>.fn.
  • Fix: hoisted the tool defs to module level, matching every other example. No behavior change.
  • Standard Python multiprocessing limitation, not an SDK or ADK bug — docs/WORKER.md states
    the same rule for @worker_task workers.

Issue #443

Alternatives considered

  • SDK-side workaround (cloudpickle, or fork instead of spawn) — rejected, fork is unsafe
    on macOS (native-framework SIGSEGV), which is why spawn is the default.
  • Leave examples non-runnable, document instead of fix — rejected, every other example runs.

Tools were defined as functions nested inside main(), which are never
picklable under the SDK's default spawn start method. Hoisting them to
module scope makes them importable by qualified name, matching every
other example and satisfying probe_spawn_safety.
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 60 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kowser-orkes
kowser-orkes merged commit ed110cd into main Jul 28, 2026
7 checks passed
@kowser-orkes
kowser-orkes deleted the fix/google-adk-spawn-safety branch July 28, 2026 19: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.

2 participants