CCOR-13508 - fix(agents): prefer the importable function in a tool closure - #510
Merged
chrishagglund-ship-it merged 1 commit intoSep 21, 2026
Conversation
openai-agents auto-updated to 0.22.3 (the dep is unpinned, >=0.12.2), whose tool closure now holds two candidates: a nested _prepare_arguments(input, tool_name) beside the user's function. _extract_from_closure returned the first candidate whose leading parameter was not ctx/context, so it began returning the framework's wrapper: FunctionRef.of rejected it as unimportable (5 unit failures), and the serializer would have registered a worker around it -- worse than finding nothing. main would fail identically on a re-run. Selection is now preference-ordered: importable by module + qualname wins. That is exactly what FunctionRef.of requires, and it is a property of the candidate rather than a guess from its parameter names. Closures holding nothing importable fall back to the nested candidate, so those callers get the same value and the same actionable SpawnSafetyError as before. Adds TestClosureCandidatePreference, which builds the adverse closure directly and runs without the extra installed -- the existing deep-extract tests are importorskip'd and pin whatever internals happen to be installed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
manan164
approved these changes
Sep 21, 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.
openai-agents auto-updated to 0.22.3 (the dep is unpinned, >=0.12.2), whose tool closure now holds two candidates: a nested _prepare_arguments(input, tool_name) beside the user's function. _extract_from_closure returned the first candidate whose leading parameter was not ctx/context, so it began returning the framework's wrapper: FunctionRef.of rejected it as unimportable (5 unit failures), and the serializer would have registered a worker around it -- worse than finding nothing. main would fail identically on a re-run.
Selection is now preference-ordered: importable by module + qualname wins. That is exactly what FunctionRef.of requires, and it is a property of the candidate rather than a guess from its parameter names. Closures holding nothing importable fall back to the nested candidate, so those callers get the same value and the same actionable SpawnSafetyError as before.
Adds TestClosureCandidatePreference, which builds the adverse closure directly and runs without the extra installed -- the existing deep-extract tests are importorskip'd and pin whatever internals happen to be installed.