Skip to content

[Bug]: Tool schema marks **kwargs as a required (untyped) parameter, forcing the LLM to fill it #22134

Description

@gautamvarmadatla

Bug Description

FunctionTool builds its parameter schema with create_schema_from_function, which loops over a function's parameters without checking param.kind, so *args and **kwargs get added as required schema properties (and unannotated **kwargs has no type). This makes the LLM-facing tool spec demand a phantom args/kwargs argument on every call and gets rejected by OpenAI strict function calling.

Version

0.14.23

Steps to Reproduce

from llama_index.core.tools import FunctionTool
from llama_index.llms.openai import OpenAI


def search(query: str, **kwargs) -> str:
    """Search the web."""
    return "results"


tool = FunctionTool.from_defaults(fn=search)
llm = OpenAI(model="gpt-5.5", strict=True)  

resp = llm.chat_with_tools([tool], user_msg="search for cats")
print(llm.get_tool_calls_from_response(resp, error_on_no_tool_call=False))

Relevant Logs/Tracebacks

ERROR: BadRequestError
Error code: 400 - {'error': {'message': "Invalid schema for function 'search': In context=('properties', 'kwargs'), schema must have a 'type' key.", 'type': 'invalid_request_error', 'param': 'tools[0].function.parameters', 'code': 'invalid_function_parameters'}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageIssue needs to be triaged/prioritized

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions