Skip to content

Capabilities

Base classes

Name Children Inherits
EventedModel
psygnal._evented_model
A pydantic BaseModel that emits a signal whenever a field value is changed.

⋔ Inheritance diagram

graph TD
  94701628969776["capabilities.Capabilities"]
  94701632610560["_evented_model.EventedModel"]
  94701612203136["main.BaseModel"]
  139765536922080["builtins.object"]
  94701632610560 --> 94701628969776
  94701612203136 --> 94701632610560
  139765536922080 --> 94701612203136

🛈 DocStrings

Bases: EventedModel

Defines what operations an agent is allowed to perform.

Source code in src/llmling_agent/config/capabilities.py
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
class Capabilities(EventedModel):
    """Defines what operations an agent is allowed to perform."""

    # Agent / Team discovery and delegation
    can_list_agents: bool = False
    """Whether the agent can discover other available agents."""

    can_delegate_tasks: bool = False
    """Whether the agent can delegate tasks to other agents."""

    can_observe_agents: bool = False
    """Whether the agent can monitor other agents' activities."""

    can_list_teams: bool = False
    """Whether the agent can discover available teams."""

    # History and statistics access
    history_access: AccessLevel = "none"
    """Level of access to conversation history."""

    # Resource capabilities
    can_load_resources: bool = False
    """Whether the agent can load and access resource content."""

    can_list_resources: bool = False
    """Whether the agent can discover available resources."""

    can_read_files: bool = False
    """Whether the agent can read local and remote files."""

    can_list_directories: bool = False
    """Whether the agent can list directories and their contents."""

    # Tool management
    can_register_tools: bool = False
    """Whether the agent can register importable functions as tools."""

    can_register_code: bool = False
    """Whether the agent can create new tools from provided code."""

    can_install_packages: bool = False
    """Whether the agent can install Python packages for tools."""

    can_chain_tools: bool = False
    """Whether the agent can chain multiple tool calls into one."""

    # Execution

    can_execute_code: bool = False
    """Whether the agent can execute Python code (WARNING: No sandbox)."""

    can_execute_commands: bool = False
    """Whether the agent can execute CLI commands (use at your own risk)."""

    can_manage_processes: bool = False
    """Whether the agent can start and manage background processes."""

    # Agent creation
    can_create_workers: bool = False
    """Whether the agent can create worker agents (as tools)."""

    can_create_delegates: bool = False
    """Whether the agent can spawn temporary delegate agents."""

    can_add_agents: bool = False
    """Whether the agent can add aother agents to the pool."""

    can_ask_agents: bool = False
    """Whether the agent can ask other agents of the pool."""

    can_add_teams: bool = False
    """Whether the agent can add teams to the pool."""

    can_connect_nodes: bool = False
    """Whether the agent can add teams to the pool."""

    can_ask_user: bool = False
    """Whether the agent can ask the user clarifying questions during processing."""

    can_add_mcp_servers: bool = False
    """Whether the agent can add new MCP servers."""

    model_config = ConfigDict(frozen=True, use_attribute_docstrings=True, extra="forbid")

    def __contains__(self, required: Capabilities) -> bool:
        """Check if these capabilities contain all required capabilities.

        Example:
            required in agent.capabilities  # Can agent fulfill requirements?
        """
        # Check all boolean capabilities using any() to find any missing required flag
        if any(
            getattr(required, field) and not getattr(self, field)
            for field in type(self).model_fields
            if isinstance(getattr(required, field), bool)
        ):
            return False

        # Check access levels (none < own < all)
        access_order = {"none": 0, "own": 1, "all": 2}
        required_level = access_order[required.history_access]
        self_level = access_order[self.history_access]
        return not required_level > self_level

    def has_capability(self, capability: str) -> bool:
        """Check if a specific capability is enabled.

        Args:
            capability: Name of capability to check.
                      Can be a boolean capability (e.g., "can_delegate_tasks")
                      or an access level (e.g., "history_access")
        """
        match capability:
            case str() if hasattr(self, capability):
                value = getattr(self, capability)
                return bool(value) if isinstance(value, bool) else value != "none"
            case _:
                msg = f"Unknown capability: {capability}"
                raise ValueError(msg)

can_add_agents class-attribute instance-attribute

can_add_agents: bool = False

Whether the agent can add aother agents to the pool.

can_add_mcp_servers class-attribute instance-attribute

can_add_mcp_servers: bool = False

