Skip to content

2.7. Tool Calling (Function Calling)

Tool Calling is the feature that transforms an AI model from a passive text generator into an active problem solver. It gives the AI "hands" to interact with the digital world: your file system, the internet, and your computer's internal state.

What is Tool Calling?

Normally, an LLM is limited to the knowledge it was trained on. It can't know what time it is, what files are on your desktop, or what happened in the news today.

Tool Calling bridges this gap. Instead of hallucinating an answer, the model can say: "I need to use the web_search tool to find the current stock price of Apple."

Backend.AI GO intercepts this request, executes the tool securely, and feeds the result back to the model. The model then uses this real data to answer your question.

Why is it Important?

  • Real-Time Knowledge: Access the latest news, weather, and financial data via web search.

  • System Interaction: Read log files, organize folders, or check system health directly through chat.

  • Accuracy: Perform precise mathematical calculations using a calculator instead of relying on the model's approximate arithmetic.

  • Agentic Behavior: It is the foundation of AI Agents. By chaining multiple tool calls (Search -> Read -> Write), the AI can complete complex workflows autonomously.

Compatible Models

Not all models support Tool Calling. You need a model that has been fine-tuned to understand tool definitions and output structured tool requests.

  • Look for the "Tool" Tag: In the Backend.AI GO Model Library, compatible models are marked with a Tool or Function Calling chip.

  • Recommended Models: Gemma 4, Qwen3.6, Llama 4, Mistral Large, and (via cloud integration) GPT-5.4, Gemini 3 Pro, Claude Sonnet 4.6 are excellent choices.

Security & Permissions

Because tools can access your files and run code, security is paramount. Backend.AI GO implements a Risk-Based Permission System.

Risk Levels

Every tool is assigned a risk level:

  • 🟢 Safe (No Risk): Actions that simply read public data or perform calculations.

    • Examples: Calculator, Get Current Time.
    • Behavior: Executed automatically without interrupting you.
  • 🟡 Moderate (Read Access): Actions that read your personal files or access external websites.

    • Examples: Read File, Web Search, List Directory.
    • Behavior: Requires one-time approval per session. Once approved, the agent can use it freely for the rest of the conversation.
  • 🔴 Critical (Write/Execute): Actions that modify data or execute code.

    • Examples: Write File, Delete File, Run Shell Command.
    • Behavior: Requires explicit approval for every single call. The AI cannot delete a file without you clicking "Approve".

Built-in Tools

Tools panel in chat Tools panel in chat

Backend.AI GO ships 31 built-in tools across eight categories. The chat tool selector is derived from the same registry the agent runtime uses, so tool definitions and behavior are identical on both surfaces. The legacy names execute_python, list_files, and run_shell resolve to run_python, list_directory, and run_command, so saved tool selections using the old names keep working via backward-compatible aliases.

1. File System Tools

