Application classes to be discoverable and usable by AI agents, they need to be explicitly exposed. This is primarily achieved through the list_tools() method of your application and the ToolManager.
The list_tools() Method
Every class that inherits from BaseApplication (including APIApplication and GraphQLApplication) must implement the list_tools() method.
This method should return a list of the callable methods within that application class that you intend to make available as tools.
Example:
get_itemandcreate_itemare intended as tools._internal_helper_methodis a private/internal helper and is not included in the list returned bylist_tools(), so it won’t be exposed as a tool.
Tool Registration via ToolManager
The ToolManager is responsible for collecting these exposed tool methods and transforming them into fully-fledged Tool objects with all the necessary metadata (name, description, parameters, etc.).
When you have an instance of your application, you use the ToolManager’s register_tools_from_app() method:
register_tools_from_app method will:
- Call the
app.list_tools()method to get the list of callable functions. - For each function, it creates a
Toolinstance usingTool.from_function(). - It automatically prefixes the tool name with the application’s name (e.g.,
mywebapp_get_item) to avoid naming conflicts if you register tools from multiple applications. - It also adds the application’s name as a tag to the tool for easier filtering.
- It stores these
Toolobjects internally.
tool_names or tags in register_tools_from_app to selectively register only a subset of tools from an application.
How AI Agents Discover Tools
Once tools are registered in theToolManager, AI agent frameworks (like Langchain or OpenAI Functions) can query the ToolManager to get a list of available tools in a compatible format (e.g., OpenAI JSON schema). The ToolManager.list_tools(format="openai") or ToolManager.list_tools(format="langchain") methods are used for this.
The descriptions and parameter schemas generated for each tool are critical for the AI agent to understand:
- What each tool does.
- When it should be used.
- What inputs it requires.
list_tools() in your applications and using ToolManager to register them, you make your application’s functionalities available to AI agents in a structured and discoverable manner.
Refer to tools/manager.py for more information