FoundationAgents/OpenManus · error · ValueError
No primary agent available
Error message
No primary agent available
What it means
Raised in PlanningFlow.execute() when self.primary_agent is None. The primary agent drives plan creation and is the fallback executor, so without it the flow cannot proceed. It is usually None because the agents dict passed to the flow was empty, had no default key, or the shared instance default applied.
Source
Thrown at app/flow/planning.py:98
Can be extended to select agents based on step type/requirements.
"""
# If step type is provided and matches an agent key, use that agent
if step_type and step_type in self.agents:
return self.agents[step_type]
# Otherwise use the first available executor or fall back to primary agent
for key in self.executor_keys:
if key in self.agents:
return self.agents[key]
# Fallback to primary agent
return self.primary_agent
async def execute(self, input_text: str) -> str:
"""Execute the planning flow with agents."""
try:
if not self.primary_agent:
raise ValueError("No primary agent available")
# Create initial plan if input provided
if input_text:
await self._create_initial_plan(input_text)
# Verify plan was created successfully
if self.active_plan_id not in self.planning_tool.plans:
logger.error(
f"Plan creation failed. Plan ID {self.active_plan_id} not found in planning tool."
)
return f"Failed to create plan for: {input_text}"
result = ""
while True:
# Get current step to execute
self.current_step_index, step_info = await self._get_current_step_info()
# Exit if no more steps or plan completedView on GitHub (pinned to 52a13f2a57)
Solutions
- Pass at least one agent: PlanningFlow(agents) with a non-empty BaseAgent, list of agents, or dict containing a primary/default entry
- If using a dict, set the primary under the default key (commonly "default") so primary_agent resolves
- Guard before execute(): skip or abort with your own message when flow.primary_agent is None
Example fix
# before
flow = PlanningFlow({})
await flow.execute("do something") # ValueError
# after
flow = PlanningFlow({"default": planning_agent, "executor": worker_agent})
await flow.execute("do something") Defensive patterns
Strategy: validation
Validate before calling
def flow_has_primary(agents) -> bool:
if isinstance(agents, dict):
return bool(agents) and ("default" in agents or any(bool(a) for a in agents.values()))
return bool(agents) Try / catch
try:
result = await flow.execute(text)
except ValueError as e:
if "No primary agent" in str(e):
result = "no agent configured; skipping plan"
else:
raise Prevention
- Always pass at least one agent to PlanningFlow
- When using a dict, include a primary under the default key
- Assert flow.primary_agent is not None before execute() and fail with your own message
When it happens
Trigger: PlanningFlow({}) or PlanningFlow({"executor1": agent}) with no primary/default key; passing a dict whose default key does not exist; calling execute() before injecting agents. Also when agents is a list of executors only and no primary was designated.
Common situations: Constructing the flow from a config that defines executors but no primary agent key; empty agents mapping during tests; misunderstanding that at least one agent (ideally a default/primary) is required.
Related errors
- Tool calls required but none provided
- Unknown flow type: {flow_type}
- Unrecognized command: {command}. Allowed commands are: creat
- Parameter `plan_id` is required for command: create
- A plan with ID '{plan_id}' already exists. Use 'update' to m
AI-assisted analysis of FoundationAgents/OpenManus@52a13f2a57 (2026-08-15).
Data as JSON: /api/errors/00bc8b8a9bcbddf3.
Report an issue: GitHub.