Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix function_schema name override bug #872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/agents/function_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ def function_schema(
doc_info = None
param_descs = {}

func_name = name_override or doc_info.name if doc_info else func.__name__
# Ensure name_override takes precedence even if docstring info is disabled.
func_name = name_override or (doc_info.name if doc_info else func.__name__)

# 2. Inspect function signature and get type hints
sig = inspect.signature(func)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_function_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,15 @@ def func_with_mapping(test_one: Mapping[str, int]) -> str:

with pytest.raises(UserError):
function_schema(func_with_mapping)


def test_name_override_without_docstring() -> None:
"""name_override should be used even when not parsing docstrings."""

def foo(x: int) -> int:
return x

fs = function_schema(foo, use_docstring_info=False, name_override="custom")

assert fs.name == "custom"
assert fs.params_json_schema.get("title") == "custom_args"