Expand description
Lua scripted agent runtime.
Loads .lua agent scripts at startup, extracts their metadata (name,
description, tools, arguments), and provides runtime resolution with a
context bridge back into the Rust core (search, get, sources).
§Architecture
Agent scripts follow the same sandboxed Lua VM model as connectors and
tools, reusing all host APIs from crate::lua_runtime. In addition,
agents receive a context table identical to tools:
context.search(query, opts?)— search the knowledge basecontext.get(id)— retrieve a document by UUIDcontext.sources()— list connector status
The agent-specific config from ctx.toml is passed as the second
argument to agent.resolve(args, config, context).
§Script Interface
Every agent script defines a global agent table:
agent = {
name = "my-agent",
description = "Helps with tasks",
tools = { "search", "get" },
arguments = {
{ name = "topic", description = "Focus area", required = false },
},
}
function agent.resolve(args, config, context)
return {
system = "You are a helpful assistant.",
messages = {},
}
end§Configuration
[agents.script.my_agent]
path = "agents/my-agent.lua"
timeout = 30
search_limit = 5See docs/AGENTS.md for the full specification.
Structs§
- Agent
Definition - Metadata extracted from a loaded Lua agent script.
- LuaAgent
Adapter - Adapter that wraps a Lua
AgentDefinitionas anAgenttrait object.
Functions§
- doc_
response_ 🔒to_ lua - Convert a document response to a Lua table.
- extract_
arguments 🔒 - Extract argument definitions from a Lua
agent.argumentstable. - extract_
string_ 🔒list - Extract a list of strings from a Lua table field.
- list_
agents - List all configured agents and print their info.
- load_
agent_ definitions - Load all agent scripts from config and extract their definitions.
- load_
single_ agent - Load a single agent script and extract its definition.
- lua_
result_ 🔒to_ agent_ prompt - Convert the Lua
agent.resolve()return value to anAgentPrompt. - register_
agent_ 🔒context_ bridge - Register the
contexttable in the Lua VM for agent scripts. - resolve_
agent - Resolve an agent script’s prompt.
- run_
lua_ 🔒agent - Run the Lua agent synchronously on a blocking thread.
- scaffold_
agent - Scaffold a new agent script from a template.
- search_
results_ 🔒to_ lua - Convert search results to a Lua array table.
- sources_
to_ 🔒lua - Convert source statuses to a Lua array table.
- test_
agent - Test an agent script by resolving its prompt.
- truncate 🔒
- Truncate a string to fit in a column.