Agent SDK throws Error "additionalProperties should not be set for object types."

I get the following error while running the Agent SDK with annotation of function_tool for a function.

Here is the definition of the function. If i change the type of input_dict to str , it doesn’t complain. Where can i set the additionalProperties to false.

@function_tool
def filter_data (input_data_str: Dict , key : str , operator: str , value: Union[str,int] ) -> Dict  :

Orchestrator definiton -

orchestrator = Agent(
    name="Orchestrator",
    model="o4-mini",
    instructions=ORCHESTRATOR_PROMPT,
    tools=[
        patient_query,
        get_current_date,
        filter_data,
    ],


)

agents.exceptions.UserError: additionalProperties should not be set for object types. This could be because you’re using an older version of Pydantic, or because you configured additional properties to be allowed. If you really need this, update the function or output tool to not use a strict schema.

I had this problem, and tried to debug it with the official documentation example.

from typing import Any

from agents import Agent, FunctionTool, RunContextWrapper, Runner
from pydantic import BaseModel


def do_some_work(data: str) -> str:
    return "done"


class FunctionArgs(BaseModel):
    username: str
    age: int


async def run_function(ctx: RunContextWrapper[Any], args: str) -> str:
    parsed = FunctionArgs.model_validate_json(args)
    return do_some_work(data=f"{parsed.username} is {parsed.age} years old")


tool = FunctionTool(
    name="process_user",
    description="Save user data",
    params_json_schema=FunctionArgs.model_json_schema(),
    on_invoke_tool=run_function,
)

agent = Agent(
    name="UserProcessor",
    instructions="Process user data and return a message",
    tools=[tool],
)
async def run_agent():
    
    return await Runner.run(agent, input="Save the user Pedro who is 30 years old")

import asyncio

if __name__ == "__main__":

    result = asyncio.run(run_agent())
    print(result)  

I got this error with this code:

openai.BadRequestError: Error code: 400 - {'error': {'message': "Invalid schema for function 'process_user': In context=(), 'additionalProperties' is required to be supplied and to be false.", 'type': 'invalid_request_error', 'param': 'tools[0].parameters', 'code': 'invalid_function_parameters'}}

I eventually fix it like this

j_schema = FunctionArgs.model_json_schema()
j_schema["additionalProperties"] = False

tool = FunctionTool(
    name="process_user",
    description="Save user data",
    params_json_schema=j_schema,
    on_invoke_tool=run_function,
)

Using dicts in the json schema is tricky, unfortunately I can’t anwser you. But a trick I used for this is asking the model to generate a json string.