default_build_packet_envelope(channel_id, sender_id, body, *, handoff=None, context_set=None, audience=None, causation_id=None)
Default build_packet_envelope: emit EV_PACKET with body + optional routing.
routing carries {"kind": "handoff", "target": ..., "reason": ...} when handoff is set. context_set populates context.
Source code in autogen/beta/network/adapters/base.py
| def default_build_packet_envelope(
channel_id: str,
sender_id: str,
body: str,
*,
handoff: "Handoff | None" = None,
context_set: dict | None = None,
audience: list[str] | None = None,
causation_id: str | None = None,
) -> Envelope:
"""Default ``build_packet_envelope``: emit ``EV_PACKET`` with body +
optional routing.
``routing`` carries ``{"kind": "handoff", "target": ..., "reason": ...}``
when ``handoff`` is set. ``context_set`` populates ``context``.
"""
event_data: dict[str, object] = {"body": body}
if handoff is not None:
routing: dict[str, object] = {"kind": "handoff", "target": handoff.target}
if handoff.reason:
routing["reason"] = handoff.reason
event_data["routing"] = routing
if context_set:
event_data["context"] = dict(context_set)
return Envelope(
channel_id=channel_id,
sender_id=sender_id,
audience=audience,
event_type=EV_PACKET,
event_data=event_data,
causation_id=causation_id,
)
|