Skip to content

Tool System

andershsueh edited this page Feb 10, 2026 · 3 revisions

Tool System

📖 Languages: English only | 中文翻译征集中 | 日本語翻訳募集中

ALICE's Tool System enables AI to perform real-world tasks through Function Calling. Instead of just answering questions, ALICE can read files, search directories, execute commands, and more.

Overview

What is Function Calling?

Function Calling allows the LLM to:

  1. Decide when a tool is needed
  2. Choose which tool to use
  3. Provide parameters for the tool
  4. Interpret the tool's results
  5. Generate a natural language response

How It Works

User: "How many TypeScript files are in this project?"
  ↓
LLM thinks: "I need to search for *.ts files"
  ↓
Calls: searchFiles(pattern: "**/*.ts")
  ↓
Tool executes and returns: { count: 25, files: [...] }
  ↓
LLM generates: "This project contains 25 TypeScript files..."

Available Tools

ALICE comes with 7 builtin tools:

Tool Category Description Platform
readFile File System Read file contents All
listFiles File System List directory contents All
searchFiles File System Search files by pattern All
getCurrentDirectory Workspace Get current working directory All
getGitInfo Workspace Get Git repository info All
getCurrentDateTime System Get current date and time All
executeCommand System Execute shell commands All ⚠️

⚠️ = Requires user confirmation for dangerous operations

View detailed documentation for each tool →

Tool Execution Flow

1. Normal Tool Call

User Input
  ↓
LLM Analysis (with tool definitions)
  ↓
Tool Call Decision
  ↓
Execute Tool
  ↓
Return Result to LLM
  ↓
Generate Natural Response

2. Dangerous Command (with Confirmation)

User: "Delete node_modules"
  ↓
LLM decides: executeCommand("rm -rf node_modules")
  ↓
System detects: Dangerous command!
  ↓
Show Confirmation Dialog:
┌─────────────────────────────┐
│ ⚠️  Dangerous Command        │
│ Command: rm -rf node_modules│
│ Confirm? (y/N):             │
└─────────────────────────────┘
  ↓
User confirms: y
  ↓
Execute command
  ↓
Return result

Features

✅ Intelligent Tool Selection

The LLM automatically chooses the right tool:

# Question about time → uses getCurrentDateTime
> You: What time is it?

# Question about files → uses searchFiles or listFiles
> You: Show me all JavaScript files

# Question about Git → uses getGitInfo
> You: What branch am I on?

✅ Real-time Status Display

See exactly what ALICE is doing:

[🔧 readFile] Reading package.json...
[✅ readFile] File read successfully (1024 bytes)

Status indicators:

  • 🔧 = Tool executing
  • ✅ = Success
  • ❌ = Error
  • ⚠️ = Warning/Confirmation needed

✅ Multi-step Tool Calls

ALICE can use multiple tools in sequence:

> You: Find all TypeScript files and tell me the total size

[🔍 searchFiles] Searching for **/*.ts...
[✅ searchFiles] Found 25 files

[📄 readFile] Reading file sizes...
[✅ readFile] Complete

Alice: Found 25 TypeScript files with a total size of 156 KB.

✅ Safe Execution

Dangerous operations require confirmation:

  • File deletion
  • System commands
  • Disk operations
  • Network changes

✅ Cross-platform

All tools work consistently across:

  • Windows (PowerShell)
  • macOS (Bash)
  • Linux (Bash)

Tool Parameters

Tools use JSON Schema for parameter validation:

// Example: searchFiles tool
{
  name: "searchFiles",
  parameters: {
    type: "object",
    properties: {
      pattern: {
        type: "string",
        description: "Glob pattern like '**/*.ts'"
      },
      directory: {
        type: "string",
        description: "Search directory (default: current)"
      }
    },
    required: ["pattern"]
  }
}

Parameters are validated before execution.

Configuration

Enable/Disable Tools

Tools are enabled by default. To disable:

// In settings.jsonc (future feature)
{
  "tools": {
    "enabled": true,
    "whitelist": ["readFile", "listFiles", "searchFiles"]
  }
}

Dangerous Command Protection

Control dangerous command behavior:

{
  // true: Ask for confirmation (default, recommended)
  // false: Execute without asking
  "dangerous_cmd": true
}

Learn more about dangerous commands →

Tool Call Loop

ALICE uses a smart loop to handle complex tasks:

Max Iterations: 5
Current Iteration: 0

While iteration < 5:
  1. Send messages + tool definitions to LLM
  2. Receive response:
     - If text only: Return response, break
     - If tool calls: Execute tools, continue loop
  3. Add tool results to conversation
  4. Iteration++

If exceeded max iterations:
  Throw error: "Too many tool calls"

This prevents infinite loops while allowing multi-step operations.

Performance

Tool execution is fast:

  • File operations: < 100ms
  • Directory listing: < 200ms
  • Git operations: < 500ms
  • Commands: Varies by command

Total overhead: ~1-2 seconds per tool call (including LLM processing)

Limitations

Current Limitations

  1. LM Studio Compatibility

    • Requires Function Calling support
    • Some models may not support tools
    • Recommend: GPT-3.5/4 compatible models
  2. No Tool Streaming

    • Tool execution is synchronous
    • LLM response streams after tools complete
  3. Fixed Tool Set

    • Currently 7 builtin tools
    • Custom tools: Coming soon

Planned Features

  • Custom tool support
  • Tool plugins system
  • Tool result caching
  • Parallel tool execution
  • Tool call history

Examples

See Available Tools for detailed examples of each tool.

Troubleshooting

Tools Not Working

Problem: LLM returns text instead of calling tools

Solutions:

  • Check if your LLM backend supports Function Calling
  • Try with OpenAI API (guaranteed support)
  • Update LM Studio to latest version

Tool Execution Fails

Problem: Tool returns error

Solutions:

  • Check file/directory permissions
  • Verify path is correct
  • See Troubleshooting for specific errors

Learn More

Related

Clone this wiki locally