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

Skip to content

Commit e251fa6

Browse files
authored
description_override is not properly used for function_schema.description (openai#1000)
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: ```python description=description_override or doc_info.description if doc_info else None ``` does not honor description_override when `use_docstring_info=False`. This happens because of operator precedence in Python. Without parentheses, the expression is interpreted as: ```python description=(description_override or doc_info.description) if doc_info else None ``` So when doc_info is None, even if description_override is set, it falls back to None Debug information Python version (e.g. Python 3.10) Repro steps ```python from agents.function_schema import function_schema def my_func(): pass schema = function_schema( my_func, description_override ="CustomDescription", use_docstring_info=False ) print(schema.description) # Expected: "CustomDescription", Actual: None ``` Expected behavior Even when use_docstring_info=False, if description_override is provided, it should be used for description. Suggested Fix: Update this line: description=description_override or doc_info.description if doc_info else None To this (with parentheses to enforce correct evaluation): description=description_override or (doc_info.description if doc_info else None)
1 parent 1720e4a commit e251fa6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/agents/function_schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@ def function_schema(
337337
# 5. Return as a FuncSchema dataclass
338338
return FuncSchema(
339339
name=func_name,
340-
description=description_override or doc_info.description if doc_info else None,
340+
# Ensure description_override takes precedence even if docstring info is disabled.
341+
description=description_override or (doc_info.description if doc_info else None),
341342
params_pydantic_model=dynamic_model,
342343
params_json_schema=json_schema,
343344
signature=sig,

0 commit comments

Comments
 (0)