> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Examples

> Complete DEFINE AGENT examples: a local chat agent, a reporting agent with a write grant, and a supervisor with specialists

Preview

> [!WARNING]
>
> `DEFINE AGENT` is a preview feature. It ships in broker **2.22**. The syntax and behaviour may still change.

The examples below are complete. Deploy the LLM connector with `-addConnector` and the agent with `-addAgent`. For the full clause list see [Agent Syntax](/latest/lot-language/agents/syntax). For more copy-and-deploy recipes (site guide, scheduled report, alert triage, shift handover), see [Creating Agents in Coreflux](/latest/quick-start/creating-agents).

**Chat with a local agent**

A tools-capable Ollama model on the broker host, granted read access to one topic tree. Create the user `line-viewer` with `-addUser` before you add the agent.

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE CONNECTOR LocalLlama WITH TYPE LLM
    ADD LLM_CONFIG
        WITH PROVIDER "ollama"
        WITH BASE_URL "http://localhost:11434"
        WITH MODEL "llama3.2"

DEFINE AGENT LineWatcher
    USES LLM CONNECTOR LocalLlama
    WITH DESCRIPTION "Answers questions about line telemetry"
    WITH DEFAULT_USER "line-viewer"
    WITH INTERACTION_TOPIC "plant/watcher"
    ADD TOOL "read_mqtt"
        WITH TOPICS "lines/+/telemetry/#"
```

Publish `Is line 2 running hot?` to `plant/watcher/s1/ask`. The answer arrives on `plant/watcher/s1/response`. Each tool call appears on `$SYS/Coreflux/Agents/LineWatcher/task/s1/stream`.

**File a report the agent may publish**

The agent may publish under `reports/shift/#` and nowhere else. A writing tool needs `WITH LEVEL "write"`.

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE CONNECTOR Claude WITH TYPE LLM
    ADD LLM_CONFIG
        WITH PROVIDER "anthropic"
        WITH MODEL "claude-sonnet-4-0"
        WITH API_KEY GET SECRET "ANTHROPIC_API_KEY"

DEFINE AGENT ShiftReporter
    USES LLM CONNECTOR Claude
    WITH DESCRIPTION "Writes the end-of-shift report"
    WITH DEFAULT_USER "report-writer"
    WITH INTERACTION_TOPIC "plant/reporter"
    ADD TOOL "read_mqtt"
        WITH TOPICS "alarms/#, lines/+/counters/#"
    ADD TOOL "write_mqtt"
        WITH TOPICS "reports/shift/#"
        WITH LEVEL "write"
```

A publish to `reports/shift/2026-10-15` runs when `report-writer` may publish there. A publish to `lines/3/cmd` is refused as `out_of_scope` on the task stream.

## Supervisor with specialists

One LLM connector, a supervisor, and two specialists it may hand work to. Declare `AlertAnalyst` and `MaintenancePlanner` the same way, each with the grants its job needs. The delegation rules (shared budget, hop limit, who each tool call runs as) are in [Delegation](/latest/lot-language/agents/syntax#delegation-with-agents).

```lot wrap focus={10} theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE CONNECTOR Gpt56 WITH TYPE LLM
    ADD LLM_CONFIG
        WITH PROVIDER "openai"
        WITH MODEL "gpt-5.6"
        WITH API_KEY GET SECRET "OPENAI_API_KEY"

DEFINE AGENT ShiftSupervisor
    USES LLM CONNECTOR Gpt56
    WITH DEFAULT_USER "shift-ops"
    WITH AGENTS "AlertAnalyst, MaintenancePlanner"
    WITH MAX_TOKENS 80000
    WITH INTERACTION_TOPIC "plant/supervisor"
    ADD TOOL "read_lot"
```

Give a classifier specialist `WITH MEMORY "none"` so an earlier conversation can't steer it, and run high-volume classification on a local model.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.