workbench: Replacing Bloated Agent Daemons with a Lightweight Bot Kernel and Fail-Closed Sanitizer A developer rebuilt a local multi-agent workbench by replacing per-role resident daemons with on-demand native sessions driven by a lightweight, tool-agnostic bot kernel, where each role is defined by Markdown contracts (SOUL.md, CORE.md, BRIEF.md) and an isolated skill sandbox. The kernel auto-rotates sessions at a 40,000-character history threshold, handing off a capped BRIEF.md and topic memory files while archiving the rest to .history/ for rollback, and routes every outbound artifact through a deterministic fail-closed sanitizer that raises SanitizerError on high-risk identifiers such as account UIDs, order IDs, auth tokens and API secrets. When you build a local multi-agent workbench for daily engineering and operations, the most tempting early pattern is to give every specialized role its own long-running background daemon. It feels clean at first: one process per persona, each holding its own memory, toolset, and event loop. In practice, that architecture decays faster than you expect. Here is what broke in our setup, and how we replaced heavy resident daemons with a tool-agnostic bot kernel, 40K-character auto epoch rotation, and a fail-closed outbound sanitizer gate. Once we scaled past three specialized roles, running a resident process per agent introduced three compounding problems: We did not need more orchestration frameworks on top of those daemons. We needed a smaller, stricter kernel underneath them. Instead of keeping resident processes alive, our workbench now spawns on-demand native sessions backed by a lightweight, tool-agnostic bot kernel. Each role is defined by a small set of plain Markdown contracts SOUL.md for hard boundaries, CORE.md for stable procedures, and BRIEF.md for rolling state plus an isolated skill sandbox . Long-lived specialized bots still need continuity across days without dragging massive transcripts into every turn. Our kernel solves this with automatic epoch rotation at a 40,000-character threshold . Whenever an active session approaches 40K characters of accumulated history, the workbench triggers a clean handoff: BRIEF.md capped at 2,500 characters and topic-specific memory files. .history/ archive for instant rollback if needed. Latency stays flat, prompt adherence stays sharp, and nothing important gets silently dropped. Prompt instructions alone are never enough when an automated pipeline publishes to external platforms. Every outbound artifact in our publishing workflow passes through a deterministic fail-closed sanitizer gate before anything is written to disk or sent over HTTP. Low-risk local artifacts like accidental local paths or internal port strings can be stripped or flagged, while high-risk identifiers—such as account UIDs, order IDs, exact asset balances, or auth credentials—raise a hard SanitizerError and abort the run immediately: python import re from typing import Iterable, Tuple class SanitizerError ValueError : """Raised when high-risk identifiers cannot be safely redacted.""" HARD BLOCK PATTERNS: Tuple Tuple str, re.Pattern str , ... = "account uid", re.compile r"\bUID :\s - \d{6,12}\b", re.IGNORECASE , "order id", re.compile r" \d{6,}" , "auth header", re.compile r"\bAuthToken\s+ A-Za-z0-9. \- {16,}\b" , "api secret", re.compile r"\b ?:tok |key |pat A-Za-z0-9 \- {12,}\b" , def assert safe outbound text: str, patterns: Iterable Tuple str, re.Pattern str = HARD BLOCK PATTERNS, - str: """Fail-closed check before any external draft or post is dispatched.""" for label, pattern in patterns: if pattern.search text : raise SanitizerError f"Blocked outbound payload due to {label}" return text.strip if name == " main ": sample = "Kernel rotated cleanly at 40K chars; outbound gate active." assert assert safe outbound sample == sample print "Sanitizer self-check passed." After migrating our workbench to this architecture, we verified four concrete outcomes: If you are building local multi-agent workflows, consider shrinking the runtime before adding more layers of orchestration. Strict isolation and fail-closed boundaries pay off far earlier than complex daemon meshes.