Fix openai @function_tool tools crashing under default spawn start method - #451
Merged
Merged
Conversation
added 2 commits
July 28, 2026 11:14
- FunctionTool has no .func/.coroutine/__wrapped__ (unlike langchain's StructuredTool, e714961) — FunctionRef.of fell back to unsafe fn_direct, crashing the registration-time pickle probe. - Relocates _find_embedded_function from serializer.py into _worker_entries.py, alongside _extract_from_closure (prior commit) — one shared walk for parent-side discovery and FunctionRef's verification/reconstruction, can't drift apart. - No __wrapped__ fallback needed on the deep-extract match (unlike _CONTAINER_ATTRS): fn is always _find_embedded_function's own prior return value, so identity always matches.
Codecov Report❌ Patch coverage is
... and 58 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
NOTE: Please remember to run
./gradlew spotlessApplyto fix any format violations.Changes in this PR
agents.function_tool(the real openai-agents SDK decorator) rebinds a tool function'smodule-level name to a
FunctionTooldataclass instance with no.func/.coroutine/__wrapped__— the existing container-attr hop (added ine714961ffor langchain'sStructuredTool) doesn't match it.FunctionRef.offell through to unsafefn_directtransport, which crashed the registration-time pickle probe with
SpawnSafetyError, eventhough the tool function was correctly defined at module level.
examples/agents/openai/02_function_tools.py, run as shipped against a liveAI-enabled Conductor server under default
spawn— crashed before any LLM call.FunctionRef.ofgets a new fallback that reusesserializer.py's existing generic,recursive attribute+closure walk (
_find_embedded_function), relocated into_worker_entries.pyalongside_extract_from_closureso parent-side discovery andchild-side reconstruction share one implementation and can't drift apart. No
openai-agents-specific attribute path is hardcoded.
Issue #448
Alternatives considered
_CLOSURE_CONTAINER_ATTRS = ("on_invoke_tool",)) calling theclosure-walk directly on
on_invoke_tool— the original design. Doesn't work:on_invoke_toolhas no
__closure__(it's an instance, not a function), and hardcoding the next attributehop (
_invoke_tool_impl) would pin to a double-underscore-private name that could rename inany openai-agents point release.
FunctionRefinstead ofreusing
serializer.py's existing walk — rejected to avoid two independent implementationsthat could silently diverge.