DEV Community

Tom Lee
Tom Lee

Posted on • Originally published at blog.clawsouls.ai

Building Safe Agents with Long-Term Memory: SoulScan, Persona Engine & Swarm Memory

Claude Dispatch Validated the Market. Now Let's Talk About Safety.

Anthropic recently launched Claude Dispatch — a phone-to-desktop agent workflow. This validates what the OpenClaw community has been building for months: AI agents that work autonomously on your behalf.

But there's a gap nobody talks about: How do you keep an autonomous agent safe?

When your agent runs 24/7, handles sensitive data, and has tool access, three problems emerge:

  1. Soul file tampering — Someone modifies your agent's personality definition
  2. Persona drift — The agent gradually deviates from its defined character
  3. Memory fragmentation — Multiple agents can't share what they've learned

SoulClaw v2026.3.21 addresses all three.

1. SoulScan: Inline Security Scanning

SoulScan is a 4-stage security pipeline that scans soul files for:

  • Prompt injection — Hidden instructions in personality definitions
  • Data exfiltration — Patterns that leak sensitive information
  • Harmful content — 58+ security rules
  • Schema violations — Structural issues

What's New: Inline Scanning

Previously, SoulScan only ran manually. Now it runs automatically after every agent turn (rate-limited to once per 5 minutes):

Agent Turn → Response → [fire-and-forget] SoulScan checks workspace
                                          ↓
                                    Score < threshold?
                                          ↓
                                    ⚠️ Warning logged
Enter fullscreen mode Exit fullscreen mode

No configuration needed. If your workspace has a SOUL.md, it's protected.

# Scan your workspace
soulclaw soulscan

# CI/CD pipeline
soulclaw soulscan --json --min-score 70
Enter fullscreen mode Exit fullscreen mode

2. Persona Engine: Drift Detection

Even with a perfect SOUL.md, your agent's personality drifts over long conversations. The Persona Engine monitors this.

How It Works

  1. Parse — SOUL.md parsed into structured rules (tone, style, principles)
  2. Detect — Every N responses, scored against rules via Ollama or keyword matching
  3. Enforce — Correction injected + notification sent when threshold exceeded

Opt-In Configuration

Drift detection is off by default:

# Enable
soulclaw persona config --enable

# Customize
soulclaw persona config --interval 3 --threshold 0.4

# Check manually
soulclaw persona check --text "Your agent's response"

# View history
soulclaw persona metrics
Enter fullscreen mode Exit fullscreen mode

Real-Time Notifications

Alerts via Telegram, Discord, etc.:

⚠️ Persona Drift WARNING
Score: 0.450 (method: keyword)
Session: agent:main:telegram:12345
Action: reminder
Enter fullscreen mode Exit fullscreen mode

3. Swarm Memory: Multi-Agent Sync

Git-based memory synchronization across agents and devices.

Agent A (Mac)                    Agent B (Server)
    │                                │
    ├── MEMORY.md                    ├── MEMORY.md
    │                                │
    └─── swarm sync ──→ Git Repo ←── swarm sync ───┘
Enter fullscreen mode Exit fullscreen mode
# Initialize
soulclaw swarm init --remote git@github.com:user/swarm-memory.git

# Sync with LLM merge
soulclaw swarm sync --llm-merge

# Resolve conflicts
soulclaw swarm resolve --llm      # LLM semantic merge
soulclaw swarm resolve --ours     # Keep ours
soulclaw swarm resolve --theirs   # Keep theirs
soulclaw swarm resolve --manual   # Edit manually
Enter fullscreen mode Exit fullscreen mode

Why This Matters

Problem Before After
Soul file tampered Silently compromised SoulScan catches in 5 min
Agent drifts Nobody notices Persona Engine alerts you
Multi-agent knowledge Each starts from zero Swarm Memory shares all

Free, Open Source, Built on OpenClaw

  • Free — No subscription
  • Open source — MIT license
  • 30-second migration from OpenClaw
npm install -g soulclaw
soulclaw gateway install
soulclaw gateway start  # Uses existing ~/.openclaw/ config
Enter fullscreen mode Exit fullscreen mode

Migration guide: docs.clawsouls.ai


SoulClaw v2026.3.21 — Safe agents with long-term memory.

GitHub · npm · Docs

Top comments (0)