The description field is what the AI agent reads to decide whether to use the tool. Better descriptions lead to better tool selection.
Good Descriptions
Bad Descriptions
commands: [ { name: 'read_temperature', description: 'Read the current room temperature in celsius from the wall-mounted sensor', }, { name: 'print_label', description: 'Print a shipping label. Requires recipient name, address, city, and postal code. Optionally specify number of copies (1-10).', }, { name: 'scan_barcode', description: 'Activate the barcode scanner and return the scanned code. Takes 2-3 seconds. Returns the barcode value and format (UPC, QR, etc).', },]
Your agent persona can reference devices to guide tool usage. Add instructions in your persona about when and how to use device tools:
const agent = new LuaAgent({ name: 'warehouse-agent', persona: ` You are a warehouse operations assistant. You have access to physical devices in the warehouse: - Barcode scanners for inventory lookup - Weight scales for package verification - Gate controllers for dock access When a user asks about inventory, use the barcode scanner to look up items. When verifying shipments, use the weight scale to confirm package weight. Always confirm before opening or closing gates. If a device is offline, tell the user and suggest alternatives. `, skills: [inventorySkill],});
Here is what a conversation looks like when an agent uses device tools:
User: What's the temperature in the server room?Agent: [internally selects tool: device:server-room-sensor:read_temperature] [sends command to device, receives: { temperature: 23.5, unit: 'celsius' }] The server room temperature is currently 23.5 degrees celsius.User: That seems a bit warm. Can you turn up the AC?Agent: [internally selects tool: device:server-room-hvac:set_target] [sends command with payload: { temperature: 21 }] [receives: { targetTemperature: 21, heatingOn: false }] Done. I've set the target temperature to 21 degrees celsius. The cooling system is now active. The temperature should come down within the next few minutes.User: Thanks. Let me know if it goes above 25.Agent: I'll keep an eye on it. If the temperature exceeds 25 degrees, I'll notify you immediately. [Note: this would be handled by a device trigger, not polling]
When a device disconnects, its tools are removed from the agent’s tool list. The agent will not be able to use commands from an offline device. If a user asks for something that requires an offline device, the agent should explain that the device is unavailable.
Design your persona to handle this gracefully. The agent does not know about devices that were previously connected but are now offline — it only sees currently connected devices.