run-llama/llama_index · error · ValueError
fn or async_fn must be provided.
Error message
fn or async_fn must be provided.
What it means
Error "fn or async_fn must be provided." thrown in run-llama/llama_index.
Source
Thrown at llama-index-core/llama_index/core/tools/function_tool.py:90
"""
Function Tool.
A tool that takes in a function, optionally handles workflow context,
and allows the use of callbacks. The callback can return a new ToolOutput
to override the default one or a string that will be used as the final content.
"""
def __init__(
self,
fn: Optional[Callable[..., Any]] = None,
metadata: Optional[ToolMetadata] = None,
async_fn: Optional[AsyncCallable] = None,
callback: Optional[Callable[..., Any]] = None,
async_callback: Optional[Callable[..., Any]] = None,
partial_params: Optional[Dict[str, Any]] = None,
) -> None:
if fn is None and async_fn is None:
raise ValueError("fn or async_fn must be provided.")
# Handle function (sync and async)
self._real_fn = fn or async_fn
if async_fn is not None:
self._async_fn = async_fn
self._fn = fn or async_to_sync(async_fn)
else:
assert fn is not None
if inspect.iscoroutinefunction(fn):
self._async_fn = fn
self._fn = async_to_sync(fn)
else:
self._fn = fn
self._async_fn = sync_to_async(fn)
# Determine if the function requires context by inspecting its signature
fn_to_inspect = fn or async_fn
assert fn_to_inspect is not NoneView on GitHub (pinned to afd0fef371)
Solutions
- Provide fn (or async_fn) when constructing the FunctionTool.
- Use FunctionTool.from_defaults(fn=my_function).
When it happens
Trigger: Thrown at llama-index-core/llama_index/core/tools/function_tool.py:90 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/25013059df89b19d.
Report an issue: GitHub.