Repository navigation
2026.10.13 contains breaking changes for users of 2025.5.24 and 2025.8.22.1933. Read Breaking changes below before upgrading; coming from 2025.5.24, also read the notes under 2025.8.22.1933 in CHANGES.md.
This is the first tagged release, and the first under the MIT License.
Changes since 2025.8.22.1933: the reliability work of RFC-001 to RFC-013 (July-August 2026) and the fixes from the October 2026 audit (merged pull requests #80-#109, RFC-014 and RFC-015).
Breaking changes
Messaging
- Handlers run on a bounded pool of 8 daemon threads with a 1024-message queue instead of one new thread per message; when the queue is full the newest message is dropped (RFC-004).
publish_sync()inside a handler stays safe: replies use a lane of their own (#7).
Migration: size it withdispatch.workers/dispatch.queue_capacity;dispatch.mode: per_message_threadrestores the old model but is deprecated. Agent.publish()returnsTrue/Falseinstead ofNone, and still never raises for broker errors; an invalidqosraisesValueError(#4).
Migration: check the result where a lost message matters.- Payloads larger than
codec.max_payload_bytes(default 16 MiB) are dropped without decoding, and received payloads waiting for a handler may not exceeddispatch.max_queued_bytes(default 256 MiB) (#34).
Migration: raise these limits if you send larger messages. - MqttBroker refuses a publish once
max_pending_bytes(default 64 MiB) are unsent or unacknowledged:Agent.publish()returnsFalse,publish_sync()raisesMqttBackpressureError(#35).
Migration: raisemax_pending_bytesin the broker config for bursty senders. - Holon control messages,
publish_sync()requests and automatic replies are sent at QoS 1; every message carries amessage_id, and a redelivered id (window of 4096) is dropped before any handler runs (#4).
Migration: none for MQTT 3.1.1 brokers; subscribe services withqos=1for QoS 1 end to end, and keep handlers idempotent. - Envelopes whose
versionis missing, not an integer or outside 1-3 are dropped and counted indecode_failure_count, as are payloads without an AgentFlow prefix, now without a traceback per message (#15).
Migration: none for AgentFlow senders. - Invalid subscription filters (e.g.
a+b/c,a/#/b) raiseValueErrorfromAgent.subscribe()andMqttBroker.subscribe()before anything is registered, connected or not (#53).
Migration: use+and#only as whole topic levels,#only last. Agent.subscribe()/unsubscribe()on a topic held by a runningpublish_sync()call, andpublish_sync()on a topic owned by asubscribe()handler, raiseTopicWaitCollisionError(RFC-006, RFC-007).
Migration: keep subscription topics and reply topics apart.
Request/reply
publish_sync()raises the broker's error at once (MqttPublishError,MqttBackpressureError, orRuntimeErrorwithout a broker) instead of aTimeoutErrorafter the full timeout (RFC-002, RFC-012).
Migration: catch these as well asTimeoutError.- Automatic replies are sent only for topics with a handler registered by
subscribe(topic, topic_handler=...); a request that falls through toon_message()gets no reply (RFC-003).
Migration: register an explicit handler for every request topic. - Replies never carry
topic_return, and a handler exception no longer mutates the incoming Parcel: the error reply is a new Parcel (RFC-003).
Migration: none, unless a handler kept its input Parcel and relied on that mutation. publish_sync()no longer writes the reply topic into the caller's Parcel; a late reply on a generated reply topic is dropped and counted inlate_reply_countinstead of reachingon_message();timeout=Noneis deprecated (#21).
Migration: pass a finite timeout, and do not readtopic_returnback after the call.- Requests carry a
correlation_id, andpublish_sync()ignores replies to other requests (RFC-014, #36). Overlapping calls that share atopic_waitwith a responder older than 2026.10.13 now time out rather than risk taking each other's reply.
Migration: upgrade responders first.
MQTT broker
- The client reconnects automatically after a connection loss (back-off 1-30 s) and restores its subscriptions; each connect attempt times out after 2 s instead of paho's 5 s (#2).
Migration:reconnect: falserestores the old behaviour; tuneconnect_timeout. - The client sends a client id,
'{name}-{agent_id:.12}'by default, instead of a zero-length one; refusals that a retry cannot fix (bad credentials, not authorised, id rejected) raiseMqttConnectRefused, and the agent stops retrying (#17).
Migration: update broker ACLs keyed on client ids, or set theclient_idtemplate. MqttBrokerinstances are single-shot:start()on an instance that is not NEW raisesRuntimeError, and so doesstop()while STARTING;start(options, *, startup_timeout_s=None)andstop(graceful_timeout_s=5.0)are bounded and returnbool(RFC-010, RFC-011).
Migration: create a new broker for each start (the Agent already does).MqttBroker.publish()raisesMqttPublishErrorwhen the broker is not running or not connected, or when paho rejects the message, instead of returning a failedMessageInfo(RFC-012).
Migration: catchagentflow.broker.MqttPublishErrorwhen calling the broker directly;Agent.publish()handles it.MessageBroker.publish()/subscribe()take keyword-onlyqos(andretainfor publish). While disconnected,MqttBroker.subscribe()/unsubscribe()only update the registry replayed on the next CONNACK; afterstop()they do nothing (RFC-005, #4).
Migration: subclasses of the built-in brokers must accept the new keywords.
Lifecycle and workers
- Workers are single-shot: a second
start()raisesRuntimeError.ProcessWorker.stop()escalates to terminate and kill after 5 + 2 + 1 s and returns the exit code;ThreadWorker.stop()returnsFalse(stateSTOP_TIMEOUT) if the thread does not exit in 5 s (RFC-008, RFC-009).
Migration: create a new Agent to run it again. start()without an explicitCONCURRENCY_TYPEemits aFutureWarning(the default will become'thread'), andagent.configlacks that key until then; messaging and data calls on a process-mode controller, which never reach the child, emit aRuntimeWarning(#9).
Migration: callstart_thread()orstart_process(), and do messaging inside the agent's hooks and handlers.
Holons
- Children re-send
register_childon every (re)connect, and parents announce themselves with a new internalparent_onlinesubject;on_register_child/on_register_parentfire once per member (#6).
Migration: in mixed-version fleets, upgrade parents (including mid-tier agents) before children. terminateis honoured only from a registered parent,register_parentonly on the child's own channel, and automatic replies are never published to holon control topics (#13).
Migration: tools that stop agents by publishing onto_child.{name}needholon.trust_unregistered_parents: true; setholon.control_secreton every agent of a holon or on none.- Parent messages carry the sender's
parent_name; an agent drops its own echoed broadcasts and messages from senders not named like its parent, so name-addressed messages no longer reach grandchildren (#5, #38).
Migration: none, unless you relied on that addressing. _children/_parentsare replaced, not mutated, when a new member registers; a raisingon_register_childno longer suppressesregister_parentoron_children_message(#57).
Migration: re-read the attribute instead of keeping a reference to it.
Security
BinaryParcel(pickle) payloads are decoded with a restricted unpickler: plain data only, plus immutable types listed incodec.pickle_allowed_globals; protocol 0-2 payloads that contain bytes are refused (#1).
Migration: allowlist types such asdatetime.datetime, or send plain data;codec.accept_pickle: falserefuses pickle entirely.- An automatic error reply names only the exception type, e.g.
"KeyError (details are in the responder's log)"(#68).
Migration:errors: {expose_details: true}restoresstr(ex);publish_sync(..., raise_on_error=True)raisesRemoteErrorinstead of returning the error reply. agentflow.core.wrapperwas removed; it was unused, broken, and contained an unrestrictedpickle.loads(#1).
Migration: none.
Packaging
paho-mqtt>=2.0,<3is a declared dependency (#45).
Migration: replace a pinned paho-mqtt 1.x.
Added
Agent.unsubscribe(topic)andMessageBroker.unsubscribe(topic), a non-abstract no-op by default (RFC-001).agent_configis optional:Agent(name)works, and agents created without a config no longer share one default dict (#75).Agent.is_connected()and the hookson_disconnected()/on_reconnected(), run on a short-lived daemon thread;BrokerNotifier._on_disconnect(planned), non-abstract (#2).qos=onAgent.publish()/subscribe()(#4);publish_sync(..., raise_on_error=False)andRemoteErrorwithtopic,errorandreply(#68).- Agent counters:
decode_failure_count(#15),late_reply_count(#21),publish_backpressure_count(#35). - Agent config sections, validated at construction (unknown keys and wrong types raise):
codec:accept_pickle(defaultTrue),pickle_allowed_globals([]),max_payload_bytes(16 MiB) (#1, #34);errors:expose_details(False) (#68);holon:control_secret(unset; str or bytes of at least 16 bytes, signs control messages with HMAC-SHA256),control_max_age(300 s),max_children(unlimited),trust_unregistered_parents(False) (#13).
dispatchconfig:workers(8),queue_capacity(1024),shutdown_timeout_s(5.0),max_queued_bytes(256 MiB),mode('bounded';'per_message_thread'is deprecated) (RFC-004, #34).- MQTT broker options (the broker's config section):
MqttBroker.recovery_metrics()withresubscribe_success_count,resubscribe_error_count,recovery_run_count,active_subscriptions,failed_subscriptions,connected,stopping,ever_connected,pending_publish_countandpending_publish_bytes(RFC-005, #35, #53).MqttBrokerpropertieslast_disconnect_was_planned,state,last_start_exception,last_stop_exception,start_generation(RFC-005, RFC-010, RFC-011).- Exceptions:
MqttPublishError/MqttPublishReason,MqttBackpressureErrorandPublishBackpressureError, exported fromagentflow.broker(RFC-012, #35);MqttConnectRefusedwithreason_code/retryable(#17);TopicWaitCollisionError(RFC-006);ParcelDecodeError, aTypeError(#1). check_filter()andcheck_qos()inagentflow.broker.message_broker(#4, #53).- Optional envelope fields
correlation_id(RFC-014) andmessage_id(RFC-015), written only when set and ignored by older receivers. Parcel.from_payload()keyword-onlyaccept_pickle/pickle_allowed_globals,parse_pickle_globals()andDEFAULT_PICKLE_ALLOWED_GLOBALS(#1).- A request the dispatcher drops is answered at once with an
"overloaded: ..."error reply carrying its correlation id, so the requester need not wait out its timeout (#4). - Messages with no handler yet that arrive while
on_activate()/on_connected()are still running, e.g. from a resumed persistent session, are held (up to 4096, at most 10 s) and replayed once the hooks return (#17, PR #95). WorkerState;ProcessWorker.state/exitcode;ThreadWorker.state,last_exception,thread_alive,thread_daemon,worker_thread_ident,requires_process_restart(RFC-008, RFC-009, RFC-013).Agent.terminate()logs an ERROR when a wedged non-daemon worker thread will keep the interpreter from exiting (RFC-013).- A failed process-mode start names the handlers, config values or attributes that cannot be pickled (RFC-008, #9).
agentflow.core.dispatcher.MessageDispatcherwith metrics (RFC-004), andagentflow.core.holon_auth(#13).- Documentation: an
Agentclass docstring on thread versus process mode (#9); deployment guides indocs/deployment/(RFC-013); RFC-001 to RFC-015 indocs/rfc/and the architecture audit indocs/audit/.
Fixed
- The MQTT client never reconnected after its first connection loss, leaving the agent deaf while
is_active()stayed true; an exception in a connect callback killed paho's network thread (#2). - Subscriptions are restored after a reconnect (RFC-005) and are sent when made before the first CONNACK (#54); an unsubscribe racing that replay now wins.
- A subscription the broker refused (SUBACK 0x80) or a failed resubscribe still counted as active; it is now logged, counted in
failed_subscriptionsand retried on the next CONNACK (#53). MqttBroker.start()andstop()had no time bound, and late paho callbacks afterstop()or a failed start still reached the agent (RFC-010, RFC-011).MqttBroker.publish()ignored paho's return code (RFC-012).publish_sync()leaked a handler entry and a broker subscription on every call (RFC-001), and created aProcessWorker, changing the multiprocessing start method, on an agent without a worker (#21).publish_sync()could return a late reply to an earlier call, and concurrent calls on onetopic_waitoverwrote each other's handler; they now share the topic and each gets its own reply (#36).- Handler errors and broker self-echo could start endless reply loops (RFC-003); a burst of messages created one thread per message (RFC-004); subscribe, unsubscribe and dispatch raced on the handler registry (RFC-007).
ProcessWorker.stop()/ThreadWorker.stop()could wait forever on a wedged child or thread (RFC-008, RFC-009);Agent.is_active()was always false in process mode (commit 072291d).- The deprecated
per_message_threaddispatcher'sstop()always returnedTrue; it now reports whether its handler threads have finished (#75). - On Windows, a
ProcessWorkerstart that failed to pickle the agent left an orphan child that broke the next spawn (#48). - Importing
agentflow.core.agentfailed on hosts without tkinter (#47). - Holon membership depended on start order and was lost on reconnects and parent restarts (#6); a mid-tier agent re-ran
terminateon its own echo (#5); same-name replicas stopped each other (#38). - A hook iterating
_childrenwhile other children registered raiseddictionary changed size during iteration, and a raising hook kept a child from learning its parent (#57). - Undecodable messages were each logged with a full traceback; they are now counted and logged at a rate-limited WARNING (#15).
- Payloads were decoded on the network thread, delaying keepalives and every other message (#34).
Security
- Remote code execution:
BinaryParceldecoding ranpickle.loadson received bytes, so any client able to publish to a subscribed topic could run code in the agent (#1).bytearray(<int>)memory amplification is blocked too. - Holon control plane: forged
terminateandregister_childmessages, automatic replies redirected into control topics, and predictable reply topics, now generated withsecrets. Opt-in HMAC-SHA256 signing viaholon.control_secret, which is masked in config logs (#13). - Error replies leaked exception messages (hosts, connection strings, credentials) to anyone subscribed to the reply topic (#68).
- Hostile input: oversized payloads are not decoded (#34); deeply nested JSON and huge
versionvalues are decode failures, and logged reasons and topics are escaped and length-capped (#15). - Not addressed in this release: TLS (#3), and broker credentials printed in DEBUG config logs (#14).
Packaging
- Released under the MIT License (
LICENSE.md); earlier releases shipped an emptyLICENSE.md. install_requiresdeclarespaho-mqtt>=2.0,<3(#45); 2025.8.22.1933 already needed paho-mqtt 2.x but declared no dependency.python_requiresstays>=3.11; classifiers now name the CI-tested versions, Python 3.11 and 3.13 (#77).- GitHub Actions CI: ruff and mypy, tests on Ubuntu and Windows with Python 3.11 and 3.13 and a 70% coverage floor, and a wheel build-and-import smoke test (#49).
- The repository root is no longer an importable package: a stray
__init__.py, never part of the wheel, was removed (#76).