A model call, or an assistant that can act
Your broker already moves sensor data, drives equipment, and stores history. Two LoT pieces add a language model to that world. ATYPE LLM connector sends one prompt and returns text. Actions use it for a classification, a summary, or a short conversation. A DEFINE AGENT is a named assistant that runs on that connector. It can read topics, publish, run connector events, and hand work to other agents — only where you grant it.
The connector holds the provider, the model, the key, and the price. Every agent that names it with USES LLM CONNECTOR picks up a change to that connector. An agent is its own LoT entity. It is deployed with -addAgent, and it does not appear in the connector list.
When to use which
- Prompt in, text out: a
TYPE LLMconnector andCALL LLMinside an Action. This page. - An assistant that reads or changes the broker: a
DEFINE AGENTon that connector. See Agents Overview.
First time? Paste a working agent in Creating Agents in Coreflux. Come back here for providers and
CALL LLM. Grants, topics, and the move off TYPE AGENT are in Agent Syntax.The example below is complete. Deploy the LLM connector with
-addConnector.
Quick Start
- Ask a model from an Action
One prompt, one answer. The connector has no tools.Store the key once with Publish an alarm payload to
KEEP SECRET "OPENAI_API_KEY" WITH "sk-...", or with -setSecret. See Secrets.alarms/raw/line3. The explanation arrives on alarms/explained. Read success in {result} before you trust response.The LLM connector
DEFINE CONNECTOR … WITH TYPE LLM is the connector (DEFINE ROUTE and the -addRoute / -removeRoute commands still work as aliases). Actions call it with CALL LLM. Agents name it with USES LLM CONNECTOR. The connector itself never calls tools.
Picking a provider
Local Ollama. Install Ollama on the broker host, or on a machine the broker can reach, and pull a tools-capable model before you deploy (
ollama pull llama3.2 or ollama pull qwen3). The MODEL value must match ollama list. Only some Ollama models call tools. Coreflux connects to the endpoint you set. It does not install Ollama or download models.If the broker runs in Docker, localhost inside the container is the container. Point BASE_URL at the Ollama service on the Compose network (for example http://ollama:11434), or at http://host.docker.internal:11434 when Ollama runs on the Docker host.- Ollama
- OpenAI
- Anthropic
- OpenAI-compatible
The default provider. Omit
PROVIDER and the connector still uses Ollama at http://localhost:11434.LLM_CONFIG
Models that reason before answering spend part of the connector’s
MAX_TOKENS on reasoning they don’t show. With 1024 the answer can come back empty. Set MAX_TOKENS to 4096 or more on the TYPE LLM connector for these models.REASONING_EFFORT, only PROVIDER "openai" on the Responses API sends one: Medium. That default is skipped for older families (gpt-4*, gpt-3*, chatgpt-*), which reject it. A compatible connector sends no reasoning effort unless you set it. Set REASONING_EFFORT "none" when an OpenAI model rejects the default.
MCP_ROUTES is legacy. On a TYPE LLM connector the broker ignores it and logs a warning to use ADD TOOL. The connector still starts. A TYPE LLM call runs no tools. On DEFINE AGENT it is a legacy clause, and -addAgent refuses it. To give an agent an MCP tool, see Agents and MCP Tools. See Coming from TYPE AGENT.
The connector does not probe the provider at start. A wrong key, URL, or model shows up on the first call, as "success": false.
Ollama context and timeouts
Ollama uses the model’s default context window (often 2k–8k tokens) unless the request asks for more, and silently drops the start of a longer prompt. The broker therefore sendsnum_ctx on every Ollama call, for CALL LLM and for each step of an agent’s tool loop:
- It estimates the prompt (messages, tool results, and tool schemas) plus
MAX_TOKENS. - It uses 16,384 tokens when that fits, otherwise
MAX_CONTEXT_WINDOW. Only two sizes, because each change makes Ollama reload the model. - It never goes above the model’s own maximum, read from Ollama and cached for five minutes.
- A prompt that still doesn’t fit fails with
context_overflowand is never sent.
These four settings apply to
PROVIDER "ollama" only.
TASK_TIMEOUT and cancel also end a call that is waiting on Ollama. A large model loading cold on a slow machine can take more than two minutes: raise FIRST_OUTPUT_TIMEOUT for it. On a low-memory Ollama host, a 32k window may not fit next to the model. Lower MAX_CONTEXT_WINDOW (for example to 16384).
Agents report these as the task’s
code. CALL LLM returns "success": false with the same message, which names the model and the URL, in error.
Call the model from an Action
CALL LLM and INVOKE LLM are the same call.
generate and chat includes success, response, model, session_id, used_history, and execution_time_ms. A failure sets success to false and puts the reason in error.
History for CALL LLM stays in memory on that connector: the last 50 messages per session_id, dropped when the connector stops or the broker restarts. Agent conversations are separate and survive a restart. See Working memory.
You can also fire the connector with TRIGGER "PlantModel" TO {prompt} FOR "generate" (or FOR "chat" for the history mapping). That path publishes the result to the mapping’s DESTINATION_TOPIC, or to {RouteName}/llm/response when that mapping has none. TRIGGER keeps chat history only when the mapping name is chat, unless the JSON payload sets use_history.
Status is the usual connector topic $SYS/Coreflux/Routes/{Name}/status. The connector does not publish …/Capabilities or …/Metrics.
-discoverAIProviders probes local and cloud model lists and retains a summary on $SYS/Coreflux/AI/Providers. That probe is independent of the providers a TYPE LLM connector accepts.
Agents
DEFINE AGENT has its own section: Agents Overview, Agent Syntax (properties, ADD TOOL, delegation, topics, CALL AGENT, management), and Agent Examples. Moving off TYPE AGENT? See Coming from TYPE AGENT.
Troubleshooting
Ollama never calls a tool
Ollama never calls a tool
The model does not support tools. Pull a tools-capable tag such as
llama3.2 or qwen3.OpenAI returns HTTP 400
OpenAI returns HTTP 400
Reasoning models reject
TEMPERATURE. Leave it unset. gpt-6-luna rejects a Chat Completions call. Use API_SURFACE "auto" or "responses".Limitations
Next steps
Creating Agents in Coreflux
Paste a site guide, a scheduled report, alert triage, or a shift handover and try them over MQTT.
MCP Connectors
Call external MCP tools from Actions. Agents do not receive those tools automatically.

