{"record":{"id":"1bed4010f1b69d40","repo":"run-llama/llama_index","slug":"context-is-required-for-this-tool","errorCode":null,"errorMessage":"Context is required for this tool","messagePattern":"Context is required for this tool","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/tools/function_tool.py","lineNumber":340,"sourceCode":"        elif isinstance(raw_output, (BaseNode, Document)):\n            return [TextBlock(text=raw_output.get_content())]\n        elif isinstance(raw_output, list) and all(\n            isinstance(item, (BaseNode, Document)) for item in raw_output\n        ):\n            return [TextBlock(text=item.get_content()) for item in raw_output]\n        else:\n            return [TextBlock(text=str(raw_output))]\n\n    def __call__(self, *args: Any, **kwargs: Any) -> ToolOutput:\n        all_kwargs = {**self.partial_params, **kwargs}\n        return self.call(*args, **all_kwargs)\n\n    def call(self, *args: Any, **kwargs: Any) -> ToolOutput:\n        \"\"\"Sync Call.\"\"\"\n        all_kwargs = {**self._field_defaults, **self.partial_params, **kwargs}\n        if self.requires_context and self.ctx_param_name is not None:\n            if self.ctx_param_name not in all_kwargs:\n                raise ValueError(\"Context is required for this tool\")\n\n        raw_output = self._fn(*args, **all_kwargs)\n\n        # Exclude the Context param from the tool output so that the Context can be serialized\n        tool_output_kwargs = {\n            k: v for k, v in all_kwargs.items() if k != self.ctx_param_name\n        }\n\n        # Parse tool output into content blocks\n        output_blocks = self._parse_tool_output(raw_output)\n\n        # Default ToolOutput based on the raw output\n        default_output = ToolOutput(\n            blocks=output_blocks,\n            tool_name=self.metadata.get_name(),\n            raw_input={\"args\": args, \"kwargs\": tool_output_kwargs},\n            raw_output=raw_output,\n        )","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/tools/function_tool.py#L322-L358","documentation":"Error \"Context is required for this tool\" thrown in run-llama/llama_index.","triggerScenarios":"Thrown at llama-index-core/llama_index/core/tools/function_tool.py:340 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass ctx=... when calling a tool that requires context.","Remove the ctx parameter from the function signature if context is not needed."],"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"}