{"record":{"id":"00bc8b8a9bcbddf3","repo":"FoundationAgents/OpenManus","slug":"no-primary-agent-available","errorCode":null,"errorMessage":"No primary agent available","messagePattern":"No primary agent available","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"app/flow/planning.py","lineNumber":98,"sourceCode":"        Can be extended to select agents based on step type/requirements.\n        \"\"\"\n        # If step type is provided and matches an agent key, use that agent\n        if step_type and step_type in self.agents:\n            return self.agents[step_type]\n\n        # Otherwise use the first available executor or fall back to primary agent\n        for key in self.executor_keys:\n            if key in self.agents:\n                return self.agents[key]\n\n        # Fallback to primary agent\n        return self.primary_agent\n\n    async def execute(self, input_text: str) -> str:\n        \"\"\"Execute the planning flow with agents.\"\"\"\n        try:\n            if not self.primary_agent:\n                raise ValueError(\"No primary agent available\")\n\n            # Create initial plan if input provided\n            if input_text:\n                await self._create_initial_plan(input_text)\n\n                # Verify plan was created successfully\n                if self.active_plan_id not in self.planning_tool.plans:\n                    logger.error(\n                        f\"Plan creation failed. Plan ID {self.active_plan_id} not found in planning tool.\"\n                    )\n                    return f\"Failed to create plan for: {input_text}\"\n\n            result = \"\"\n            while True:\n                # Get current step to execute\n                self.current_step_index, step_info = await self._get_current_step_info()\n\n                # Exit if no more steps or plan completed","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/FoundationAgents/OpenManus/blob/52a13f2a57d8c7f6737eefb02ccf569594d44273/app/flow/planning.py#L80-L116","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nflow = PlanningFlow({})\nawait flow.execute(\"do something\")  # ValueError\n\n# after\nflow = PlanningFlow({\"default\": planning_agent, \"executor\": worker_agent})\nawait flow.execute(\"do something\")","handlingStrategy":"validation","validationCode":"def flow_has_primary(agents) -> bool:\n    if isinstance(agents, dict):\n        return bool(agents) and (\"default\" in agents or any(bool(a) for a in agents.values()))\n    return bool(agents)","typeGuard":null,"tryCatchPattern":"try:\n    result = await flow.execute(text)\nexcept ValueError as e:\n    if \"No primary agent\" in str(e):\n        result = \"no agent configured; skipping plan\"\n    else:\n        raise","preventionTips":["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"],"tags":["flow","planning","agent","validation"],"backgroundTag":null,"analyzedSha":"52a13f2a57d8c7f6737eefb02ccf569594d44273","analyzedAt":"2026-08-15T02:33:49.993Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}