microsoft/autogen · error · ValueError

Invalid description {retval} for parameter {k}, should be a

Error message

Invalid description {retval} for parameter {k}, should be a string.

What it means

Error "Invalid description {retval} for parameter {k}, should be a string." thrown in microsoft/autogen.

Source

Thrown at python/packages/autogen-core/src/autogen_core/_function_utils.py:127

    name: Annotated[str, Field(description="Name of the function")]
    parameters: Annotated[Parameters, Field(description="Parameters of the function")]


class ToolFunction(BaseModel):
    """A function under tool as defined by the OpenAI API."""

    type: Literal["function"] = "function"
    function: Annotated[Function, Field(description="Function under tool")]


def type2description(k: str, v: Union[Annotated[Type[Any], str], Type[Any]]) -> str:
    # handles Annotated
    if hasattr(v, "__metadata__"):
        retval = v.__metadata__[0]
        if isinstance(retval, str):
            return retval
        else:
            raise ValueError(f"Invalid description {retval} for parameter {k}, should be a string.")
    else:
        return k


def get_parameter_json_schema(k: str, v: Any, default_values: Dict[str, Any]) -> Dict[str, Any]:
    """Get a JSON schema for a parameter as defined by the OpenAI API

    Args:
        k: The name of the parameter
        v: The type of the parameter
        default_values: The default values of the parameters of the function

    Returns:
        A Pydanitc model for the parameter
    """

    schema = TypeAdapter(v).json_schema()
    if k in default_values:

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Provide string descriptions for all tool parameters

Example fix

Set description='...' strings in the function docstring/annotations

When it happens

Trigger: Thrown at python/packages/autogen-core/src/autogen_core/_function_utils.py:127 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/8cd1651f3c9165f5. Report an issue: GitHub.