Skip to main content

Overview

Tools are the mechanism through which OrbitAI agents interact with the external world and perform specialized operations. They enable agents to go beyond language processing to take concrete actions, access external resources, and manipulate data.

Extensible

Built-in tools and custom tool creation support

Type-Safe

JSON Schema validation ensures correct usage

Async-Ready

Fully asynchronous execution with Swift Concurrency

Traceable

Comprehensive metrics and execution tracking

Intelligent

LLM-driven automatic tool selection

Composable

Combine tools for complex workflows

Key Capabilities

Agents automatically determine which tools to use based on task requirements, available tools, and context. The LLM reasons about tool usage and orchestrates multi-tool workflows.
Every tool defines its input parameters using JSON Schema, ensuring type safety and preventing invalid tool usage before execution.
Tool execution is monitored with detailed metrics including execution time, success status, input/output sizes, and error information.
Built-in error handling mechanisms ensure graceful failures with detailed error messages and recovery strategies.

Tool Architecture

Built-in Tools

OrbitAI includes a comprehensive suite of built-in tools for common operations:

File & Data Operations

file_reader

Description: Read and process file contents Parameters: path (string), encoding (optional) Returns: File contents as string or data

file_writer

Description: Write or update file contents Parameters: path (string), content (string), mode (append/overwrite) Returns: Success status and file path

directory_list

Description: List directory contents with filtering Parameters: path (string), recursive (boolean), filter (regex) Returns: Array of file/directory information

csv_processor

Description: Parse and manipulate CSV data Parameters: file_path (string), operation (read/write/transform) Returns: Structured data or success status

data_analyzer

Description: Analyze datasets with statistical operations Parameters: data (array), operations (mean/median/std/etc) Returns: Statistical analysis results

Web & Network Tools

web_search

Description: Search the internet for current information Parameters: query (string), num_results (integer, 1-10) Returns: Array of search results with URLs and snippets

web_scraping

Description: Extract content from web pages Parameters: url (string), selectors (CSS/XPath) Returns: Extracted content and metadata

api_caller

Description: Make HTTP requests to external APIs Parameters: url, method, headers, body, auth Returns: Response data and status

geocoding

Description: Convert addresses to coordinates and vice versa Parameters: query (string), type (forward/reverse) Returns: Location data with coordinates

Apple Platform Integration

apple_calendar

Description: Interact with Apple Calendar (EventKit) Parameters: operation (read/create/update/delete), event_data Returns: Calendar events or success status

apple_reminders

Description: Manage Apple Reminders Parameters: operation, reminder_data, list_name Returns: Reminders or success status

local_notifications

Description: Schedule and manage local notifications Parameters: title, body, trigger, identifier Returns: Notification identifier and delivery status

core_location

Description: Access device location services Parameters: accuracy (best/kilometer/etc), continuous (boolean) Returns: Location coordinates and metadata

weather_kit

Description: Retrieve weather information using WeatherKit Parameters: location (coordinates/place), forecast_type Returns: Weather data and forecasts

Computation Tools

calculator

Description: Perform mathematical calculations Parameters: expression (string), precision (integer) Returns: Calculation result

code_executor

Description: Execute code in sandboxed environment Parameters: code (string), language (python/swift/js) Returns: Execution output and status

chart_generator

Description: Create data visualizations Parameters: data, chart_type, styling Returns: Chart image or data URL
Built-in tools are automatically registered with ToolsHandler when OrbitAI initializes. No manual registration is required.

Tool Assignment

Tools can be assigned at both the agent and task levels, providing flexibility in tool availability and usage.

Agent-Level Tools

Assign tools to an agent to define its general capabilities across all tasks:
When to use: When tools are fundamental to the agent’s role and will be used across multiple tasks.

Task-Level Tools

Assign tools to specific tasks for fine-grained control:
When to use: When specific tools are only needed for particular tasks or to restrict tool usage.

Agent Tools vs Task Tools

When both agent and task define tools, OrbitAI uses the following resolution logic:
Key Rules:
  1. If task has tools defined → Use only task tools
  2. If task has no tools → Use agent tools
  3. Task tools override agent tools (not merge)
  4. Empty tool list [] means no tools available
Task tools completely override agent tools—they do not merge. If you need agent tools plus additional task tools, explicitly list all required tools in the task definition.

Creating Custom Tools

Custom tools enable integration with proprietary systems, external APIs, and domain-specific functionality.

Basic Custom Tool

Create a custom tool by extending BaseTool:
1

