-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
Description
Describe the bug
When streaming responses from an Agent using Runner.run_streamed(), a pydantic validation error occurs when trying to process ResponseTextDeltaEvent objects. The error indicates that the logprobs field is required but missing from the response data.
Debug information
- Agents SDK version: v0.2.3
- Python version: 3.11.6
- Additional dependencies:
- openai: 1.97.1
- litellm: 1.74.7
Repro steps
Minimal Python script to reproduce the bug:
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())Error output:
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
Expected behavior
The script should successfully stream agent responses without validation errors. The ResponseTextDeltaEvent should be properly constructed with all required fields, or the logprobs field should be optional if not provided by the underlying model/API.
The expected output should be the agent's response printed character by character as it streams, followed by the input list representation of the result.
sei-li-miidas, Roman-Kornev, vmalyi, Lin-Rexter, walsha2 and 5 more