Fix claude-code agent registration crash under spawn - #450
Merged
Conversation
…g spawn-safe passthrough builder - both is_claude_code branches in _register_workers built the tool_worker closure eagerly via make_claude_agent_sdk_worker, passed straight to _register_passthrough_worker for pickling - that closure is local to make_claude_agent_sdk_worker's frame, never picklable by reference -> SpawnSafetyError/PicklingError under the default spawn start method, for every claude-code agent (top-level or nested sub-agent) - _build_passthrough_func already builds a picklable PassthroughWorkerEntry for "claude_agent_sdk" -- just never called from these two sites; route both through it instead of hand-rolling the closure - adds TestClaudeCodeAgentRegistration (4 tests): entry-type assertions + regression tests confirming no SpawnSafetyError under the real chain
Agent(model='claude-code/...') registration crash under spawn
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 59 files with indirect coverage changes 🚀 New features to boost your workflow:
|
bradyyie
approved these changes
Jul 28, 2026
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.
Pull Request type
Changes in this PR
Both
is_claude_codebranches in_register_workers(runtime.py) built thetool_workerclosure eagerly in the parent process viamake_claude_agent_sdk_worker, then passed it straight to_register_passthrough_workerfor pickling. That closure is local tomake_claude_agent_sdk_worker's own frame and is never picklable byreference, so registration raised
SpawnSafetyError/PicklingErrorunderthe SDK's default
spawnstart method for everyclaude-codeagent — bothtop-level and nested as a sub-agent.
_build_passthrough_funcalready builds a picklablePassthroughWorkerEntryfor this exact framework (
"claude_agent_sdk") — it just wasn't called fromeither of these two sites. This PR routes both through it instead of
hand-rolling the closure.
Adds
TestClaudeCodeAgentRegistration(4 tests): two assert the entry handedto
_register_passthrough_workeris aPassthroughWorkerEntry, two areregression tests confirming no
SpawnSafetyErrorunder the realregistration chain (confirmed to fail pre-fix with the original traceback).
Issue #
Alternatives considered
Patch
make_claude_agent_sdk_worker's closure to be picklable directly —rejected because
_build_passthrough_funcalready solves this genericallyfor the framework, and duplicating that logic at the two call sites would
drift from it over time.