Skip to content

Orchestrator needs better error handling when there isn't a agent suitable for the task #317

@kawolum

Description

@kawolum

To reproduce, start the orchestrator without any agents.

orchestrator = Orchestrator(
    name=ORCHESTRATOR_NAME,
    llm_factory=OpenAIAugmentedLLM,
    available_agents=[],
    plan_type="iterative",
)

await orchestrator.generate_str(message="anything")

For actual use case, this can be reproduced with an impossible task that cannot be accomplished with the available agents.

orchestrator = Orchestrator(
    name=ORCHESTRATOR_NAME,
    llm_factory=OpenAIAugmentedLLM,
    available_agents=[data_collection_agent],
    plan_type="iterative",
)

await orchestrator.generate_str(message="Collect data and produce a summary of the data")

They would fail with an error from raise ValueError(f"No agent found matching {task.agent}")

Suggested fixes:

  1. Raise an error with a more useful error message, something like the following:
    1. The planner created a task to {task.description} but there isn't an agent suitable for the task, consider adding an agent.
  2. Improve the system prompt of the planner to the following:
    1. Name of 1 Agent (ONLY using the available agents specified)
  3. I am not sure why List of MCP server names to use for the task is in the prompt. I don't think returning the list of MCP servers works? I think this is for ServerTask but I don't see ServerTask being referenced in Step. Should probably be removed.
    1. https://github.com/lastmile-ai/mcp-agent/blob/main/src/mcp_agent/workflows/orchestrator/orchestrator_prompts.py#L38
    2. https://github.com/lastmile-ai/mcp-agent/blob/main/src/mcp_agent/workflows/orchestrator/orchestrator_prompts.py#L85

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions