AgentEligibilityPolicy
autogen.AgentEligibilityPolicy #
Bases: Protocol
Protocol for runtime eligibility filters in GroupChat speaker selection.
Implement this protocol to remove agents from the candidate set before the speaker selection method (auto/manual/random/round_robin) runs.
Example - always allow all agents (no-op, equivalent to no policy)::
class AllowAll:
def is_eligible(self, agent: Agent, ctx: SelectionContext) -> bool:
return True
Example - exclude a specific agent by name::
class ExcludeAgent:
def __init__(self, name: str) -> None:
self.name = name
def is_eligible(self, agent: Agent, ctx: SelectionContext) -> bool:
return agent.name != self.name
Multiple policies can be registered on a GroupChat; all must return True for an agent to be considered eligible (AND semantics).
Note
isinstance(obj, AgentEligibilityPolicy) only checks that is_eligible exists as an attribute -- it does not verify the method signature. A class with the wrong arity will fail at call time, not at registration.
is_eligible #
Return True if agent should be included in the candidate set.
| PARAMETER | DESCRIPTION |
|---|---|
agent | The candidate agent being evaluated. TYPE: |
ctx | Minimal context about the current selection round. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
bool | True to keep the agent in the candidate set; False to exclude it. |