You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Framework examples (adk/langgraph/openai) crash with SpawnSafetyError — tool functions defined inside main() instead of module level #443
Several framework example files fail immediately with SpawnSafetyError because they define their tool callables inside main() (local/nested functions). The SDK's spawn-safety probe requires tools to be importable by qualified name, and its own error message states the fix. This is an examples defect — the tools should be defined at module level.
Environment
conductor-oss/python-sdk @ main (also repros on the released conductor-agent-sdk)
conductor-oss server 3.32.0-rc.10, model anthropic/claude-sonnet-4-6, macOS
AttributeError: Can't get local object 'main.<locals>.lookup_customer'
...
conductor.ai.agents.runtime._worker_entries.SpawnSafetyError: worker 'lookup_customer'
is not spawn-safe (AttributeError("Can't get local object 'main.<locals>.lookup_customer'")).
Define the callable at module level (importable by qualified name).
Cause
The tool functions are declared inside main(), so they can't be pickled/imported by worker processes → the SDK's probe_spawn_safety (intentionally) rejects them. The SDK behavior is correct and even prints the remedy: "Define the callable at module level." Passing examples already define tools at module scope.
Move each example's @tool/tool functions from inside main() to module level so they're importable by qualified name (matching the pattern used by the examples that run successfully).
Worth reading before fixing this one: #448 hits the same transport code through a different trigger.
There the tool is already defined at module level and it still fails, with PicklingError: ... it's not the same object as __main__.get_inventory rather than AttributeError: Can't get local object.
That matters for the fix here. Moving the example tools out of main() will make these examples pass, but any OpenAI @function_tool at module level still fails. @function_tool rebinds the module global to a FunctionTool, and _CONTAINER_ATTRS only unwraps .func and .coroutine, so the container hop that covers LangChain does not cover OpenAI.
#448 also has a Linux reproduction, which shows this is not platform-specific, and a suggested by-value transport with cloudpickle that would cover both cases.
Activity
nickorkes commentedon Jul 26, 2026
Worth reading before fixing this one: #448 hits the same transport code through a different trigger.
There the tool is already defined at module level and it still fails, with
PicklingError: ... it's not the same object as __main__.get_inventoryrather thanAttributeError: Can't get local object.That matters for the fix here. Moving the example tools out of
main()will make these examples pass, but any OpenAI@function_toolat module level still fails.@function_toolrebinds the module global to aFunctionTool, and_CONTAINER_ATTRSonly unwraps.funcand.coroutine, so the container hop that covers LangChain does not cover OpenAI.#448 also has a Linux reproduction, which shows this is not platform-specific, and a suggested by-value transport with cloudpickle that would cover both cases.
deeptireddy-lab commentedon Jul 26, 2026
correct for openai it has nothing to so with the module level. for langgraph and adk, it does.
kowser-orkes commentedon Jul 28, 2026
Example fix are on this PR: #449