---
type: email
from: Shivam Bahuguna <notifications@github.com>
subject: [openai/openai-agents-python] Usage always zero in streamed agent

 response (Issue #1722)
received: 2026-03-06 07:29:41
date_header: Thu, 11 Sep 2025 23:41:22 -0700
priority: normal
status: awaiting_approval
uid: 30221
---

## Email Content

**From:** Shivam Bahuguna <notifications@github.com>
**Subject:** [openai/openai-agents-python] Usage always zero in streamed agent

 response (Issue #1722)
**Date:** Thu, 11 Sep 2025 23:41:22 -0700

### Body (preview)

Shivam-Bahuguna-Seatrium created an issue (openai/openai-agents-python#1722)



I'm using Runner.run_streamed(...).stream_events() to stream responses from an agent. However, after the stream completes, result_stream.context_wrapper.usage always returns zero. I confirmed that the stream is fully consumed before accessing usage. Is this expected behavior?





**result_stream = Runner.run_streamed(agent, prompt, context=context, session=session)

async for event in result_stream.stream_events():

    # streaming logic

usage = result_stream.context_wrapper.usage  # always zero**





FULL CODE



async def process_user_query(self, user_query: str):

    await self.session.add_items([{"role": "user", "content": user_query}])

    last_messages = await self.session.get_items(limit=4, user_query=user_query)

    temp_session = MemoryManagerSession("router_temp_" + self.session_id)

    await temp_session.add_items(last_messages)



    query_type = await self.detect_query_type(user_query)

    context = AgentContext(principal_ids=self.principal_ids, query_type=query_type)

    prompt = f"User Query (answer this): {user_query}\n"

    router_agent = self.master_agent.agent



    **result_stream = Runner.run_streamed(router_agent, prompt, context=context, session=self.session)**



    accumulated_output = ""

    tool_used = None

    agent_name = "MasterAgent"

    tool_call_events = []

    tool_call_results = []

    tool_calls_pending = False



    try:

        async for event in result_stream.stream_events():

            if event.type == "agent_updated_stream_event":

                agent_name = getattr(event.new_agent, "name", agent_name)

            elif event.type == "run_item_stream_event":

                if getattr(event.item, "type", None) == "tool_called":

                    tool_used = getattr(event.item, "name", None)

                    tool_call_events.append(event)

                    tool_calls_pending = True

                elif getattr(ev

---

## Suggested Actions
- [ ] Reply
- [ ] Archive
- [ ] Escalate
