feat(agent_session_endpoints): serialize event rows with type/data wire fields

Renames event_type/payload -> type/data when projecting an
AgentRunEvent row into a ConversationMessage so the /conversation
endpoint output matches the SSE event frame and Cursor's API.
This commit is contained in:
Ishaan Jaffer 2026-05-06 16:15:32 -07:00
parent 19f3f3210f
commit dc39173849
No known key found for this signature in database

View file

@ -98,10 +98,14 @@ def run_row_to_response(row: Any) -> RunResponse:
def event_row_to_message(row: Any) -> ConversationMessage:
# NOTE: the DB column is ``event_type``/``payload`` but the wire
# shape we surface to SDK consumers is ``type``/``data`` (matches
# Cursor's API + the SSE event frame in run_endpoints._sse_event_data).
# Rename here so /conversation and the SSE stream agree.
return ConversationMessage(
run_id=row.run_id,
seq=row.seq,
event_type=row.event_type,
payload=_as_dict(row.payload) or {},
type=row.event_type,
data=_as_dict(row.payload) or {},
created_at=_iso(row.created_at),
)