{"record":{"id":"c58276ff45a1adbb","repo":"microsoft/graphrag","slug":"function-function-name-not-registered","errorCode":null,"errorMessage":"Function '{function_name}' not registered.","messagePattern":"Function '(.+?)' not registered\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/graphrag-llm/graphrag_llm/utils/function_tool_manager.py","lineNumber":119,"sourceCode":"        -------\n            list[ToolMessage]\n                The list of tool response messages to be added to the message history.\n        \"\"\"\n        if not response.choices[0].message.tool_calls:\n            return []\n\n        tool_messages: list[ToolMessage] = []\n\n        for tool_call in response.choices[0].message.tool_calls:\n            if tool_call.type != \"function\":\n                continue\n            tool_id = tool_call.id\n            function_name = tool_call.function.name\n            function_args = tool_call.function.arguments\n\n            if function_name not in self._tools:\n                msg = f\"Function '{function_name}' not registered.\"\n                raise ValueError(msg)\n\n            tool_def = self._tools[function_name]\n            input_model = tool_def[\"input_model\"]\n            function = tool_def[\"function\"]\n\n            try:\n                parsed_args_dict = json.loads(function_args)\n                input_model_instance = input_model(**parsed_args_dict)\n            except Exception as e:\n                msg = f\"Failed to parse arguments for function '{function_name}': {e}\"\n                raise ValueError(msg) from e\n\n            result = function(input_model_instance)\n            tool_messages.append({\n                \"content\": result,\n                \"tool_call_id\": tool_id,\n            })\n","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/microsoft/graphrag/blob/f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704/packages/graphrag-llm/graphrag_llm/utils/function_tool_manager.py#L101-L137","documentation":"FunctionToolManager.call_functions iterates tool_calls from the LLM response and looks each function name up in the registered _tools dict. If the model emitted a function name that was never registered via register_function, a ValueError is raised.","triggerScenarios":"Calling call_functions on a response whose tool_calls reference a function you never registered, or registered under a different name than the one given to the LLM's tools schema.","commonSituations":"Registering the Pydantic input model under one name but telling the LLM a different tool name, adding a tool to the LLM prompt but forgetting register_function, or the model hallucinating a plausible tool name.","solutions":["Register the missing function with the exact name the LLM sees: manager.register_function(name, input_model, function)","Make the registration name and the tool schema name identical strings","Re-list registered names (manager._tools.keys() or your registry) to spot mismatches","If the model hallucinates the name, tighten the tool descriptions/prompt"],"exampleFix":"# before\nmanager.register_function('get_weather', GetWeatherInput, get_weather)\n# but LLM tool schema says 'lookup_weather' -> ValueError\n\n# after\nmanager.register_function('lookup_weather', GetWeatherInput, get_weather)","handlingStrategy":"validation","validationCode":"registered = set(manager._tools)  # or expose a public list\nfor call in response.tool_calls:\n    assert call.function.name in registered, f\"unregistered tool {call.function.name}\"","typeGuard":"def all_tools_registered(manager, response) -> bool:\n    return all(c.function.name in manager._tools for c in response.tool_calls or [])","tryCatchPattern":"try:\n    manager.call_functions(response)\nexcept ValueError as e:\n    if 'not registered' in str(e):\n        # skip/acknowledge unknown tool and continue the loop\n        ...\n    else:\n        raise","preventionTips":["Build the LLM tool schemas and the registry from one source of truth (name -> model -> fn)","Register every advertised tool before the first completion call"],"tags":["function-calling","tools","llm","graphrag"],"backgroundTag":"unregistered-function-name-in-tool-call","analyzedSha":"f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704","analyzedAt":"2026-08-27T11:16:29.677Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}