Skip to content

Fix claude-code agent registration crash under spawn - #450

Merged
kowser-orkes merged 1 commit into
mainfrom
fix/claude-code-agent-spawn-safety
Jul 28, 2026
Merged

Fix claude-code agent registration crash under spawn#450
kowser-orkes merged 1 commit into
mainfrom
fix/claude-code-agent-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):

Changes in this PR

Both is_claude_code branches in _register_workers (runtime.py) built the
tool_worker closure eagerly in the parent process via
make_claude_agent_sdk_worker, then passed it straight to
_register_passthrough_worker for pickling. That closure is local to
make_claude_agent_sdk_worker's own frame and is never picklable by
reference, so registration raised SpawnSafetyError/PicklingError under
the SDK's default spawn start method for every claude-code agent — both
top-level and nested as a sub-agent.

_build_passthrough_func already builds a picklable PassthroughWorkerEntry
for this exact framework ("claude_agent_sdk") — it just wasn't called from
either of these two sites. This PR routes both through it instead of
hand-rolling the closure.

Adds TestClaudeCodeAgentRegistration (4 tests): two assert the entry handed
to _register_passthrough_worker is a PassthroughWorkerEntry, two are
regression tests confirming no SpawnSafetyError under the real
registration 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_func already solves this generically
for the framework, and duplicating that logic at the two call sites would
drift from it over time.

…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
@kowser-orkes kowser-orkes changed the title Fix Agent(model='claude-code/...') registration crash under spawn Fix claude-code agent registration crash under spawn Jul 28, 2026
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/conductor/ai/agents/runtime/runtime.py 50.48% <100.00%> (+0.45%) ⬆️

... and 59 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 requested review from bradyyie and v1r3n July 28, 2026 18:17
@kowser-orkes
kowser-orkes merged commit 8d8fce3 into main Jul 28, 2026
11 of 12 checks passed
@kowser-orkes
kowser-orkes deleted the fix/claude-code-agent-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