Skip to main content

What is Lua?

Lua is a platform for building AI agents with custom capabilities. Think of it like:

Skills

A skill is a collection of related tools that give your AI agent specific capabilities.

Example: Coffee Shop Skill

Skill Properties

string
required
Unique identifier for the skill (e.g., “coffee-shop-skill”)
string
required
Brief description (1-2 sentences) of what the skill does
string
required
Detailed instructions for the AI on when and how to use the tools. This is critical for proper tool selection!
LuaTool[]
Array of tool instances to include in the skill
function
Optional async function that determines if the whole skill is available
When it returns false the skill’s tools can’t be called and its name, context, and tool names are left out of the agent’s prompt — the agent doesn’t know the capability exists. Use it for tiering and entitlements, where the existence of a feature is itself sensitive. Fail-closed: a condition that throws or times out hides the skill.See Conditional Skills and Skill condition vs tool condition.

Writing Good Context

The context field guides the AI’s decision-making. Write it like instructions to a smart assistant:

Tools

A tool is a single function that the AI can call to accomplish a specific task.

Anatomy of a Tool

Tool Properties

string
required
Unique identifier using only: a-z, A-Z, 0-9, -, _Examples: get_weather, create-product, sendEmail123
string
required
Clear, concise description (1 sentence) of what the tool doesHelps the AI understand when to use this tool
ZodType
required
Zod schema that validates inputs at runtimeProvides automatic validation and TypeScript types
function
required
Async function that implements the tool’s logic
function
Optional async function that determines if the tool should be available
Use for premium features, feature flags, channel-specific tools, or user-specific availability.A hidden tool is left out of the prompt’s tool list, but the skill’s name and context stay — the agent can still tell the user the capability exists. To hide a capability entirely, gate the skill instead: Skill condition vs tool condition.Access the current channel via Lua.request.channel and raw webhook data via Lua.request.webhook?.payload - see Lua API.

Sharing Tool Logic Across Agents

When you build multiple agents that share behaviour — same search backend, same external API, same auth flow — factor the shared parts into a base class and have each agent declare a thin subclass that overrides only the bits that differ.
How it works:
  • The lua compiler walks the full extends chain. A leaf that extends a shared base which itself extends LuaTool is detected as a tool.
  • Field initializers on the leaf (ragSearchPath = '/blk/search') override the parent’s defaults. When execute() runs and reads this.ragSearchPath, it sees the leaf’s value — JavaScript’s normal inheritance semantics.
  • The leaf inherits the parent’s inputSchema, description, and execute unless it overrides them. No copy-paste.
Don’t pass per-reference constructor arguments inside a tools: [...] array:
The compiler will warn (lua/constructor-args-dropped) if it sees this pattern. Use a subclass with a field override instead.

Skills vs Tools

Single Function

How It Works

1

User Request

User asks the AI: “What’s the weather in London?”
2

Tool Selection

AI reads the skill’s context and determines get_weather tool is appropriate
3

Input Validation

AI provides input: { city: "London" }Input is validated against inputSchema
4

Tool Execution

The execute function runs with validated inputCalls weather API and returns structured data
5

AI Response

AI uses the tool’s output to form a natural language response“The weather in London is 15°C and cloudy.”

Tool Naming Best Practices

Good Names

  • search_products
  • create_order
  • cancel_booking
  • get_user_profile

Bad Names

  • do_search (too generic)
  • process (unclear)
  • tool1 (not descriptive)
  • get data (spaces not allowed)

Creating Your Agent

You configure your entire agent using LuaAgent:
Use LuaAgent to configure persona, welcome message, and skills together in one unified configuration.

Why LuaAgent?

The new LuaAgent pattern provides:
  • Single source of truth - All agent config in one place (code, not YAML)
  • Better organization - Clear separation of persona, skills, webhooks, jobs
  • Auto-sync - CLI auto-manages lua.skill.yaml (do not edit manually)
  • More features - Support for webhooks, jobs, preprocessors, postprocessors

Multiple Skills in One Project

You can organize tools into multiple skills and add them all to your agent:

When to Use Multiple Skills

  • ✅ Tools serve different purposes (e.g., “HR Skill” vs “Sales Skill”)
  • ✅ Different teams own different skills
  • ✅ Skills have different deployment schedules
  • ✅ Skills need different permissions

Example Patterns

Pattern: CRUD Skill

Pattern: Workflow Skill

Pattern: Integration Skill

Next Steps

Platform APIs

Learn about built-in APIs for users, products, and data

Build Your First Skill

Follow a step-by-step tutorial

Tool Examples

Explore 30+ working examples

API Reference

Complete LuaSkill API documentation