Tool Description Risk Level
Read File (read_file) Read the contents of a file at the specified path. 🟢 Low
Write File (write_file) Write content to a file at the specified path. 🟡 Medium
List Directory (list_directory) List files and directories at the specified path. 🟢 Low
Create Directory (create_directory) Create a new directory at the specified path. 🟡 Medium
Delete File (delete_file) Delete a file at the specified path. Requires approval for every call. 🔴 High
Move File (move_file) Move or rename a file from one location to another. Requires approval for every call. 🔴 High
Search Files (search_files) Search for files matching a glob pattern (e.g., *.pdf, **/*.ts). 🟢 Low
Search Content (search_content) Search file contents using regex patterns with recursive directory traversal. Automatically skips binary files and large files (>10 MB). 🟢 Low
Diff Files (diff_files) Compare two text files and return a unified diff. Rejects binary files. 🟡 Medium

2. Web Tools

Tool Description Risk Level
Web Search (web_search) Search the web using Brave Search or Google Search (via Serper). Returns relevant results with titles, URLs, and snippets. Requires an API key configured in Settings. 🟢 Low
Fetch URL (fetch_url) Fetch content from a URL. HTML pages are converted to Markdown; Readability-based boilerplate stripping is on by default (pass extract_main_content: false to disable). 🟡 Medium
HTTP Request (http_request) Make an HTTP request with full method support (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS), custom headers, request body, configurable timeout, and SSRF protections. 🟡 Medium

fetch_url Parameters

Parameter Type Required Description
url string Yes The URL to fetch.
extract_main_content boolean No When true (default), applies the Readability algorithm to strip navigation, ads, and boilerplate and return the main article content. Set to false to get the full page converted to Markdown.

3. Utility & System Tools

Tool Description Risk Level
Calculator (calculator) Evaluate mathematical expressions. Supports basic operations (+, -, *, /, ^, %), parentheses, and functions (sqrt, sin, cos, log, exp, etc.). 🟢 Safe
Get Current Time (get_current_time) Get the current date and time. Supports ISO 8601, Unix timestamp, human-readable, and custom strftime formats. 🟢 Safe
System Info (get_system_info) Get system information including CPU, memory, disk, and OS details. Filter by category for specific data. 🟢 Safe
PDF Reader (pdf_reader) Extract text from PDF files with optional page range selection (e.g., 5, 1-10, 1,3,5-10). Supports up to 500 pages per call. 🟡 Medium
Diff Text (diff_text) Compare two text strings and return a unified diff. 🟢 Safe
Image to Base64 (image_to_base64) Convert an image file to a base64 data URI for multimodal LLM input. Supports PNG, JPEG, WebP, and GIF; can resize and convert output format. 🟡 Medium
Image Info (image_info) Get image metadata including dimensions, format, color space, and file size. 🟡 Medium

4. Data Query Tools

Tool Description Risk Level
JSON Query (json_query) Query JSON data using JSONPath syntax. Supports path access, array operations, and filtering. Can read from a string or a file. 🟢 Low
CSV Reader (csv_reader) Read and analyze CSV files with configurable parsing options. Supports column selection, custom delimiters, and row limiting (up to 10,000 rows). 🟢 Low

5. Code Execution Tools

Tool Description Risk Level
Run Python (run_python) Execute Python code in a sandboxed environment and return the output. Each call runs in a fresh process; variables and imports from previous calls are not retained. Network-access modules (socket, urllib, http), process-spawning modules (subprocess, multiprocessing), and system-level modules (ctypes, signal) are blocked. 🔴 Critical
Run Command (run_command) Execute a shell command and return the output. Dangerous commands are blocked by the built-in shell security validator. Requires explicit approval for every call. 🔴 Critical

Python sandbox configuration

When the Python executable is not on your application's PATH (common for desktop apps launched from Finder or the Windows Start menu, or for pyenv/conda environments), the run_python tool will report a "Python interpreter not found" error. Set the interpreter path in Settings → Tools & Extensions → Python sandbox → Python interpreter path to point directly at the executable, for example /usr/local/bin/python3 or C:\Python312\python.exe.

A configured path is validated when code actually runs (the interpreter must report a "Python 3" version string), not at save time.

When submitted code fails (syntax error, runtime exception, non-zero exit, or timeout), the tool result carries success: false and a classified error message, and the error together with captured stderr are displayed prominently in the tool result block in the chat interface.

Code execution filesystem sandbox

run_python and run_command run model-supplied code in a real subprocess. The import blocklist restricts which modules the code can load, but it does not by itself restrict the open builtin or general file I/O. To prevent a tool call from reading, writing, or deleting arbitrary host files, all file access these tools perform is confined to a single sandbox folder:

  • run_python runs with the sandbox folder as its working directory, and the interpreter's file primitives (open, io.open, os.open, and the path-taking os.* functions) are wrapped so any path that resolves outside the sandbox folder (after collapsing .. and following symlinks) raises PermissionError.
  • run_command runs with the sandbox folder as its working directory and rejects path arguments that resolve outside it (for example cat /etc/passwd is denied).
  • Temporary files created with Python's tempfile are redirected into the sandbox folder, so legitimate scratch-file usage keeps working.

Set the folder in Settings → Tools & Extensions → Python sandbox → Code execution sandbox folder. It must be an absolute path. Leave it empty to use the default folder (code-exec-sandbox under the application data directory), which is created automatically the first time a code-execution tool runs.

The same enforcement applies on every surface that runs these tools, the in-app chat, the agent runtime, and the REST POST /api/v1/tools/execute endpoint, because they all dispatch through one shared implementation.

This is application-level confinement, not OS isolation

The sandbox is enforced inside the interpreter and the shell argument parser, not by the operating system. The most direct ways to obtain an unrestricted file handle (spawning a fresh interpreter via subprocess / multiprocessing, or loading native code via ctypes) are already blocked by the import hook, but in-process enforcement cannot be considered a hard security boundary. Because tool calls can be driven by untrusted model output (including indirect prompt injection from fetched content), keep run_python and run_command set to require approval (their default), and only point the sandbox folder at a directory you are comfortable exposing. A full OS-level sandbox (container or seccomp/jail isolation) is planned as the long-term replacement.

6. Audio Tools

Tool Description Risk Level
Audio Transcribe (audio_transcribe) Transcribe audio files to text using Whisper speech-to-text. Supports MP3, WAV, M4A, FLAC, OGG, WebM, MP4, MPEG, MPGA, OGA, and Opus formats. Language can be auto-detected or specified explicitly (e.g., en, ko, ja). Requires a running whisper-server with a loaded Whisper model. 🟡 Medium

audio_transcribe is reported with available_in_headless: false by /api/v1/tools and is not executable through /api/v1/tools/execute. Use the dedicated /api/v1/audio/transcriptions endpoint instead.

audio_transcribe Parameters

Parameter Type Required Description
path string Yes Path to the audio file to transcribe
language string No Language code (e.g., en, ko, ja). Auto-detects if not specified.
timestamps boolean No Include segment timestamps in the output. Defaults to false.
model_size string No Whisper model size: tiny, base, small, or medium.

7. Image Generation Tools

Tool Description Risk Level
Generate Image (generate_image) Generate an image from a text prompt using the user's configured default image model (Settings → Models → Default Image Model). Supports both locally-installed diffusion models (sd-server pool) and cloud Provider image models (routed through continuum-router). Local models are auto-loaded when not already in memory. 🟡 Medium

generate_image is reported with available_in_headless: false by /api/v1/tools and is not executable through /api/v1/tools/execute. Use the dedicated /api/v1/diffusion/generate endpoint instead.

8. Desktop Integration Tools

These tools require the desktop app's process context (system clipboard, native notifications, the agent memory bank) and are not available in headless server mode. The REST /api/v1/tools endpoint still lists these tools, but marks each one with available_in_headless: false, and /api/v1/tools/execute rejects them with a descriptive error. Headless clients filter on this flag instead of receiving the tools as normally executable.

Tool Description Risk Level
Clipboard Read (clipboard_read) Read the current text content from the system clipboard. 🟢 Low
Clipboard Write (clipboard_write) Write text content to the system clipboard, making it available for pasting into other applications. 🟡 Medium
Notification (notification) Send a native desktop system notification with a title and message body. 🟢 Safe
Read Memory (read_memory) Read the agent's own memory bank. Optionally specify a section name to read only that section. 🟢 Low
Write Memory (write_memory) Write content to a named section in the agent's memory bank. Creates the section if it does not exist. 🟢 Low
Search Memory (search_memory) Search across memory banks of all agents in the squad. Returns matching lines with context. 🟢 Low

9. Interactive Tools (Agent Runtime Only)

select_option is intentionally not offered in the one-shot chat tool selector. It requires the agent loop's interactive approval channel to resolve its result, so it cannot function on the chat or REST execution path. It remains fully available to the agent runtime.

Tool Description
Select Option (select_option) Pause the agent and present a set of clickable choices to the user in chat. The user's pick is returned to the model as the tool result, letting the agent branch its behavior based on explicit user input rather than inference. Supports single-select and multi-select modes.

The agent calls select_option when it needs a decision that should come from the user rather than be inferred from context. When the tool fires, the chat shows a widget with labeled buttons; clicking one resumes the run with the chosen value. Cancelling the prompt returns an empty result and the agent continues.

select_option Parameters

Parameter Type Required Description
prompt string Yes The question or instruction shown above the choices.
options array Yes The list of choices. Each choice has an id (returned as the result), a label (shown on the button), and optional description, recommended, priority, and risk fields.
mode string No "single" (default) or "multiple". In multiple mode a Submit button appears so the user can pick several options before confirming.

The LLM never selects the image model; the model is always resolved from Settings → Models → Default Image Model. When the configured model id starts with cloud: (a cloud Provider image model), the request is routed through continuum-router to the registered provider instead of the local sd-server pool. Local diffusion models are auto-loaded into the pool when not already in memory. When no default model is configured, the tool returns an explicit error that the model can relay verbatim, prompting you to configure it.

generate_image Parameters

Parameter Type Required Description
prompt string Yes Detailed text description of the desired image.
negative_prompt string No Things the image should NOT contain.
width integer No Image width in pixels: 512, 768, 1024, or 1792. Defaults to 1024.
height integer No Image height in pixels: 512, 768, 1024, or 1792. Defaults to 1024.
n integer No Number of images to generate (1–4). Defaults to 1.
steps integer No Number of sampling steps (1–100). Defaults to 20.
cfg_scale number No Classifier-free guidance scale (0.1–30.0). Defaults to 7.0.
seed integer No Random seed for reproducibility. Omit or pass -1 for a random seed.

Tool Results in Chat

Tool result displayed in chat

When a tool finishes executing, the result is displayed inline in the chat conversation. You can expand the result block to see the full output, including structured data like file listings, search results, or command output. This transparent display ensures you always know what information the AI is working with.