Skip to content

Agents

Waldiez agents model.

WaldiezAgents

Bases: WaldiezBase

Waldiez agents model.

Attributes:

NameTypeDescription
usersList[WaldiezUserProxy]

User proxy agents.

assistantsList[WaldiezAssistant]

Assistant agents.

managersList[WaldiezGroupManager]

Group chat managers.

rag_usersList[WaldiezRagUser]

RAG user agents.

members: Iterator[WaldiezAgent] property

Get all agents.

Yields:

TypeDescription
WaldiezAgent

The agents.

validate_agents() -> Self

Validate the agents.

  • At least two agents are required.
  • All the agent IDs must be unique.

Returns:

TypeDescription
WaldiezAgents

The agents.

Raises:

TypeDescription
ValueError

If the agents are invalid.

Source code in waldiez/models/agents/agents.py
@model_validator(mode="after")
def validate_agents(self) -> Self:
    """Validate the agents.

    - At least two agents are required.
    - All the agent IDs must be unique.

    Returns
    -------
    WaldiezAgents
        The agents.

    Raises
    ------
    ValueError
        If the agents are invalid.
    """
    all_agent_ids = [agent.id for agent in self.members]
    if len(all_agent_ids) < 1:
        raise ValueError("At least one agent is required.")
    if len(all_agent_ids) != len(set(all_agent_ids)):
        raise ValueError("Agent IDs must be unique.")
    return self

validate_flow(model_ids: List[str], skill_ids: List[str]) -> None

Validate the flow of the agents.

  • Validate the linked models (the referenced model ids must exist).
  • Validate the linked skills (the referenced skill ids must exist).
  • Validate the code execution (the referenced functions must exist).

Parameters:

NameTypeDescriptionDefault
model_idsList[str]

The list of model IDs.

required
skill_idsList[str]

The list of skill IDs.

required

Raises:

TypeDescription
ValueError

If the flow is invalid.

Source code in waldiez/models/agents/agents.py
def validate_flow(self, model_ids: List[str], skill_ids: List[str]) -> None:
    """Validate the flow of the agents.

    - Validate the linked models (the referenced model ids must exist).
    - Validate the linked skills (the referenced skill ids must exist).
    - Validate the code execution (the referenced functions must exist).

    Parameters
    ----------
    model_ids : List[str]
        The list of model IDs.
    skill_ids : List[str]
        The list of skill IDs.

    Raises
    ------
    ValueError
        If the flow is invalid.
    """
    all_agent_ids = [agent.id for agent in self.members]
    for agent in self.members:
        agent.validate_linked_models(model_ids)
        agent.validate_linked_skills(skill_ids, agent_ids=all_agent_ids)
        agent.validate_code_execution(skill_ids=skill_ids)
        if agent.agent_type == "manager" and isinstance(
            agent, WaldiezGroupManager
        ):
            agent.validate_transitions(agent_ids=all_agent_ids)