-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
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.