-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
Description
Description
I'm using the latest openai-agents Python SDK and running an agent successfully with Runner.run(...).
However, the returned RunResult object does not have a .usage attribute, even though the documentation suggests it should.
Code Snippet
base_result = await Runner.run(
self.agent,
input=instruction
context=context,
)
print(base_result.final_output) # works fine
print(base_result.usage) # raises AttributeErrorError
AttributeError: 'RunResult' object has no attribute 'usage'
Environment
- openai-agents version: 0.2.6
- Python: 3.11
- OS: (e.g., macOS 14.5 / Ubuntu 22.04)
- Agent Type: Custom agent built with
Agentand run viaRunner.run(...)
Expected behavior
The RunResult object should contain .usage with input_tokens, output_tokens, and total_tokens, as per the documentation/examples.
Additional context
This is blocking me from tracking token consumption per run.
If .usage is not supported in Runner.run, please clarify the intended way to retrieve token usage for agent runs.