Skip to content

Envelope

autogen.beta.network.envelope.Envelope dataclass #

Envelope(session_id, sender_id, audience, event_type, event_data, envelope_id='', task_id=None, causation_id=None, trace_id=None, priority='normal', depth=0, idempotency_key=None, created_at='', ttl_seconds=None)

Wire shape for every Agent-to-Agent message.

Field semantics:

  • envelope_id — hub-stamped on accept (UUID7-like). Sender-side construction leaves this empty; Hub.post_envelope populates.
  • audienceNone broadcasts within the session; a list targets a subset. Hub WAL stores the full envelope regardless of addressing (audit + debug); notify lands only on listed peers.
  • causation_id — envelope this is responding to. Used by view policies to thread replies to their prompts.
  • depth — delegation hop count. Hub auto-increments on the reply path; Rule.limits.delegation_depth caps it.
  • ttl_seconds — per-envelope TTL. None defers to the session's expires_at.
  • idempotency_key — dedup key reserved for cross-process transports; the in-process hub serialises under a per-session lock and ignores it.

session_id instance-attribute #

session_id

sender_id instance-attribute #

sender_id

audience instance-attribute #

audience

event_type instance-attribute #

event_type

event_data instance-attribute #

event_data

envelope_id class-attribute instance-attribute #

envelope_id = ''

task_id class-attribute instance-attribute #

task_id = None

causation_id class-attribute instance-attribute #

causation_id = None

trace_id class-attribute instance-attribute #

trace_id = None

priority class-attribute instance-attribute #

priority = 'normal'

depth class-attribute instance-attribute #

depth = 0

idempotency_key class-attribute instance-attribute #

idempotency_key = None

created_at class-attribute instance-attribute #

created_at = ''

ttl_seconds class-attribute instance-attribute #

ttl_seconds = None

to_dict #

to_dict()

JSON-compatible dict (every field round-trips byte-stable).

Source code in autogen/beta/network/envelope.py
def to_dict(self) -> dict[str, Any]:
    """JSON-compatible dict (every field round-trips byte-stable)."""
    return asdict(self)

to_json #

to_json()

Serialise to JSON. Sort keys so cross-process hashes match.

Source code in autogen/beta/network/envelope.py
def to_json(self) -> str:
    """Serialise to JSON. Sort keys so cross-process hashes match."""
    return json.dumps(self.to_dict(), sort_keys=True)

from_dict classmethod #

from_dict(data)
Source code in autogen/beta/network/envelope.py
@classmethod
def from_dict(cls, data: dict[str, Any]) -> "Envelope":
    return cls(**data)

from_json classmethod #

from_json(text)
Source code in autogen/beta/network/envelope.py
@classmethod
def from_json(cls, text: str) -> "Envelope":
    return cls.from_dict(json.loads(text))