Derive realtime input receipts from thread history (#62251)

## Why

Accepted handoffs and saved transcript chunks need to appear in realtime
history. Their text can come from the same user message that model history
uses, avoiding a second persisted copy for the receipt.

## What changed

- Reconstruct `turnInputAccepted` and transcript chunk receipts from user
  messages annotated with realtime provenance. Use the stored observation
  time when restoring the realtime clock.
- Replace `sessionEndInputSaved` in the app-server protocol with
  `sessionInputSaved` and a `reason` of `chunk` or `sessionEnd`. Update the
  generated schemas and bindings.

## Testing

Add coverage for reconstructing both receipt types, preserving rollout
order in paginated realtime history, and restoring observation time
across a restart after wall-clock rollback.

GitOrigin-RevId: fcb4e0e539f4e4066726e83fa1e945fb659a2ca8
This commit is contained in:
Zahan Malkani
2026-11-18 11:01:02 +00:00
committed by copyberry
parent 6d9f0199ed
commit 4389a526d5
19 changed files with 404 additions and 65 deletions
+29 -23
View File
@@ -6520,27 +6520,6 @@ class TurnInputAcceptedThreadRealtimeItem(BaseModel):
]
class SessionEndInputSavedThreadRealtimeItem(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
id: str
observed_at_ms: Annotated[
int | None,
Field(
alias="observedAtMs",
description="Canonical observation time in Unix milliseconds for eligible voice calls.",
),
] = None
realtime_session_id: Annotated[str, Field(alias="realtimeSessionId")]
input: str
input_item_id: str
source_event_ids: list[str]
type: Annotated[
Literal["sessionEndInputSaved"], Field(title="SessionEndInputSavedThreadRealtimeItemType")
]
class ThreadRealtimeItemAddedNotification(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
@@ -6579,6 +6558,11 @@ class ThreadRealtimeSdpNotification(BaseModel):
thread_id: Annotated[str, Field(alias="threadId")]
class ThreadRealtimeSessionInputReason(Enum):
chunk = "chunk"
session_end = "sessionEnd"
class ThreadRealtimeSessionOutcome(Enum):
ended = "ended"
failed = "failed"
@@ -11405,6 +11389,28 @@ class RealtimeSessionClosedThreadRealtimeItem(BaseModel):
]
class SessionInputSavedThreadRealtimeItem(BaseModel):
model_config = ConfigDict(
populate_by_name=True,
)
id: str
observed_at_ms: Annotated[
int | None,
Field(
alias="observedAtMs",
description="Canonical observation time in Unix milliseconds for eligible voice calls.",
),
] = None
realtime_session_id: Annotated[str, Field(alias="realtimeSessionId")]
input: str
input_item_id: str
reason: ThreadRealtimeSessionInputReason
source_event_ids: list[str]
type: Annotated[
Literal["sessionInputSaved"], Field(title="SessionInputSavedThreadRealtimeItemType")
]
class ThreadRealtimeItem(
RootModel[
RealtimeSessionStartedThreadRealtimeItem
@@ -11413,7 +11419,7 @@ class ThreadRealtimeItem(
| BemItemPromotedThreadRealtimeItem
| RealtimeSessionClosedThreadRealtimeItem
| TurnInputAcceptedThreadRealtimeItem
| SessionEndInputSavedThreadRealtimeItem
| SessionInputSavedThreadRealtimeItem
]
):
root: Annotated[
@@ -11423,7 +11429,7 @@ class ThreadRealtimeItem(
| BemItemPromotedThreadRealtimeItem
| RealtimeSessionClosedThreadRealtimeItem
| TurnInputAcceptedThreadRealtimeItem
| SessionEndInputSavedThreadRealtimeItem,
| SessionInputSavedThreadRealtimeItem,
Field(
description="EXPERIMENTAL - a thread-scoped realtime item in the canonical timeline."
),