Skip to main content

Overview

Kortix provides a flexible framework for creating custom tools that extend agent capabilities. This guide covers everything from basic tool creation to advanced patterns and best practices.

Tool Structure

All custom tools inherit from the Tool base class and use decorators to define metadata and schemas.

Basic Tool Template

Step-by-Step Guide

Step 1: Import Required Components

Step 2: Define Tool Metadata

Use the @tool_metadata decorator to provide information about your tool:
Metadata Parameters:
  • display_name - Human-readable name shown in UI
  • description - Short description (1-2 sentences)
  • icon - Icon name from your icon library
  • color - Tailwind CSS color classes for UI
  • is_core - Whether tool is always enabled
  • weight - Sort priority (lower = higher priority)
  • visible - Whether shown in frontend UI
  • usage_guide - Detailed markdown documentation for AI

Step 3: Initialize Tool Resources

Step 4: Define Tool Methods with OpenAPI Schemas

Step 5: Add Multiple Methods

Real-World Example: API Integration Tool

Here’s a complete example integrating with an external API:

Advanced Patterns

1. Sandbox-Aware Tools

For tools that need access to the sandbox environment:

2. Stateful Tools

Tools that maintain state across calls:

3. Tools with Method-Level Metadata

Registering Custom Tools

Add to Tool Registry

Edit core/tools/tool_registry.py:

Dynamic Registration

Testing Custom Tools

Best Practices

1. Error Handling

2. Input Validation

3. Async Operations

4. Resource Cleanup

5. Comprehensive Documentation

method_name(param1=“value”, param2=123)

Next Steps