{"record":{"id":"04ff10f2c3eacca7","repo":"run-llama/llama_index","slug":"structured-output-extraction-failed-the-llm-s-too","errorCode":null,"errorMessage":"Structured output extraction failed: the LLM's tool call could not be parsed into {self._output_cls.__name__}. Error: {error_detail}","messagePattern":"Structured output extraction failed: the LLM's tool call could not be parsed into (.+?)\\. Error: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/program/function_program.py","lineNumber":239,"sourceCode":"                \"LLM did not return any tool calls for structured output. \"\n                \"The model was expected to call a function to produce a \"\n                f\"{self._output_cls.__name__} object, but instead returned \"\n                f\"plain text: {agent_response.response!r}. \"\n                \"This can happen when the LLM provider does not honor \"\n                \"tool_choice='required'. Consider using a different model or \"\n                \"switching to PydanticProgramMode.LLM to use text-based \"\n                \"output parsing instead.\"\n            )\n\n        outputs: List[Model] = []\n        for source in agent_response.sources:\n            raw = source.raw_output\n            if source.is_error:\n                # The tool call failed (e.g. Pydantic validation error).\n                # Surface the original exception with context instead of\n                # silently returning a string that will crash downstream.\n                error_detail = str(source.exception) if source.exception else str(raw)\n                raise ValueError(\n                    f\"Structured output extraction failed: the LLM's tool \"\n                    f\"call could not be parsed into \"\n                    f\"{self._output_cls.__name__}. \"\n                    f\"Error: {error_detail}\"\n                )\n            if not isinstance(raw, BaseModel):\n                raise TypeError(\n                    f\"Structured output extraction failed: expected a \"\n                    f\"{self._output_cls.__name__} instance but got \"\n                    f\"{type(raw).__name__}: {raw!r}. \"\n                    f\"This may indicate a bug in the LLM integration's \"\n                    f\"tool call handling.\"\n                )\n            outputs.append(cast(Model, raw))\n\n        if allow_parallel_tool_calls:\n            return outputs\n        else:","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/program/function_program.py#L221-L257","documentation":"Error \"Structured output extraction failed: the LLM's tool call could not be parsed into {self._output_cls.__name__}. Error: {error_detail}\" thrown in run-llama/llama_index.","triggerScenarios":"Thrown at llama-index-core/llama_index/core/program/function_program.py:239 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect error_detail and fix the output_cls schema or the tool call arguments produced by the model.","Retry with a more capable model or simplify the pydantic schema."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}