-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
using litellm models in openai-agents with openai version 1.97.1 causes this error in streaming mode. Note that this was working fine with openai 1.96.1
pydantic_core._pydantic_core.ValidationError: 1 validation error for ResponseTextDeltaEvent
logprobs
Field required [type=missing, input_value={'content_index': 0, 'del...', 'sequence_number': 3}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.11/v/missing
To Reproduce
import asyncio
from agents import Agent, Runner
from dotenv import load_dotenv
from openai.types.responses import ResponseTextDeltaEvent
load_dotenv()
async def main():
print("\n🚀 Running basic mode...")
agent = Agent(
name="Test Agent",
instructions="You are a helpful assistant that can help with tasks.",
model="litellm/anthropic/claude-opus-4-20250514"
)
result = Runner.run_streamed(
starting_agent=agent,
input="Hi",
)
print("=== Test Agent Starting ===")
async for event in result.stream_events():
if event.type == "raw_response_event" and isinstance(event.data, ResponseTextDeltaEvent):
print(event.data.delta, end="", flush=True)
print(result.to_input_list())
if name == "main":
asyncio.run(main())
Code snippets
OS
macOS
Python version
Python v3.11.6
Library version
openai 1.97.1, openai-agents 0.2.3, litellm 1.74.7