{"record":{"id":"f25265284d78c2d2","repo":"run-llama/llama_index","slug":"expected-actionreasoningstep-got-reasoning-step","errorCode":null,"errorMessage":"Expected ActionReasoningStep, got {reasoning_step}","messagePattern":"Expected ActionReasoningStep, got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/agent/workflow/react_agent.py","lineNumber":246,"sourceCode":"        current_reasoning.append(reasoning_step)\n        await ctx.store.set(self.reasoning_key, current_reasoning)\n\n        # If response step, we're done\n        raw = (\n            last_chat_response.raw.model_dump()\n            if isinstance(last_chat_response.raw, BaseModel)\n            else last_chat_response.raw\n        )\n        if reasoning_step.is_done:\n            return AgentOutput(\n                response=last_chat_response.message,\n                raw=raw,\n                current_agent_name=self.name,\n            )\n\n        reasoning_step = cast(ActionReasoningStep, reasoning_step)\n        if not isinstance(reasoning_step, ActionReasoningStep):\n            raise ValueError(f\"Expected ActionReasoningStep, got {reasoning_step}\")\n\n        # Create tool call\n        tool_calls = [\n            ToolSelection(\n                tool_id=str(uuid.uuid4()),\n                tool_name=reasoning_step.action,\n                tool_kwargs=reasoning_step.action_input,\n            )\n        ]\n\n        return AgentOutput(\n            response=last_chat_response.message,\n            tool_calls=tool_calls,\n            raw=raw,\n            current_agent_name=self.name,\n        )\n\n    async def handle_tool_call_results(","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/agent/workflow/react_agent.py#L228-L264","documentation":"ReActAgent parses each LLM response into a reasoning step via structured output. If the parsed output reports is_done=False it must be an ActionReasoningStep (thought + action + action_input) so a tool call can be built. Any other pydantic subclass — e.g. a ResponseReasoningStep or ObservationReasoningStep sneaking through with is_done=False — triggers this ValueError.","triggerScenarios":"Using ReActAgent with an LLM whose structured-output parsing returns an unexpected ReasoningStep subtype with is_done=False; swapping output_cls or customizing react_agent_system_prompt so the model emits the wrong schema; weak models that produce malformed ReAct output under structured output modes.","commonSituations":"Using ReActAgent with llm.structured output on models that follow the wrong branch of the ReAct prompt; upgrading llama-index versions where the ReAct agent moved from text parsing to structured output; overriding agent reasoning step classes.","solutions":["Use a model with reliable structured/JSON output (OpenAI gpt-4o-class, Claude, etc.) with ReActAgent.","Avoid overriding the ReAct system prompt or output_cls; use FunctionAgent for plain function-calling models instead.","Upgrade llama-index-core — the structured ReAct path has had fixes for edge cases.","If it happens sporadically, retry the run; borderline model outputs can parse differently per attempt."],"exampleFix":"# before\nagent = ReActAgent(tools=[tool], llm=weak_local_llm)  # parses into wrong step type\n\n# after\nagent = FunctionAgent(tools=[tool], llm=weak_local_llm)  # uses native tool calling","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        result = await agent.run(user_msg=q)\n        break\n    except ValueError as e:\n        if \"Expected ActionReasoningStep\" not in str(e) or attempt == 1:\n            raise","preventionTips":["Prefer FunctionAgent over ReActAgent for models with native tool calling.","Use strong structured-output models with ReActAgent.","Do not override ReAct output schemas/prompts unless you control the step classes."],"tags":["react-agent","structured-output","llm","parsing"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}