Skip to content

RealtimeSession does not emit history_updated for transcript_delta #2940

@LocNguyenSGU

Description

@LocNguyenSGU

RealtimeSession does not emit history_updated for transcript_delta

Summary

I may be misunderstanding the intended API contract here, but RealtimeSession appears to update its local history on transcript_delta without emitting history_updated (or another high-level history event).

That seems a little surprising given the realtime docs, which suggest history_added / history_updated are the main events for UI state.

What I observed

When RealtimeSession receives a RealtimeModelTranscriptDeltaEvent:

  • it accumulates transcript text,
  • it updates session._history,
  • but it only forwards the raw model event to the queue.

So a UI that follows the docs and listens mainly to history_added / history_updated will not see live partial transcript changes, even though the session history has already changed.

Minimal repro

import asyncio
from agents.realtime.session import RealtimeSession
from agents.realtime.model_events import RealtimeModelTranscriptDeltaEvent

class DummyModel:
    async def connect(self): pass
    async def close(self): pass
    async def send_event(self, event): pass

class DummyAgent:
    output_guardrails = []
    handoffs = []
    tools = []
    mcp_servers = []
    model_settings = None

async def main():
    session = RealtimeSession(DummyModel(), DummyAgent(), None)

    await session.on_event(
        RealtimeModelTranscriptDeltaEvent(
            item_id="item_1",
            delta="hello",
            response_id="resp_1",
        )
    )

    print("queue size:", session._event_queue.qsize())
    while not session._event_queue.empty():
        event = await session._event_queue.get()
        print(type(event).__name__, getattr(event, "type", None))

    print("history:", session._history)

asyncio.run(main())

Current behavior

  • only the raw model event is emitted to the queue
  • session._history is updated with the partial transcript

Expected behavior

One of these seems reasonable:

  1. emit history_updated when transcript_delta mutates local history, so UI subscribers stay in sync, or
  2. clarify in the docs that live transcript updates are only available through raw model events, not through session history events

Why this seems inconsistent with the docs

The realtime guide says:

The most useful events for UI state are usually history_added and history_updated.

But the transcript_delta path updates _history without emitting either of those events.

Implementation notes

In src/agents/realtime/session.py, the transcript_delta branch:

  • accumulates transcript text,
  • updates _history via _get_new_history(...),
  • but does not emit RealtimeHistoryUpdated.

There is also a test in tests/realtime/test_session.py that currently treats transcript_delta as an ignored high-level event, which matches the current implementation.

Environment

  • Agents SDK version: 0.14.2
  • Python version: 3.13.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions