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):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 aMinionJobContext:
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 bymodusbrain 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:
skills/migrations/v0.11.0.md:
- Read
~/.modusbrain/migrations/pending-host-work.jsonl. - For each
cron-handler-needs-host-registrationrow, ship a handler registration in the host’s worker bootstrap following the pattern above. - Deploy the updated worker.
- 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 usemodusbrain jobs submit. The JSONL row is markedstatus: "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.Related
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.