Serialize a sequence of AG2 events into the ag2.history+json shape.
Transient events (ModelMessageChunk, ModelReasoning, lifecycle events) are dropped — they are conversation deltas, not durable state. Unknown event types are also skipped silently so future event additions don't break older clients/servers.
Source code in autogen/beta/a2a/mappers/history.py
| def events_to_payload(events: Sequence[BaseEvent]) -> dict[str, Any]:
"""Serialize a sequence of AG2 events into the ``ag2.history+json`` shape.
Transient events (``ModelMessageChunk``, ``ModelReasoning``, lifecycle
events) are dropped — they are conversation deltas, not durable state.
Unknown event types are also skipped silently so future event additions
don't break older clients/servers.
"""
out: list[dict[str, Any]] = []
for ev in events:
encoded = _event_to_dict(ev)
if encoded is not None:
out.append(encoded)
return {"events": out}
|