SessionAdapter
autogen.beta.network.adapters.base.SessionAdapter #
Bases: Protocol
Code half of the manifest/adapter split.
Adapters are looked up at session-create time by (manifest.type, manifest.version). Re-registering an adapter at a new version does not retroactively change in-flight sessions — they keep their original manifest snapshot.
initial_state #
fold #
Append envelope into the derived state. Pure function.
Called once per WAL append by the hub. Must be deterministic so Hub.hydrate() can re-fold from disk.
Source code in autogen/beta/network/adapters/base.py
validate_create #
validate_send #
Raise if this envelope is not allowed by the protocol at this point.
Receives state BEFORE fold(envelope, ...) runs.
Source code in autogen/beta/network/adapters/base.py
on_accepted #
Decide post-accept transitions.
Receives state AFTER fold(envelope, ...) has run.
Source code in autogen/beta/network/adapters/base.py
default_view_policy #
Per-participant default projection for this session type.
extract_turn_input #
Decode an inbound substantive envelope into the input the next speaker's LLM should receive on its turn.
Return None (or empty string) for envelopes this adapter doesn't act on — the handler will skip the round.
The default behaviour (default_extract_turn_input) handles EV_TEXT. Adapters that emit additional substantive event types (e.g. EV_PACKET for the workflow adapter) override to decode those.
Source code in autogen/beta/network/adapters/base.py
build_round_envelope #
Build the envelope that captures one Agent.ask round.
Called by the handler after Agent.ask returns. Adapters encode the round result into the envelope shape they expect: the default (default_build_round_envelope) emits EV_TEXT(reply.body) if non-empty, else None (silent round, no envelope posted).
Returning None means "this round produced nothing worth recording" — the caller skips the post.
Source code in autogen/beta/network/adapters/base.py
render_envelope #
Project envelope to its LLM-visible string for view policies.
Called by ViewPolicy.project once per envelope in the WAL slice the participant should see. Adapters that emit only EV_TEXT delegate to default_render_envelope; adapters with richer round-end shapes (e.g. WorkflowAdapter with EV_PACKET) handle their own types and fall through to the default for the universal cases.
Returning None means "skip this envelope in the projection" (non-substantive event types, malformed payload, etc.).