Skip to main content
Preview
DEFINE AGENT is a preview feature. It ships in broker 2.22. The syntax and behaviour may still change.

Why build with Agents

Whether you operate a production line, a solar substation, a city sensor network, or a cold-chain fleet, raw MQTT telemetry only tells you what changed — not what to do next. With a LoT Agent, you pair a language model (TYPE LLM connector) with explicit, scoped tool grants (ADD TOOL) so people and LoT Actions can ask questions, classify events, summarize operations, and trigger approved workflows right inside the broker.
Like hiring a specialist with a keycard. The TYPE LLM connector is the brain, and each DEFINE AGENT is a specialist whose keycard (ADD TOOL) only opens the exact topics, actions, and connectors needed for that job.

When to use these patterns


The examples below are complete and ready to deploy. Create each DEFAULT_USER with -addUser, deploy connectors with -addConnector, deploy agents with -addAgent, and deploy actions with -addAction (or validate first with -validateLot).

Core agent patterns

Start with the two most common building blocks: a read-only chat agent running on a local Ollama model, and a reporting agent that is allowed to publish summaries to a single topic tree.
Run a tools-capable Ollama model on the broker host and grant it read access to one topic tree. Create the user line-viewer with -addUser before deploying the agent:
Publish Is line 2 running hot? to plant/watcher/s1/ask. The answer arrives on plant/watcher/s1/response, and each tool call appears on $SYS/Coreflux/Agents/LineWatcher/task/s1/stream.

Supervisor with specialists

Instead of giving one agent every topic in the plant, split the work across focused specialists and let a supervisor delegate with WITH AGENTS. All agents share one TYPE LLM connector and one root task token budget:
When an operator asks a question on plant/supervisor/s1/ask, ShiftSupervisor can delegate to AlertAnalyst and MaintenancePlanner. Every tool call in the delegation tree still authorizes against the user who started the chain:

Manufacturing use cases

On the shop floor, agents can classify unstructured operator notes automatically from LoT Actions or log structured quality checks through a database connector.
Use a stateless agent (WITH MEMORY "none") and CALL AGENT inside an Action to label every floor note as safety, quality, or maintenance:
Publishing "Guard door sensor on press 2 is loose" to factory/notes/raw runs NoteClassifier without storing conversation history and publishes "safety" to factory/notes/labeled.

Energy use cases

Power generation sites and EV charging hubs use agents to summarize inverter telemetry for dispatchers and translate raw charger fault codes into field instructions.
Let grid operators query live solar inverter output and grid frequency under grid/solar/#, and allow the agent to publish curtailment advisories under grid/solar/advisories/#:

Smart cities use cases

Municipal teams use agents to turn sensor networks into plain-language public bulletins and to coordinate district infrastructure such as street lighting.
Run a scheduled Action every hour that asks AirQualityReporter to read city-wide PM2.5 and NO2 stations and publish a short bulletin for school zones and public dashboards:
Every hour, HourlyAirBulletin publishes a fresh summary to city/bulletins/air without requiring an open chat session.

Smart buildings and logistics

Facility managers and logistics teams use agents to balance occupant comfort with energy targets and to protect temperature-sensitive cargo in transit.
Let facility staff ask questions about floor temperatures and CO2 levels, and allow the agent to publish setpoint recommendations within safe guardrails:
Note that WITH GUARDRAILS steers the model’s recommendations, while ADD TOOL "write_mqtt" enforces that the agent can only publish to building/hvac/recommendations/# — never directly to physical damper or chiller command topics.

Intelligent Things (Things with Agents)

When you have repeated physical assets that each need their own AI assistant, embed WITH AGENT inside a DEFINE THING TEMPLATE. Every Thing instance automatically gets an agent scoped to its own topic path ({{path}}/#), and a parent station can delegate to its child assets’ agents using relative paths (p1.Assistant, p2.Assistant):
Deploying PlantLLM with -addConnector and the DEFINE THING blocks with -addThing expands north into two pump assistants (north_p1_Assistant, north_p2_Assistant), two diagnostic actions (north_p1_DiagnoseAlarm, north_p2_DiagnoseAlarm), and a station supervisor (north_Supervisor) that can delegate to both pumps. See Thing Examples for more patterns.

Verify your deployment

1

Validate the LoT code

Send -validateLot <DEFINE …> to $SYS/Coreflux/Command to check connector, agent, and action syntax before deploying.
2

Deploy the LLM connector and the agent

Send -addConnector <DEFINE CONNECTOR …> and -addAgent <DEFINE AGENT …> to $SYS/Coreflux/Command. Run -listAgents to confirm the agent status is online.
3

Watch the live task stream

Use MQTT Explorer or Coreflux HUB to subscribe to $SYS/Coreflux/Agents/<agent>/task/+/stream and {INTERACTION_TOPIC}/+/response while sending a test question to {INTERACTION_TOPIC}/s1/ask.

Best practices

Every tool call checks both ADD TOOL scope and the permissions of the user the task runs as (plus DEFAULT_USER). Never use root as DEFAULT_USER — create a dedicated user with only the topic and command permissions the agent needs.
Set WITH MEMORY "none" on agents called by high-volume ON TOPIC or ON EVERY actions so each run is stateless and does not spend tokens resending prior turns.
WITH GUARDRAILS steers the model’s reasoning, but ADD TOOL and RBAC are what enforce boundaries. Keep critical actuator topics outside write_mqtt grants until a human or deterministic LoT Action validates the output.

Next steps

Agent Syntax

Full reference for DEFINE AGENT clauses, ADD TOOL grants, delegation, and topics.

Agents Overview

Learn how agents pair with TYPE LLM connectors and when to use CALL AGENT.
Last modified on October 22, 2026