How to Create a Tool?
You can create custom tools to work with the tool parameter of the agentmake function.
An agentmake tool takes actions to resolve user requests through function calling.
Each tool is defined in a Python file (.py) specifying the following variables:
1. TOOL_SCHEMA (Required)
The JSON schema describing the parameters for function calling.
- If you want to pass the whole conversation for the tool to process, assign an empty dictionary (
{}) toTOOL_SCHEMA. In this case,agentmakepasses themessagesparameter toTOOL_FUNCTION.
2. TOOL_FUNCTION (Required)
The function object called by the tool.
Arguments:
- Structured Output: Unpacked arguments from the dictionary generated according to
TOOL_SCHEMA. **kwargs: REQUIRED. Theagentmakefunction passes runtime parameters (e.g.,backend,model,api_key) providing the ability to run nestedagentmakecalls within your tool.
Return Values:
- Empty string (
""): User request resolved without needed chat extension. Any printed output is taken as the assistant's response. - Non-empty string: Provides context to extend the chat conversation.
None: Fall back to regular chat completion (useful for error handling).
3. TOOL_SYSTEM (Optional)
System message for running the tool.
- Specify a string for the system message.
- Assign an empty string
""to avoid using a tool system message. - Omit to use the default
agentmaketool system message.
4. TOOL_DESCRIPTION (Optional)
Description of the tool.
- Optional if the tool description is already specified within
TOOL_SCHEMA.
Example Structure:
def my_tool_function(param1, **kwargs):
# Tool logic
return "Result"
TOOL_SCHEMA = {
"type": "object",
"properties": {
"param1": {"type": "string"}
}
}
TOOL_FUNCTION = my_tool_function
For practical examples, check our built-in tools at https://github.com/eliranwong/agentmake/tree/main/agentmake/tools.