Multi-participant turn-taking session with round_robin ordering.
Participants: 2+ (no upper bound). Initiator (order=0) speaks first; turns rotate through metadata.participants in order, cycling back after the last participant.
Knobs: {"ordering": "round_robin"} (default). Unsupported orderings are rejected at create time.
Default view: :class:WindowedSummary(recent_n=N*2) where N = participant count — keeps prompt size bounded at any turn count.
Source code in autogen/beta/network/adapters/discussion.py
| def __init__(self) -> None:
self.manifest = SessionManifest(
type=DISCUSSION_TYPE,
version=1,
participants=ParticipantSchema(min=2),
knobs_schema={"ordering": "str"},
default_view_policy=WindowedSummary.name,
expectations=[
Expectation(
name="turn_within",
on_violation="warn",
params={"seconds": 120},
),
Expectation(
name="turn_within",
on_violation="hide",
params={"seconds": 600},
),
],
)
|
manifest instance-attribute
manifest = SessionManifest(type=DISCUSSION_TYPE, version=1, participants=ParticipantSchema(min=2), knobs_schema={'ordering': 'str'}, default_view_policy=name, expectations=[Expectation(name='turn_within', on_violation='warn', params={'seconds': 120}), Expectation(name='turn_within', on_violation='hide', params={'seconds': 600})])
initial_state
Source code in autogen/beta/network/adapters/discussion.py
| def initial_state(self, metadata: SessionMetadata) -> DiscussionState:
order = [p.agent_id for p in sorted(metadata.participants, key=lambda p: p.order)]
return DiscussionState(
participant_order=order,
expected_next_speaker=metadata.creator_id,
)
|
fold
Source code in autogen/beta/network/adapters/discussion.py
| def fold(self, envelope: Envelope, state: DiscussionState) -> DiscussionState:
if _is_session_protocol_event(envelope) or _is_task_event(envelope):
return state
if envelope.event_type != EV_TEXT:
return state
try:
idx = state.participant_order.index(envelope.sender_id)
except ValueError:
# Sender not in the rotation (shouldn't happen — validate_send
# gates this) — leave state untouched rather than crash.
return state
next_idx = (idx + 1) % len(state.participant_order)
return DiscussionState(
participant_order=state.participant_order,
expected_next_speaker=state.participant_order[next_idx],
last_speaker_id=envelope.sender_id,
last_envelope_id=envelope.envelope_id,
turn_count=state.turn_count + 1,
)
|
validate_create
validate_create(metadata)
Source code in autogen/beta/network/adapters/discussion.py
| def validate_create(self, metadata: SessionMetadata) -> None:
if len(metadata.participants) < 2:
raise ProtocolError(f"discussion requires at least 2 participants, got {len(metadata.participants)}")
ordering = metadata.knobs.get("ordering", _DEFAULT_ORDERING)
if ordering not in _SUPPORTED_ORDERINGS:
raise ProtocolError(
f"discussion knobs.ordering={ordering!r} not supported; choose from {sorted(_SUPPORTED_ORDERINGS)}"
)
|
validate_send
validate_send(metadata, envelope, state)
Source code in autogen/beta/network/adapters/discussion.py
| def validate_send(
self,
metadata: SessionMetadata,
envelope: Envelope,
state: DiscussionState,
) -> None:
if _is_session_protocol_event(envelope) or _is_task_event(envelope):
return
if envelope.event_type != EV_TEXT:
return
if envelope.sender_id != state.expected_next_speaker:
raise ProtocolError(
f"discussion session {metadata.session_id!r} expects "
f"{state.expected_next_speaker!r} to speak, got {envelope.sender_id!r}"
)
|
on_accepted
on_accepted(metadata, envelope, state)
Source code in autogen/beta/network/adapters/discussion.py
| def on_accepted(
self,
metadata: SessionMetadata,
envelope: Envelope,
state: DiscussionState,
) -> AdapterResult:
# Discussions end via explicit ``Hub.close_session`` or TTL.
# Speaker rotation happens entirely in ``fold``.
return AdapterResult()
|
default_view_policy
default_view_policy(metadata, participant_id)
Source code in autogen/beta/network/adapters/discussion.py
| def default_view_policy(
self,
metadata: SessionMetadata,
participant_id: str,
) -> ViewPolicy:
recent_n = max(len(metadata.participants) * 2, 4)
return WindowedSummary(recent_n=recent_n)
|
extract_turn_input(envelope)
Source code in autogen/beta/network/adapters/discussion.py
| def extract_turn_input(self, envelope):
return default_extract_turn_input(envelope)
|
build_round_envelope
build_round_envelope(metadata, sender_id, reply, events, state, hub)
Source code in autogen/beta/network/adapters/discussion.py
| def build_round_envelope(self, metadata, sender_id, reply, events, state, hub):
return default_build_round_envelope(metadata, sender_id, reply, events, state, hub)
|
render_envelope
render_envelope(envelope)
Source code in autogen/beta/network/adapters/discussion.py
| def render_envelope(self, envelope):
return default_render_envelope(envelope)
|