Skip to content

SelectionContext

autogen.SelectionContext dataclass #

SelectionContext(round, last_speaker, participants)

Minimal context passed to AgentEligibilityPolicy.is_eligible().

Intentionally minimal to avoid coupling policies to GroupChat internals. Do NOT add the GroupChat object itself -- policies should be stateless with respect to the chat object.

round instance-attribute #

round

Number of messages spoken so far.

In normal GroupChatManager flow, equals 1 during the first speaker selection (the initial message is appended before select_speaker is called). Use round == 1 to detect the first selection in that context.

Example::

def is_eligible(self, agent, ctx):
    if ctx.round == 1:
        return agent.name != "expensive_agent"  # skip on opening turn
    return True

last_speaker instance-attribute #

last_speaker

Name of the last speaker, or None if this is the first round.

participants instance-attribute #

participants

Names of all registered participants in the GroupChat (the full roster, not the filtered candidate set at the point of this call).

Note

Agents that have been marked unavailable via :class:AgentDescriptionGuard (description prefixed with [UNAVAILABLE]) are still included here -- they are present in the GroupChat roster. Eligibility filtering happens separately; this field reflects the raw participant list.