Whether the agent can add new MCP servers.

can_add_teams class-attribute instance-attribute

can_add_teams: bool = False

Whether the agent can add teams to the pool.

can_ask_agents class-attribute instance-attribute

can_ask_agents: bool = False

Whether the agent can ask other agents of the pool.

can_ask_user class-attribute instance-attribute

can_ask_user: bool = False

Whether the agent can ask the user clarifying questions during processing.

can_chain_tools class-attribute instance-attribute

can_chain_tools: bool = False

Whether the agent can chain multiple tool calls into one.

can_connect_nodes class-attribute instance-attribute

can_connect_nodes: bool = False

Whether the agent can add teams to the pool.

can_create_delegates class-attribute instance-attribute

can_create_delegates: bool = False

Whether the agent can spawn temporary delegate agents.

can_create_workers class-attribute instance-attribute

can_create_workers: bool = False

Whether the agent can create worker agents (as tools).

can_delegate_tasks class-attribute instance-attribute

can_delegate_tasks: bool = False

Whether the agent can delegate tasks to other agents.

can_execute_code class-attribute instance-attribute

can_execute_code: bool = False

Whether the agent can execute Python code (WARNING: No sandbox).

can_execute_commands class-attribute instance-attribute

can_execute_commands: bool = False

Whether the agent can execute CLI commands (use at your own risk).

can_install_packages class-attribute instance-attribute

can_install_packages: bool = False

Whether the agent can install Python packages for tools.

can_list_agents class-attribute instance-attribute

can_list_agents: bool = False

Whether the agent can discover other available agents.

can_list_directories class-attribute instance-attribute

can_list_directories: bool = False

Whether the agent can list directories and their contents.

can_list_resources class-attribute instance-attribute

can_list_resources: bool = False

Whether the agent can discover available resources.

can_list_teams class-attribute instance-attribute

can_list_teams: bool = False

Whether the agent can discover available teams.

can_load_resources class-attribute instance-attribute

can_load_resources: bool = False

Whether the agent can load and access resource content.

can_manage_processes class-attribute instance-attribute

can_manage_processes: bool = False

Whether the agent can start and manage background processes.

can_observe_agents class-attribute instance-attribute

can_observe_agents: bool = False

Whether the agent can monitor other agents' activities.

can_read_files class-attribute instance-attribute

can_read_files: bool = False

Whether the agent can read local and remote files.

can_register_code class-attribute instance-attribute

can_register_code: bool = False

Whether the agent can create new tools from provided code.

can_register_tools class-attribute instance-attribute

can_register_tools: bool = False

Whether the agent can register importable functions as tools.

history_access class-attribute instance-attribute

history_access: AccessLevel = 'none'

Level of access to conversation history.

__contains__

__contains__(required: Capabilities) -> bool

Check if these capabilities contain all required capabilities.

Example

required in agent.capabilities # Can agent fulfill requirements?

Source code in src/llmling_agent/config/capabilities.py
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
def __contains__(self, required: Capabilities) -> bool:
    """Check if these capabilities contain all required capabilities.

    Example:
        required in agent.capabilities  # Can agent fulfill requirements?
    """
    # Check all boolean capabilities using any() to find any missing required flag
    if any(
        getattr(required, field) and not getattr(self, field)
        for field in type(self).model_fields
        if isinstance(getattr(required, field), bool)
    ):
        return False

    # Check access levels (none < own < all)
    access_order = {"none": 0, "own": 1, "all": 2}
    required_level = access_order[required.history_access]
    self_level = access_order[self.history_access]
    return not required_level > self_level

has_capability

has_capability(capability: str) -> bool

Check if a specific capability is enabled.

Parameters:

Name Type Description Default
capability str

Name of capability to check. Can be a boolean capability (e.g., "can_delegate_tasks") or an access level (e.g., "history_access")

required
Source code in src/llmling_agent/config/capabilities.py
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
def has_capability(self, capability: str) -> bool:
    """Check if a specific capability is enabled.

    Args:
        capability: Name of capability to check.
                  Can be a boolean capability (e.g., "can_delegate_tasks")
                  or an access level (e.g., "history_access")
    """
    match capability:
        case str() if hasattr(self, capability):
            value = getattr(self, capability)
            return bool(value) if isinstance(value, bool) else value != "none"
        case _:
            msg = f"Unknown capability: {capability}"
            raise ValueError(msg)

Show source on GitHub