Define Tool Class

2

Define Parameters Schema

3

Implement Execute Method

4

Register Tool

Advanced Custom Tool Example

Here’s a more sophisticated tool with error handling, validation, and metrics:
Always return detailed error messages in ToolResult when execution fails. This helps agents understand what went wrong and potentially retry with corrected parameters.

Tool Integration

With LLM Function Calling

OrbitAI integrates tools with LLM function calling for intelligent tool usage:

Multi-Tool Workflows

Agents automatically orchestrate multi-tool workflows:

Tool Chaining

Tools can use outputs from previous tools:
The agent automatically chains tool outputs as inputs to subsequent tools based on the LLM’s reasoning about the task flow.

Tool Execution

Execution Lifecycle

Execution Model

All tool execution in OrbitAI is asynchronous using Swift Concurrency:

Timeout Handling

Implement timeouts for long-running tools:

Advanced Tool Setup

Tool Registry & Management

The ToolsHandler singleton manages all tools:

Enabling/Disabling Tools

Control tool availability dynamically:

Tool Introspection

Tools can be introspected for debugging and documentation:

Tool Versioning

Support multiple versions of the same tool:

Usage and Metrics

Tool Usage Tracking

OrbitAI automatically tracks tool usage with detailed metrics:

Accessing Tool Metrics

Performance Monitoring

Create custom monitoring for tool performance:

Cost Tracking for External APIs

Track costs for tools that call paid APIs:

Error Handling

Common Tool Errors

Cause: Parameters don’t match the schema or fail validation.Solution:
Cause: Agent references a tool that hasn’t been registered with ToolsHandler.Solution:
Cause: Tool operation takes too long to complete.Solution:
Cause: External service is unavailable or returns an error.Solution:
Cause: Tool lacks necessary permissions (file access, location, etc.).Solution:

Error Handling Patterns

Best Practices

Tool Design

Clear Naming

Use descriptive, action-oriented namesGood: send_email, analyze_sentiment, fetch_stock_price Bad: tool1, helper, process

Detailed Descriptions

Write comprehensive descriptions that guide LLM usage

Schema Validation

Define strict schemas with constraints

Single Responsibility

Each tool should do one thing wellGood: Separate read_file and write_file tools Bad: One file_operations tool that does everything

Idempotency

Design tools to be safely re-executable

Error Messages

Return actionable error messagesGood: “File not found at ‘/path/to/file.txt’. Check the path and try again.” Bad: “Error 404”

Performance Optimization

Cache frequently accessed data:

Security Considerations

Always validate and sanitize tool inputs to prevent security vulnerabilities.

Troubleshooting

Common Issues

Symptom: Agent reports tool is unavailable or not found.Diagnosis:
Solutions:
  1. Register the tool before creating the orbit
  2. Check for typos in tool name (names are case-sensitive)
  3. Verify tool is imported and compiled
  4. For built-in tools, ensure OrbitAI version is up to date
Symptom: Tool execution fails with parameter errors.Diagnosis:
Solutions:
  1. Ensure parameter names match schema exactly
  2. Check parameter types (string vs int vs array)
  3. Verify required parameters are provided
  4. Add default values for optional parameters
  5. Improve error messages in tool description
Symptom: Tools take too long to execute.Diagnosis:
Solutions:
  1. Implement caching for repeated queries
  2. Use parallel execution for independent operations
  3. Add timeouts to prevent hanging
  4. Optimize database queries or API calls
  5. Consider batch processing
Symptom: Tool executes successfully but returns wrong results.Diagnosis:
Solutions:
  1. Verify parameter parsing logic
  2. Check data transformations
  3. Validate external API responses
  4. Add unit tests for tool logic
  5. Review LLM’s parameter generation
Symptom: Agent doesn’t select the tool you expect for a task.Diagnosis:
Solutions:
  1. Improve tool description to clarify when to use it
  2. Verify tool is in agent’s or task’s tool list
  3. Add examples in tool description
  4. Adjust task description to hint at tool usage
  5. Check if multiple tools overlap in functionality

Debugging Tools

Create a debugging wrapper for tools:

Next Steps

Explore Built-in Tools

Learn about specific built-in tools and their capabilities

Agent Configuration

Understand how to configure agents with tools

Task Orchestration

Learn how tasks leverage tools for execution

LLM Integration

Understand how LLMs interact with tools

Pro Tip: Start with built-in tools and only create custom tools when you need domain-specific functionality or external integrations not covered by the built-in suite.