# 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)::

```python
class AllowAll:
    def is_eligible(self, agent: Agent, ctx: SelectionContext) -> bool:
        return True
```

Example - exclude a specific agent by name::

```python
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`

```python
is_eligible(agent, ctx)
```

Return True if agent should be included in the candidate set.

| PARAMETER | DESCRIPTION |
| --- | --- |
| `agent` | The candidate agent being evaluated.<br>**TYPE:**`Agent` |
| `ctx` | Minimal context about the current selection round.<br>**TYPE:**`SelectionContext` |

| RETURNS | DESCRIPTION |
| --- | --- |
| `bool` | True to keep the agent in the candidate set; False to exclude it. |

Source code in `autogen/agentchat/eligibility_policy.py`

|     |     |
| --- | --- |
| ```<br>100<br>101<br>102<br>103<br>104<br>105<br>106<br>107<br>108<br>109<br>110<br>``` | ```<br>def is_eligible(self, agent: Agent, ctx: SelectionContext) -> bool:<br>    """Return True if agent should be included in the candidate set.<br>    Args:<br>        agent: The candidate agent being evaluated.<br>        ctx: Minimal context about the current selection round.<br>    Returns:<br>        True to keep the agent in the candidate set; False to exclude it.<br>    """<br>    ...<br>```
