You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the stream endpoint in the normal_v2 router, the server throws an exception during the streaming process. The error occurs when processing the stream_events method in the Agent's Runner. The client receives partial responses before the connection is abruptly closed with the error: curl: (18) transfer closed with outstanding read data remaining.
Debug information
Agents SDK version: (e.g. v0.0.7)
Python version (e.g. Python 3.11)
Repro steps
Set up the normal_v2 router with the provided code.
Send a POST request to the /normal_v2/stream endpoint with the following payload:
{
"chat_history": [{"role": "system", "content": "You are a helpful assistant."}],
"user_query": "What is the weather today?"
}
Observe the server logs and client response.
Expected behavior
The server should stream the response without errors, and the client should receive the full response in a properly formatted streaming format (e.g., application/x-ndjson).
Server logs: The server throws the following exception:
ERROR: Exception in ASGI application
+ Exception Group Traceback (most recent call last):
...lib/python3.12/site-packages/agents/tracing/scope.py", line 45, in reset_current_trace
| _current_trace.reset(token)
ValueError: <Token var=<ContextVar name='current_trace' default=None at 0x1462a79c0> at 0x169dfec80> was created in a different Context
Client response: The client receives partial responses:
Looking into it. I haven't yet tested anything, but one thing that should probably work is to do the Runner.run_streamed(agent, input=full_history) inside ChatInterface. But I'll get back to you.
Edit: confirming that my suggestion does resolve the issue. So you can do that to workaround, while I investigate a better long term fix.
Describe the bug
When using the stream endpoint in the normal_v2 router, the server throws an exception during the streaming process. The error occurs when processing the stream_events method in the Agent's Runner. The client receives partial responses before the connection is abruptly closed with the error: curl: (18) transfer closed with outstanding read data remaining.
Debug information
v0.0.7
)Repro steps
Set up the normal_v2 router with the provided code.
Send a POST request to the /normal_v2/stream endpoint with the following payload:
Observe the server logs and client response.
Expected behavior
The server should stream the response without errors, and the client should receive the full response in a properly formatted streaming format (e.g., application/x-ndjson).
Server logs: The server throws the following exception:
Client response: The client receives partial responses:
Followed by the error:
curl: (18) transfer closed with outstanding read data remaining
Additional context
Code snippets
Router code:
The text was updated successfully, but these errors were encountered: