Free forever, no credit card.Get Started for Free →
← All posts
November 12, 2026 · 6 min read

Does MQTT Remember Between Runs? A Retained Message Keeps One Last Value. The Next Run Still Starts With Only That Value.

Does MQTT Remember Between Runs? A Retained Message Keeps One Last Value. The Next Run Still Starts With Only That Value. MQTT remembers exactly two kinds of things, and neither one is what an agent learned while working. A broker can keep the last retained message on a topic, so a new subscriber gets the most recent value right away. A broker can also keep a persistent session, so a reconnecting client gets its subscriptions back plus any eligible messages it missed while offline. Everything e

Does MQTT Remember Between Runs? A Retained Message Keeps One Last Value. The Next Run Still Starts With Only That Value.

MQTT remembers exactly two kinds of things, and neither one is what an agent learned while working. A broker can keep the last retained message on a topic, so a new subscriber gets the most recent value right away. A broker can also keep a persistent session, so a reconnecting client gets its subscriptions back plus any eligible messages it missed while offline. Everything else passes through and is gone. The reading a subscriber acted on, the conclusion it reached, and the checks it already finished were never stored by the broker, so the next run starts with a last value or a queued message, and nothing else.

A retained message is one value per topic, not a history

A normal MQTT publish is delivered to the subscribers who are listening at that moment, and then the broker drops it. If no matching subscriber is connected, the message is discarded. Publishing with the retain flag changes that for exactly one message. The broker stores that message as the last value for its topic, delivers it to current subscribers, and then hands the same stored message to every new subscriber the moment that subscriber subscribes.

That is useful, and it is also narrow. The broker stores one retained message per topic. The next retained publish on the same topic replaces the previous one completely. There is no list of earlier values, no record of when each value arrived as a readable history, and no place for a subscriber to attach what it did after seeing the value. A retained message answers one question well: what was the last value published on this topic? It does not answer what happened after that value arrived, which run handled it, or whether the work it triggered is already finished.

Retained values can also go stale without any warning in the payload itself. A sensor can publish a retained reading, lose power, and leave that reading sitting on the topic for hours. A new subscriber receives it immediately and has to judge for itself whether the value is fresh. MQTT 5 helps with a message expiry interval, which lets the broker discard a message after a set time, but expiry removes stale data. It does not turn a single last value into a memory of past runs.

A persistent session queues delivery, not understanding

Sessions are the second thing MQTT can remember. With a clean session, the broker discards a client's subscriptions and queued messages as soon as that client disconnects. With a persistent session, the broker keeps the subscriptions for that client ID and queues eligible messages while the client is offline, then delivers the backlog when the client reconnects with the same client ID.

Eligible is the key word. Only QoS 1 and QoS 2 messages are queued for an offline client. QoS 0 messages, the fire-and-forget level with no acknowledgment, are never queued, whatever the session setting says. In MQTT 5, the same idea uses Clean Start set to false plus a Session Expiry Interval, and that interval defaults to zero, which means the session ends when the connection closes unless a nonzero value is set. Session Present in the broker's connection reply is the signal that a previous session was actually found.

A restored session therefore gives a returning client three things: its old subscriptions, a queue of missed QoS 1 and QoS 2 messages, and any unacknowledged deliveries that still need to finish. It does not give the client a summary of the messages it processed last week, the decisions those messages led to, or the dead ends it already ruled out. The broker tracked delivery state, meaning which messages still owe the client a delivery. Delivery state is not work history, and a run that resumes its session still has to reconstruct its understanding from scratch.

What a scheduled agent actually needs at the start of a run

Consider an automation that wakes up on a schedule, subscribes to a set of topics, and acts on what it finds. On each run it needs more than the last retained value and a queue of missed messages. It needs to know which alerts were already handled, so a redelivered QoS 1 message, which can legitimately arrive twice, does not trigger the same action again. It needs the conclusions from earlier runs, so a fault that was investigated and explained yesterday is not investigated again today. It needs the reasoning behind those conclusions, so it can tell a settled question from a new one that merely looks similar. And it needs that record to be shared, so a second agent working in a different tool on related topics reads the same past instead of a private fragment.

MQTT supplies none of that, because none of it is a message in transit. It is memory, and it belongs in a layer built to hold memory.

That layer is what Vilix AI provides. Vilix AI is cloud-hosted, with zero infrastructure to run: no extra broker to provision and no memory store to operate beside the existing setup. The same memory is available everywhere over MCP, so the automation doing the work, the chat tool used to review the outcome, and every other connected agent read and write one shared memory. Vilix AI stores full conversation history, not just extracted facts, so a later run can revisit what was actually discussed and decided, in context, instead of working from a single retained value or a compressed note.

The practical split is simple. Let MQTT do the job it is built for: routing publishes to matching subscribers, holding one retained value per topic, and queuing QoS 1 and QoS 2 messages for persistent sessions until the client returns. At the end of each run, write the outcome into memory: what arrived, what was checked, what was decided, and what still needs attention. At the start of the next run, read that memory before subscribing. A duplicate delivery then meets an agent that can check the record first, recognize finished work, and spend the run only on what is genuinely new.

There is no cost to testing that split. Vilix AI has a free plan that stays free forever, and Pro comes with a 7-day trial that needs no credit card. The memory stays portable throughout: export everything or delete it anytime. MQTT will keep the last value on a topic and the messages a session missed. The memory makes sure the next run arrives knowing everything the earlier runs learned.

Get Started for Free

Persistent memory across ChatGPT, Claude, and the AI tools you already use in Vilix AI.

Get Started for Free

Free forever, no credit card.

Keep reading
Does Azure Event Hubs Remember Between Runs? Events Stay in the Partitioned Log for Up to 90 Days. The Next Run Still Starts With Only Its Event.

Does Azure Event Hubs Remember Between Runs? Events Stay in the Partitioned Log for Up to 90 Days. The Next Run Still Starts With Only Its Event. Azure Event Hubs remembers the event, in full, in the log. An event hub is an append-only log that stores events, producers add new events to the end of a partition, and those events stay there for the whole retention period whether anyone read them or not. That is real retention, and it is stronger than a queue that deletes on delivery. What Event Hu

Does Apache RocketMQ Remember Between Runs? Messages Stay in the CommitLog for Days. The Next Run Still Starts With Only Its Message.

Does Apache RocketMQ Remember Between Runs? Messages Stay in the CommitLog for Days. The Next Run Still Starts With Only Its Message. Apache RocketMQ remembers the message, in full, on disk. A broker writes every message it receives into a shared physical log, keeps it for the whole storage duration whether anyone consumed it or not, and lets a consumer go back and read it again inside that window. That is real retention, and it is stronger than a queue that deletes on delivery. What RocketMQ n

How Do You Give a Microsoft Teams AI Agent Memory Between Conversations?

How Do You Give a Microsoft Teams AI Agent Memory Between Conversations? You give a Microsoft Teams AI agent memory between conversations by saving every turn to a store keyed by the Teams user ID, loading the relevant part of that history before each model call, and writing the new exchange and its outcome back after the reply. Teams delivers each message as a separate activity to a stateless bot, so nothing carries over unless your code saves it and loads it again. Why does a Teams AI agent