Skip to content

Tool parameters lose descriptions from Annotated[...] and docstring Args sections #270

Open

Description

@jaygupta17

Problem

@ai.tool builds the parameter schema with get_type_hints(fn), which strips Annotated metadata. The most natural typed-tool patterns therefore produce undocumented arguments:

from typing import Annotated
from pydantic import Field

@ai.tool
async def get_weather(
    city: Annotated[str, Field(description="City name")],
    days: Annotated[int, Field(ge=1, le=7, description="Forecast length")] = 3,
) -> str:
    """Get the weather forecast.

    Args:
        city: City to forecast for.
    """
    return "sunny"

Today neither the Field(description=...) nor the Args: entry for city reaches the JSON schema the model sees. Descriptions materially affect tool selection and argument quality, so this hurts most in exactly the multi-tool workspaces the agent loop targets.

Suggested behavior

  • resolve hints with get_type_hints(fn, include_extras=True) so Field metadata survives into model_json_schema() (pydantic already supports this; no new dependency)
  • additionally fill missing property descriptions from a Google-style Args: docstring section, with Field taking precedence
  • schemas for tools that use neither mechanism stay byte-identical

Happy to take this one.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions