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

Skip to content

name_override not respected when use_docstring_info=False due to missing parentheses in func_name assignment in function_schema #860

Closed
@HafizFasih

Description

@HafizFasih

Describe the bug

A clear and concise description of what the bug is.

In the function_schema method of the OpenAI Agents SDK, the following line:

func_name = name_override or doc_info.name if doc_info else func.__name__

does not honor name_override when use_docstring_info=False. This happens because of operator precedence in Python. Without parentheses, the expression is interpreted as:

func_name = (name_override or doc_info.name) if doc_info else func.__name__
So when doc_info is None, even if name_override is set, it falls back to func.name.

Debug information

  • Agents SDK version: (e.g. v0.0.3)
  • Python version (e.g. Python 3.10)

Repro steps

from agents.function_schema import function_schema

def my_func():
pass

schema = function_schema(
my_func,
name_override="CustomName",
use_docstring_info=False
)

print(schema.name) # Expected: "CustomName", Actual: "my_func"

Expected behavior

Even when use_docstring_info=False, if name_override is provided, it should be used for func_name.

Suggested Fix:
Update this line:
func_name = name_override or doc_info.name if doc_info else func.name
To this (with parentheses to enforce correct evaluation):
func_name = name_override or (doc_info.name if doc_info else func.name)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions