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 openai-agents-python with Runner.run_streamed, the context.usage values in the hooks (input_tokens, output_tokens, total_tokens, requests) are always 0.
This issue does not happen when using Runner.run (non-streaming mode), where the usage values are correctly populated.
@brodguez PR #595 fixes this. Note that streaming usage is only available in the very last chunk of the LLM response, so in your example it would be present in on_agent_end but not necessarily before that.
Bug description
When using
openai-agents-python
withRunner.run_streamed
, thecontext.usage
values in the hooks (input_tokens
,output_tokens
,total_tokens
,requests
) are always0
.This issue does not happen when using
Runner.run
(non-streaming mode), where the usage values are correctly populated.Debug information
v0.0.12
Repro steps
Output (streamed)
The output is always: 0 requests, 0 input tokens, 0 output tokens, 0 total tokens
If the same config is run with Runner.run, usage works correctly:
Output (non-streamed):
requests, 123 input tokens, 56 output tokens, 179 total tokens
Expected behavior
In streaming mode, the context.usage values should reflect actual usage data just like in non-streaming mode.
The text was updated successfully, but these errors were encountered: