Skip to content
Architecture

Architecture

docs.waldiez.io • November 28, 2026

Wactorz is a Python-first asyncio actor-model framework for building multi-agent AI systems. Agents communicate via MQTT and run in a single process — start everything with one command.

The framework is built on three ideas: every agent is an independent actor with its own message loop; MQTT is the universal communication bus (between agents, to the dashboard, and to external systems); and DynamicAgent allows the LLM to write and spawn new agents at runtime without restarting the process.

💡 One command to start — Running wactorz starts the actor system and the web dashboard. A separate MQTT broker (Mosquitto) must be running first — start it with docker compose up -d from the repo root.

💡 One command to start — Running wactorz starts the actor system and the web dashboard. A separate MQTT broker (Mosquitto) must be running first — start it with docker compose up -d from the repo root.

Built-in Agents — wactorz/agents/

See the Agents reference for full documentation. A summary of the core actors:

Every actor in Wactorz follows the same asyncio lifecycle:

The Supervisor wraps each actor with a ONE_FOR_ONE restart policy. If an actor crashes, only that actor is restarted — others keep running. max_restarts and restart_delay are configurable per actor.

Wactorz uses a three-tier persistence layer ( wactorz/core/persistence/ ) that routes each key to the appropriate store:

Actor.persist(key, value) and Actor.recall(key) route automatically to the correct store based on the key name. Existing agent code works without changes.

Each value in state.pkl is pickled on its own, so one that no longer unpickles after a library upgrade costs that key and not the rest of the agent's state; its bytes are kept in the file until the key is written again. The pickle store keeps each agent's state in memory once it has read it, and writes the file a second after a change, from a worker thread, so the disk is never waited for on the event loop. A node does the same with its agents' JSON state files.

A value stored directly under a key that is bytes, a numpy array (not one of objects), a torch tensor, a state_dict() , a torch module, or a scikit-learn, XGBoost, LightGBM or CatBoost model is kept as a blob: a file of its own in blobs/ beside the state file, which holds a marker in its place. It is written when its key is persisted, not with every other key, so a model persisted once costs nothing when a counter beside it changes; and it is written only then, so a value changed in place is saved by persisting it again. Nodes keep blobs the same way, beside their JSON state. A stop, a migration and a clean shutdown write what is waiting. Anything that changes or removes a state file in a running server — a reset, a migration step — goes through the store, because the copy in memory is what gets written .

The spawn registry ( _spawned_agents ) is stored in SQLite. On restart, MainActor re-spawns every entry so dynamic agents and catalog agents survive reboots.

On first startup after upgrading from an older version, migrate_from_pickle() reads existing .pkl files and moves structured keys to their store. Pickle files are left in place for keys that remain in pickle.

User → Agent (any interface)

The orchestrator seam. The chat surfaces never reach main by name. Each calls an Orchestrator ( wactorz/orchestration.py : handle_turn , handle_turn_stream , commands ) through runtime.orchestrator , naming the channel the message came in on: dashboard , cli and rest are the operator's, social is a public bot. MainOrchestrator adapts main's three entry points to it and routes a social channel to the restricted one; DirectOrchestrator answers the minimal profile without a model, by sending @name {json} to the agent as a task; a deployment supplies its own with run(orchestrator=...) or WACTORZ_ORCHESTRATOR=package.module:attr . A message that names an agent still reaches that agent directly, and the node commands ( /deploy , /migrate , /nodes ) still go to main, which holds the node table.

Pipeline (HA state → Discord notification)

All providers implement complete(messages, system) → (text, usage) and stream(messages, system) → AsyncGenerator . Cost tracking (USD per 1M tokens) is built into every provider and accumulated in LLMAgent.metrics .

LLM_TEMPERATURE sets the sampling temperature for every provider and every call ( 0 for deterministic routing and actuation; unset keeps each provider's default — Anthropic, OpenAI and Gemini default to 1.0 , Ollama to 0.8 , so pinning it is what makes runs comparable across backends). Ollama receives it as options.temperature ; the others take it as a top-level request parameter. An individual call site can still pass temperature= to complete() / stream() , which wins over the env setting. The resolved value is logged at startup.

One exception, and it is not configurable: Anthropic removed the sampling parameters with Claude Opus 4.7, and a request that carries temperature to one of those models is refused rather than ignored. AnthropicProvider therefore leaves the parameter off for the models known to have dropped it, and learns the rest the first time one refuses — that request is retried without the parameter, and it is omitted for the remainder of the process. Those models are effectively pinned to their own default, so pinning a temperature no longer makes runs comparable against them.

LLM_PROVIDER=fake selects a provider that answers from a script and never calls a model. It is a real provider reached through the same factory, so it streams, reports token counts and a (tiny, non-zero) cost, and is subject to the same spend cap — the system around it behaves exactly as it would against a paid model.

It is not a small or offline model . It does not reason anything: the intent classifier is told a fixed answer, fact extraction is told there is nothing to store, and everything else matches the request against a script. Useful for running the dashboard without an API key, for end-to-end runs that need the same answer twice, and for recording a walkthrough without paying per take. Useless for anything that depends on the being right .

Both are optional; the defaults answer every request. Unmatched messages get a default that is deliberately obviously synthetic, so a recording made against it cannot be mistaken for a real session.

Per-call-site overrides

LLM_OVERRIDES routes individual call sites to different providers/models, falling back to the global LLM_PROVIDER for any site not listed ( wactorz/llm_factory.py ):

The format is = [: ] ; only the first colon splits provider from model, so Ollama tags like qwen3:4b work. A malformed entry or a provider that fails to construct logs a warning and leaves that site on the global provider. An entry naming a site not in the table above is skipped with a warning too — nothing would read it, and a silent no-op looks exactly like an override that did not work. site=none disables the LLM for that site.

Surrounding quotes are stripped, from the value as a whole and from each site and model, as they are from LLM_PROVIDER and LLM_MODEL . Several ways of setting an environment variable keep the quotes as part of the value — Windows set VAR="…" , Docker's env_file , an unbalanced quote in a hand-edited .env — and split on , and = afterwards, those quotes land on the first site name and the last model name. The site then matches nothing and the model is one character away from real, which the API answers with 404 … model: claude-sonnet-4-6" . The startup line logs the parsed table rather than the raw string, so an entry that was dropped is visible by its absence.

For Ollama, system is encoded as the first {"role": "system"} entry in the native /api/chat messages array for both blocking and streaming calls. This keeps local model behavior aligned with the hosted providers, which already receive system instructions through their chat-message APIs.

Main's system prompt, its intent classifier, its fact extraction and the planner's prompts are not fixed texts. Each is a template : a core that holds on every installation, with named slots that the fragments of the configured integrations fill ( wactorz/agents/prompts/assemble.py ). A slot shows what the fragments insert into it, or its own default when none does, so a prompt rendered for a given set of fragments is the same every time.

Which fragments an installation gets is decided once, at startup, in app.py , by the same test that decides whether the Assistant agents start: HA_URL and HA_TOKEN , or WACTORZ_HA_AGENTS=on|off outright. Main is built with the result and hands it to every planner it spawns. Without Assistant, main never mentions it, the classifier offers and the router accepts only PIPELINE and OTHER , and the planner designs from MQTT topics and the live data flows with no ha_actuator type and no entity or camera sections. A MainActor or PlannerAgent constructed directly, outside build_system , gets every fragment, so library code and tests see no difference.

Two tests guard the mechanism. tests/test_prompts_are_pinned.py keeps the prompts a Assistant installation sends word for word under tests/parity_fixtures/prompts/ ; a prompt change shows up as a fixture diff in the pull request that makes it, regenerated with WACTORZ_UPDATE_PROMPT_FIXTURES=1 pytest tests/test_prompts_are_pinned.py . tests/test_prompt_fragments.py renders every prompt with no fragments and checks that Assistant is not mentioned.

An integration adds its own text by returning a PromptFragment (its name, a mapping of slot name to text per template, and the intent tokens it adds) and listing it in wactorz/agents/prompts/fragments.py ; home_assistant_prompts.py holds the one that exists. A fragment naming a slot a template has not got is refused when rendered, so a misspelt slot cannot vanish silently.

The supervisor is configured in cli.py inside build_system() . Each actor is registered with a factory function (called fresh on each restart), a strategy, and restart limits:

Dynamic agents (spawned by main or planner) are not in the supervision tree — they are managed by the spawn registry. On restart, main re-spawns them from the persisted _spawned_agents key in state/wactorz.db (SQLite).

The wactorz command starts the actor system and the web dashboard. It connects to an external MQTT broker (Mosquitto) that must already be running. The simplest way is docker compose up -d from the repo, which starts Mosquitto on :1883 .

The web dashboard starts automatically on regardless of which interface is active, unless --no-monitor is passed. It shows live agent status, heartbeats, logs, and a chat interface.

Extracted Entities

Platforms (2)