Skip to content

CCOR-13508 - fix(agents): prefer the importable function in a tool closure - #510

Merged
chrishagglund-ship-it merged 1 commit into
mainfrom
fix/agents-closure-prefers-importable-function
Sep 21, 2026
Merged

chrishagglund-ship-it merged 1 commit into
mainfrom
fix/agents-closure-prefers-importable-function

Conversation

@chrishagglund-ship-it

Copy link
Copy Markdown
Contributor

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.

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>
@chrishagglund-ship-it
chrishagglund-ship-it merged commit 7d340ac into main Sep 21, 2026
6 checks passed
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