---
type: email
from: Thomas Mansencal <notifications@github.com>
subject: [openai/openai-agents-python] Tool Schema Issue: LLM Ignoring Nested

 Object Structure in Function Calls (Issue #1681)
received: 2026-03-06 07:24:00
date_header: Sun, 07 Sep 2025 17:07:46 -0700
priority: normal
status: awaiting_approval
uid: 29703
---

## Email Content

**From:** Thomas Mansencal <notifications@github.com>
**Subject:** [openai/openai-agents-python] Tool Schema Issue: LLM Ignoring Nested

 Object Structure in Function Calls (Issue #1681)
**Date:** Sun, 07 Sep 2025 17:07:46 -0700

### Body (preview)

KelSolaar created an issue (openai/openai-agents-python#1681)



## Description



The OpenAI Realtime API flattens tool arguments incorrectly, ignoring the provided JSON schema for nested objects. This causes tool calls to fail because the arguments don't match the expected structure.



When using MCP tools with nested object parameters through the OpenAI Realtime API, the LLM ignores the schema structure and flattens arguments that should be nested within object properties.



### Expected Behavior



Given the schema for `SetProperties`:

```json

{

  "type": "object",

  "properties": {

    "target": {

      "type": "string",

      "description": "The name of the target on which we will set the properties."

    },

    "keysAndValues": {

      "type": "object",

      "description": "The properties keys and their values to change, formatted as json key/value pairs"

    }

  },

  "required": ["target", "keysAndValues"]

}

```



The LLM should call the tool with properly nested arguments:

```json

{

  "target": "MyTarget",

  "keysAndValues": {

    "visible": false

  }

}

```



### Actual Behavior



The LLM flattens the arguments incorrectly:

```json

{

  "target": "MyTarget",

  "visible": false

}

```



## Investigation Results



Investigation revealed:



1. **Schema Definition is Correct**: The MCP server correctly defines and serves the schema with proper nested structure

2. **Schema Conversion is Working**: Debug logs confirm the schema is properly converted from MCP format to OpenAI function tool format with strict mode enabled

3. **Schema Transmission is Successful**: The final schema sent to the LLM includes the correct `keysAndValues` object structure

4. **LLM is Ignoring Schema**: Despite receiving the correct schema, the LLM flattens arguments instead of following the nested structure



## Debug Evidence



Added debug logging to `agents/mcp/util.py` in the `to_function_tool()` and `invoke_mcp_tool()` methods:



```

[SCHEMA

---

## Suggested Actions
- [ ] Reply
- [ ] Archive
- [ ] Escalate
