8000 Missing docstring in fetch_user_age breaks tool understanding · Issue #892 · openai/openai-agents-python · GitHub
[go: up one dir, main page]

Skip to content
Missing docstring in fetch_user_age breaks tool understanding #892
Open
@Abbas-Asad

Description

@Abbas-Asad

Bug: Missing docstring in fetch_user_age breaks tool understanding

The fetch_user_age function in the context.md documentation is missing a docstring.

This causes many language models (other than OpenAI’s) to misinterpret the tool or ignore it completely. Typical responses include:

"I cannot determine the user's age because the available tools lack the ability to fetch user-specific information."
"I cannot fulfill this request. The available tools lack the ability to fetch the user's age."

This happens because, without a docstring, the tool schema lacks a proper description.

Suggested fix:

@function_tool
async def fetch_user_age(wrapper: RunContextWrapper[UserInfo]) -> str:
    """Returns the age of the user."""
    return f"User {wrapper.context.name} is 47 years old"

This minimal docstring improves compatibility across LLM providers and ensures accurate tool usage.

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

      0