Skip to main content

Plugin handlers — registering host-specific Minion handlers

ModusBrain’s Minion worker ships with seven built-in handlers: sync, embed, lint, import, extract, backlinks, autopilot-cycle. These cover every background operation the modusbrain CLI itself performs. Host platforms (OpenClaw deployments, future hosts) register their own handlers via a plugin bootstrap that imports modusbrain/minions. No handlers.json-style data file — handlers are code, loaded by the worker, with the same trust model as any other code in the host’s repo.

Why code, not data

An earlier design draft shipped ~/.claude/modusbrain-handlers.json where each entry was a shell command the worker would exec on job claim. Codex flagged this as a durable RCE surface: an agent-writable data file that spawns arbitrary shell. We dropped the data-file approach; handlers are code that the host imports explicitly and ships through code review.

The plugin contract

A host worker bootstrap looks like this (TypeScript):
Ship this as a separate binary in the host repo (e.g. your-openclaw-worker) or as a side-effect module that the stock modusbrain jobs work command auto-loads on startup (configurable via a host-provided entry point).

Handler contract

Every handler receives a MinionJobContext:
Return a serializable object on success. Throw on failure (the worker will log + retry per max_attempts). Abort cooperation. When ctx.signal.aborted becomes true, finish gracefully. The worker will wait 30s for you to return before SIGKILL. Long-running LLM calls should pass the signal through to whatever network library they use. Idempotency. The queue enforces unique idempotency_key at the DB layer, so you don’t need to worry about double-submits from a cron that fires while the previous invocation is still running.

Modusbrain’s migration flow

The v0.11.0 migration orchestrator (run by modusbrain apply-migrations) detects cron entries whose handler name is NOT in ModusBrain’s builtin set and emits a structured TODO to ~/.modusbrain/migrations/pending-host-work.jsonl. Each TODO has shape:
The host agent walks these entries using skills/migrations/v0.11.0.md:
  1. Read ~/.modusbrain/migrations/pending-host-work.jsonl.
  2. For each cron-handler-needs-host-registration row, ship a handler registration in the host’s worker bootstrap following the pattern above.
  3. Deploy the updated worker.
  4. Re-run modusbrain apply-migrations --yes. The orchestrator now recognizes the newly-registerable handler (worker writes the registered names to a discovery file on startup) and rewrites the cron entry to use modusbrain jobs submit. The JSONL row is marked status: "complete".

Trust boundary

Handler code runs inside the worker process with the same privileges as the rest of the host binary. There is no elevation. But there is also no runtime sandbox — handlers can read + write anywhere the worker user can. Review handler PRs the same way you review any other code that touches production data.
  • skills/conventions/cron-via-minions.md — the rewrite convention for cron manifests.
  • skills/migrations/v0.11.0.md — how the migration orchestrator drives the host agent through this work.
  • skills/minion-orchestrator/SKILL.md — patterns for submitting, monitoring, steering, and replaying jobs once the handler is live.