Repository navigation
Reject kwargs keys that collide with named tool parameters - #4709
mikemikimike wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2480b4539
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| for idx, (name, param) in enumerate(self.signature.parameters.items()) | ||
| if not (self.takes_context and idx == 0) | ||
| and param.kind | ||
| in (param.POSITIONAL_ONLY, param.POSITIONAL_OR_KEYWORD, param.KEYWORD_ONLY) |
There was a problem hiding this comment.
Exclude positional-only names from collision checks
For a supported callable such as def func(value: int, /, **kwargs: int), the input {"value": 1, "kwargs": {"value": 9}} is valid: Python binds the first value positionally and places the second in kwargs. Including POSITIONAL_ONLY here instead raises ModelBehaviorError, preventing a valid function-tool invocation; restrict collision detection to parameters that can actually bind by keyword.
AGENTS.md reference: AGENTS.md:L194-L194
Useful? React with 👍 / 👎.
|
Thanks for the fix. #4674 addresses the same #4669 bug and already preserves the valid positional-only case. This implementation includes positional-only parameter names in the collision set, so it rejects valid Python calls such as |
Summary
FuncSchema.to_call_argscould silently overwrite a validated named argument, or produce an invalid Python call, when a**kwargskey collided with a named function parameter.This change rejects those collisions with
ModelBehaviorErrorbefore invocation. Non-conflicting**kwargscontinue to be passed through unchanged.Testing
uv run --frozen pytest tests/test_function_schema.py -q(41 passed)uv run --frozen ruff check src/agents/function_schema.py tests/test_function_schema.pygit diff --checkMypy was attempted but did not complete on the local Windows environment.