{"record":{"id":"25013059df89b19d","repo":"run-llama/llama_index","slug":"fn-or-async-fn-must-be-provided","errorCode":null,"errorMessage":"fn or async_fn must be provided.","messagePattern":"fn or async_fn must be provided\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/tools/function_tool.py","lineNumber":90,"sourceCode":"    \"\"\"\n    Function Tool.\n\n    A tool that takes in a function, optionally handles workflow context,\n    and allows the use of callbacks. The callback can return a new ToolOutput\n    to override the default one or a string that will be used as the final content.\n    \"\"\"\n\n    def __init__(\n        self,\n        fn: Optional[Callable[..., Any]] = None,\n        metadata: Optional[ToolMetadata] = None,\n        async_fn: Optional[AsyncCallable] = None,\n        callback: Optional[Callable[..., Any]] = None,\n        async_callback: Optional[Callable[..., Any]] = None,\n        partial_params: Optional[Dict[str, Any]] = None,\n    ) -> None:\n        if fn is None and async_fn is None:\n            raise ValueError(\"fn or async_fn must be provided.\")\n\n        # Handle function (sync and async)\n        self._real_fn = fn or async_fn\n        if async_fn is not None:\n            self._async_fn = async_fn\n            self._fn = fn or async_to_sync(async_fn)\n        else:\n            assert fn is not None\n            if inspect.iscoroutinefunction(fn):\n                self._async_fn = fn\n                self._fn = async_to_sync(fn)\n            else:\n                self._fn = fn\n                self._async_fn = sync_to_async(fn)\n\n        # Determine if the function requires context by inspecting its signature\n        fn_to_inspect = fn or async_fn\n        assert fn_to_inspect is not None","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/tools/function_tool.py#L72-L108","documentation":"Error \"fn or async_fn must be provided.\" thrown in run-llama/llama_index.","triggerScenarios":"Thrown at llama-index-core/llama_index/core/tools/function_tool.py:90 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide fn (or async_fn) when constructing the FunctionTool.","Use FunctionTool.from_defaults(fn=my_function)."],"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"}