Tools & Function Calling
RadarOS agents can call external functions (tools) during a run. Tools are defined withdefineTool(), validated with Zod schemas, and executed automatically when the LLM decides to use them.
defineTool()
UsedefineTool() to create a type-safe tool definition:
Tool Definition Anatomy
name
name
Unique identifier for the tool. The LLM uses this to invoke the tool. Use camelCase (e.g.
getWeather, searchDatabase).description
description
Natural language description of what the tool does. The LLM uses this to decide when to call the tool. Be clear and specific.
parameters
parameters
A Zod object schema defining the tool’s input. Use
.describe() on fields to help the LLM understand each parameter. The schema is converted to JSON Schema for the provider.execute
execute
Async function that runs when the tool is called. Receives parsed
args (typed from the schema) and RunContext. Returns a string or ToolResult (with optional artifacts).Examples
Weather Tool
Calculator Tool
Multiple Tools on an Agent
Pass an array of tools to the agent:ToolResult Type
Instead of returning a plain string, return aToolResult to include optional artifacts:
Tool Artifacts
Artifacts are optional metadata attached to a tool result. They are stored inToolCallResult and can be used by your application (e.g., for rendering charts, displaying images, or logging). The LLM only sees the content string.
Parallel Tool Execution
When the LLM returns multiple tool calls in a single turn, RadarOS executes them in parallel (batches of up to 5 by default). Each tool call is validated against its schema; invalid arguments produce an error result for that call only.Tool Caching
Add acache property to any tool to cache results and avoid redundant executions:
Strict Mode (OpenAI Structured Outputs)
Enablestrict on a tool to activate OpenAI’s Structured Outputs for tool calls. When enabled, the model is guaranteed to return valid JSON matching the schema — no malformed arguments.
strict is true, RadarOS automatically:
- Strips verbose JSON Schema metadata (
$schema,additionalPropertieson nested objects) - Sets
additionalProperties: falseat the top level (required by OpenAI) - Passes
strict: trueto the OpenAI function definition
Strict mode is only supported by OpenAI models. For other providers, the
strict option is ignored.Sandbox & Approval
Tools support two additional safety features:sandbox— Run the tool in an isolated subprocess with timeout and memory limits. See Sandbox Execution.requiresApproval— Require human approval before executing the tool. See Human-in-the-Loop.