ToolNotFoundError
composio.errors.ToolNotFoundError
Stack trace
Traceback (most recent call last):
File "app.py", line 42, in <module>
result = composio_client.invoke_tool_action("nonexistent_tool", "run") # triggers error
File "/usr/local/lib/python3.9/site-packages/composio/client.py", line 88, in invoke_tool_action
raise ToolNotFoundError(f"Tool action '{action}' not found for tool '{tool_name}'")
composio.errors.ToolNotFoundError: Tool action 'run' not found for tool 'nonexistent_tool' Why it happens
This error occurs because the Composio client attempts to invoke a tool action that has not been registered or does not exist in the current toolset. It typically happens when the tool name or action string is misspelled, or the tool was not properly loaded or initialized.
Detection
Monitor for ToolNotFoundError exceptions during tool invocation calls and log the requested tool and action names to detect missing or misconfigured tools before crashing.
Causes & fixes
The tool name passed to the Composio client does not match any registered tool.
Verify the tool name spelling and ensure the tool is registered with composio_client.register_tool() before invoking actions.
The requested action name is not implemented or registered for the specified tool.
Check the tool's available actions and confirm the action string matches exactly, including case sensitivity.
The tool was not properly initialized or loaded before invoking its actions.
Ensure all tools are fully initialized and registered in the composio client setup phase before any action calls.
Code: broken vs fixed
from composio import ComposioClient
client = ComposioClient()
# This will raise ToolNotFoundError because 'nonexistent_tool' is not registered
result = client.invoke_tool_action("nonexistent_tool", "run") # triggers error
print(result) import os
from composio import ComposioClient
client = ComposioClient()
# Register the tool properly before invoking
client.register_tool("example_tool", tool_instance)
# Correct tool and action names
result = client.invoke_tool_action("example_tool", "run") # fixed
print(result) # prints the action result Workaround
Catch ToolNotFoundError exceptions around tool invocation calls and provide a fallback action or user-friendly error message to avoid crashing.
Prevention
Implement a tool registry validation step during startup to verify all required tools and actions are registered and available before runtime.