Overview
LuaTool is the interface that all tools must implement. A tool is a single function that the AI can call to accomplish a specific task.
Interface Definition
Required Properties
name
Unique identifier for the tool.string
required
Tool name using only:
a-z, A-Z, 0-9, -, _Examples: "get_weather", "create-order", "sendEmail123"Invalid: "get weather", "tool.name", "send@email"description
Clear, concise description of what the tool does.string
required
One sentence describing the tool’s purposeHelps the AI understand when to use this tool
inputSchema
Zod schema that validates and types the input.ZodType
required
Zod schema defining valid inputsProvides runtime validation and TypeScript types
execute
Async function that implements the tool’s logic.function
required
- Input is automatically validated
- Must return a JSON-serializable value
- Can throw errors for failures
Optional Properties
condition
Async function that determines if the tool should be available to the AI.function
- Runs before the tool is offered to the AI
- Return
trueto enable the tool,falseto hide it - If the function throws an error, the tool is disabled (fail-closed)
- Has access to all Platform APIs (User, Data, Products, etc.)
- User subscription status (premium features)
- User verification or account status
- Feature flags or A/B testing
- Region-specific functionality
- Time-based access
Fail-closed behavior: If your condition function throws an error or times out (30s), the tool is automatically disabled. This ensures tools aren’t accidentally exposed when conditions can’t be evaluated.
Implementation Examples
Simple Tool
External API Tool
Platform API Tool
Environment Variables Tool
Multi-Step Tool
Conditional Tool (Premium Feature)
Reusing Tools Across Agents
When multiple agents share the same tool logic — same API, same auth, same shape — but differ on a couple of config values, declare the shared parts on an abstract base and have each agent’s tool extend it. The compiler walks the fullextends chain, so a leaf class is detected as a tool whether it extends LuaTool directly or through any number of intermediate bases.
this.searchPath inside the parent’s execute resolves to '/blk/search'. The leaf inherits inputSchema, description, and execute from the parent unless it overrides them.
Input Schema Patterns
Optional Fields
Validation
Nested Objects
Arrays
Enums
Error Handling
Throwing Errors
Try-Catch Pattern
Return Value Patterns
Structured Data
Lists
Status Updates
Best Practices
Use Type-Safe Inputs
Use Type-Safe Inputs
Add Input Descriptions
Add Input Descriptions
Return Structured Data
Return Structured Data
Always return objects, not strings:
Handle Errors Gracefully
Handle Errors Gracefully
Provide helpful error messages:
Keep Tools Focused
Keep Tools Focused
One tool = one responsibility:
Next Steps
LuaSkill Class
Learn about skills
Platform APIs
Use built-in APIs
Tool Examples
See working examples
Build Your First Skill
Complete tutorial

