Skip to content

Agent session error in OpenAI Agents SDK when handling tool output #1429

@mehdinathani

Description

@mehdinathani

Please read this first

  • Have you read the docs? Yes — Agents SDK docs
  • Have you searched for related issues? Yes — I could not find a similar open issue.

Describe the bug

When running an agent tool in the openai-agents-python SDK, the process unexpectedly terminates with an openai.error.InvalidRequestError despite valid inputs.
The issue appears to occur intermittently and may be linked to tool input/output schema validation not being enforced consistently.

Error message:

openai.error.InvalidRequestError: Invalid tool output: expected object matching schema, got null

Debug information

  • Agents SDK version: v0.0.3
  • Python version: 3.10.14
  • OS: Windows 10 Pro 64-bit

Repro steps

Run the following minimal script:

from openai import Agent, Tool

# Simple echo tool
class EchoTool(Tool):
    name = "echo"
    description = "Echoes the input back"
    input_schema = {"type": "object", "properties": {"message": {"type": "string"}}}
    output_schema = {"type": "object", "properties": {"reply": {"type": "string"}}}

    def call(self, input):
        return {"reply": input["message"]}

# Create agent with tool
agent = Agent(
    name="TestAgent",
    tools=[EchoTool()],
)

# Trigger tool
response = agent.run("echo", {"message": "Hello World"})
print(response)

Expected behavior

The script should print:

{"reply": "Hello World"}

Instead, the run intermittently fails with the InvalidRequestError shown above.


Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions