Write a custom tool

A custom tool is a function you write. The agent may call it when the description matches the task.

Add the tool

  1. Open the agent.
  2. Choose Add custom tool.
  3. Set Tool name. Use letters, numbers, underscores, and hyphens.
  4. Set Description. This is what tells the agent when to call the tool.
  5. Write the function in Code editor. It is an async function, the same shape as a workflow node.
  6. Set Schema (JSON object). List the fields the agent must fill. Keep {} when the tool needs no input.
  7. Save the agent and run it with a sentence that needs this tool.

You should see the tool name in the run timeline. The schema is a JSON object with type, properties, and required.

{
  "type": "object",
  "properties": {
    "query": { "type": "string" }
  },
  "required": ["query"]
}

If this fails: the tool does not save

  • Custom tool 1: name is required. Fill Tool name.
  • Custom tool 1: code is required. The code editor is empty.
  • Custom tool 1: schema JSON is invalid. The schema is not a JSON object. Predefined tool schema JSON is invalid. is the same problem on a built-in tool you edited.
  • invalid tool after save means the function does not compile. The agent stays unavailable until you fix that function.