← Back to Index

Agent Replication & Deployment Architecture

Version: 1.0
Last Updated: 2026-02-17
Status: Design Complete, Pending Approval for Implementation


Executive Summary

Goal: Deploy specialized AI agents (Dev, Ops, Sales) with human oversight, cost control, and VPS flexibility.

Key Principles:

  1. Human approval required before any agent spawns (security + cost gate)
  2. Budget caps enforced per agent (no runaway bills)
  3. VPS agnostic (Docker + Tailscale works on any provider)
  4. Git-based inheritance (species-dna/ protocols shared instantly across fleet)
  5. Fast deployment (15 min from approval to live agent)

Current State: 1 agent (Main session)
Next Step: Deploy Dev Agent as pilot (validate architecture)


Architecture Overview

Hub-and-Spoke Model

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   Main Session  β”‚ ← You + Me (strategic hub)
                    β”‚  (minnie-core)  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
           β”‚                 β”‚                 β”‚
     β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
     β”‚ Dev Agent β”‚     β”‚ Ops Agent β”‚    β”‚Sales Agentβ”‚
     β”‚ (GitHub)  β”‚     β”‚ (Systems) β”‚    β”‚  (CRM)    β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                  β”‚                 β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Species DNA    β”‚ ← Shared protocols
                    β”‚  (Git Repo)     β”‚    (all inherit)
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Coordination:


Species DNA: Genetic Inheritance

What All Agents Share

species-dna/
β”œβ”€β”€ CORE-MISSION.md           # Loss function: vitality β†’ relational β†’ sovereignty β†’ business
β”œβ”€β”€ LOSS-FUNCTION.md          # Optimization priorities (shared across all agents)
β”œβ”€β”€ INTERACTION-STYLE.md      # How to communicate (authentic, not robotic)
β”œβ”€β”€ PROTECTION-PROTOCOL.md    # Data loss prevention (auto-commit, volume discipline)
β”œβ”€β”€ REBUILD-WINDOW.md         # When to deploy changes (Sunday 9:45 PM PT)
└── protocols/
    β”œβ”€β”€ escalation.md         # When to alert humans
    β”œβ”€β”€ budget-enforcement.md # Cost control rules
    └── security.md           # Credential isolation, audit trails

Update mechanism:

Why this works:


Agent-Specific Memory

What Each Agent Keeps Private

agents/
β”œβ”€β”€ main/
β”‚   β”œβ”€β”€ MEMORY.md             # Main session's long-term memory
β”‚   β”œβ”€β”€ workspace/            # Main's files (plans, analysis, metrics)
β”‚   └── credentials/          # Main's OAuth tokens (Gmail, Calendar, Drive)
β”‚
β”œβ”€β”€ dev/
β”‚   β”œβ”€β”€ MEMORY.md             # Dev's learning (GitHub patterns, Malachi preferences)
β”‚   β”œβ”€β”€ workspace/            # Dev's PR reviews, issue tracking
β”‚   └── credentials/          # Dev's tokens (GitHub API only)
β”‚
└── ops/
    β”œβ”€β”€ MEMORY.md             # Ops' system knowledge
    β”œβ”€β”€ workspace/            # Ops' monitoring logs, alerts
    └── credentials/          # Ops' tokens (Vultr, monitoring APIs)

Isolation:

Cross-pollination:


Deployment Process: 15-Minute Workflow

Phase 1: Justification (Human, 5 min)

I create proposal: species-dna/deployment-proposals/dev-agent-proposal.md

# Dev Agent Deployment Proposal

## Mission Alignment
- **Loss Function:** Sovereignty (protects Malachi's deep work)
- **Problem:** Malachi spending 15 hrs/week on PR reviews, GitHub notifications
- **Solution:** Dev Agent monitors repos 24/7, summarizes PRs, flags urgent issues

## ROI Calculation
- **Human time saved:** 15 hrs/week Γ— $50/hr = $750/week = $3,000/month
- **Agent cost:** $200/month (API + VPS)
- **ROI:** 15x

## Cost Estimate
- API calls: ~500/day Γ— $0.30/call = $150/month
- VPS: Hetzner small (€3.79/mo) = $4/month
- Buffer: $46/month
- **Total budget:** $200/month

## Success Metrics (30-day pilot)
- Malachi's GitHub time reduced by >10 hrs/week
- Agent catches 90%+ of urgent PRs within 1 hour
- Cost stays under $200/month
- Zero false positives (spam alerts)

## Approval Request
Deploy Dev Agent with $200/month budget, 30-day pilot, weekly review?

You review:


Phase 2: Provision (Automated, 10 min)

Once approved, I run:

# Provision VPS (any provider)
python3 scripts/provision-vps.py \
  --provider hetzner \
  --region eu \
  --size small \
  --agent dev \
  --budget 200

# Script does:
# 1. Create VPS via provider API (Hetzner, Vultr, DO, etc.)
# 2. Apply cloud-init bootstrap:
#    - Install Docker
#    - Install Tailscale (auto-join mesh)
#    - Clone species-dna/ repo
#    - Pull OpenClaw image
#    - Create agent workspace/
#    - Set budget cap in budget.json
# 3. Start container with:
#    - species-dna/ mounted read-only
#    - agent workspace/ mounted read-write
#    - credentials/ directory (empty, agent requests OAuth as needed)
# 4. Wait for Tailscale IP assignment
# 5. Register with fleet dashboard
# 6. Send "Hello" to designated Telegram group

Output:

βœ… Dev Agent deployed
   VPS: Hetzner fsn1 (Frankfurt)
   IP: 144.202.134.56
   Tailscale: 100.72.11.54 (minnie-dev)
   Cost: $4.15/month
   Budget: $200/month
   Status: Healthy

Phase 3: Validation (Me + You, 5 min)

Health checks:

# 1. Ping agent via Tailscale
tailscale ping minnie-dev
# β†’ Reply from 100.72.11.54

# 2. Check agent responded in Telegram
# β†’ "Hello, I'm Dev Agent. Monitoring GitHub repos for Malachi."

# 3. Test one interaction
# "Dev Agent, check GitHub notifications"
# β†’ Lists PRs awaiting review

# 4. Verify budget tracking
curl http://100.72.11.54:8080/budget
# β†’ {"spend_to_date": 0.00, "cap": 200.00, "status": "healthy"}

If all pass: Agent live, 30-day pilot begins
If any fail: Debug, retry, or escalate to Infrastructure group


Cost Monitoring: 5-Layer System

Layer 1: Token Tracking (Most Granular)

OpenClaw logs every API call:

{"ts": "2026-02-17T03:00:00Z", "agent": "dev", "model": "claude-sonnet-4-5", "tokens_in": 1200, "tokens_out": 800, "cost": 0.15}
{"ts": "2026-02-17T03:15:00Z", "agent": "dev", "model": "claude-haiku-4-5", "tokens_in": 300, "tokens_out": 150, "cost": 0.02}

Aggregation script (runs hourly):

# tools/fleet-cost-tracker.py
# Reads all agents' logs, sums costs, writes dashboard

Layer 2: Budget Enforcement (Proactive)

Each agent has budget.json:

{
  "agent_name": "dev",
  "monthly_cap_usd": 200,
  "current_month": "2026-02",
  "spend_to_date": 87.32,
  "alert_at_percent": 80,
  "pause_at_percent": 100
}

Before each API call:

def check_budget():
    budget = load_budget()
    if budget["spend_to_date"] >= budget["monthly_cap_usd"]:
        pause_agent()  # Stop making calls
        alert_human("Dev Agent hit $200 cap, paused until approval")
    elif budget["spend_to_date"] >= budget["monthly_cap_usd"] * 0.80:
        alert_human("Dev Agent at 80% budget ($160/$200)")

No runaway costs possible (hard stop at cap).


Layer 3: VPS Billing APIs

Provider wrappers:

# tools/vps-billing.py
def get_vps_cost(provider, agent_name):
    if provider == "vultr":
        return get_vultr_cost(agent_name)
    elif provider == "hetzner":
        return get_hetzner_cost(agent_name)
    # ... etc

Polled daily, added to fleet dashboard.


Layer 4: Fleet Dashboard (Auto-Generated)

Updated hourly via cron:

# Fleet Cost Dashboard

**Last Updated:** 2026-02-17 03:00 UTC

## Total Spend

| Period   | Spend    | Budget  | % Used |
|----------|----------|---------|--------|
| Feb 2026 | $143.67  | $750    | 19%    |
| Projected| $445.00  | $750    | 59%    | ← On track βœ…

## By Agent

| Agent | Budget | Spend   | % Used | Status     |
|-------|--------|---------|--------|------------|
| main  | $350   | $131.35 | 38%    | βœ… Healthy  |
| dev   | $200   | $12.32  | 6%     | βœ… Healthy  |
| ops   | $150   | β€”       | β€”      | Not deployed |

## By Provider

| Provider   | Service       | Monthly Cost |
|------------|---------------|--------------|
| Anthropic  | Claude API    | $143.67      |
| Hetzner    | VPS (dev)     | $4.15        |
| Vultr      | VPS (main)    | $40.00       |

## Alerts

- None (all agents <80% budget)

Access via Tailscale:
http://100.72.11.53:9876/species-dna/fleet-cost-dashboard.md


Layer 5: Human Review (Weekly)

Every Sunday (rebuild window):

  1. Review fleet dashboard
  2. Check for budget anomalies
  3. Evaluate agent ROI (are we getting value?)
  4. Adjust budgets if needed
  5. Terminate underperforming agents

VPS Agnosticism: Docker + Tailscale

Why Docker?

Portability:

Same container runs on:
- Vultr (US)
- Hetzner (EU)
- DigitalOcean (US)
- Linode (US)
- AWS EC2 (anywhere)

Fast deployment:

# On any Ubuntu 22.04 VPS:
docker pull openclaw/openclaw:latest
docker run -d --name minnie-dev \
  -v /opt/species-dna:/species-dna:ro \
  -v /opt/agents/dev:/home/node/.openclaw \
  openclaw/openclaw:latest

# Agent live in ~2 minutes

Why Tailscale?

Provider-independent networking:

All agents join Tailscale mesh β†’ talk to each other via 100.x.x.x IPs

Benefits:
- No VPN config (Tailscale handles it)
- No firewall rules (mesh is encrypted tunnel)
- Works across providers (Vultr agent can talk to Hetzner agent)
- Survives IP changes (Tailscale DNS resolves names)

Example:

# Main session on Vultr (US)
curl http://minnie-dev:8080/health
# β†’ Reaches Dev Agent on Hetzner (EU) via Tailscale mesh

# No public internet exposure needed

Single Bootstrap Script (Works Everywhere)

#!/bin/bash
# scripts/bootstrap-agent-host.sh
# Works on: Vultr, Hetzner, DigitalOcean, Linode, AWS

PROVIDER=$1  # vultr, hetzner, digitalocean, etc.
AGENT=$2     # main, dev, ops

# 1. Install Docker (same on all providers)
curl -fsSL https://get.docker.com | sh

# 2. Install Tailscale (same on all providers)
curl -fsSL https://tailscale.com/install.sh | sh
tailscale up --authkey=$TAILSCALE_KEY --hostname=minnie-$AGENT

# 3. Create directories
mkdir -p /opt/{species-dna,agents/$AGENT,credentials/$AGENT}

# 4. Clone species-dna
git clone https://github.com/playztag/minnie-brain.git /opt/species-dna

# 5. Start agent container
docker run -d --name minnie-$AGENT \
  --restart unless-stopped \
  -v /opt/species-dna:/species-dna:ro \
  -v /opt/agents/$AGENT:/home/node/.openclaw \
  openclaw/openclaw:latest

echo "βœ… Agent $AGENT ready on $PROVIDER"

Cloud-init (provider API pass this script):

#cloud-config
runcmd:
  - curl https://raw.githubusercontent.com/playztag/minnie-brain/main/scripts/bootstrap-agent-host.sh | bash -s hetzner dev

Migration Between Providers (15 min)

Scenario: Dev Agent on Hetzner (EU) β†’ Move to DigitalOcean (US)

# 1. Provision new VPS
python3 scripts/provision-vps.py --provider digitalocean --agent dev

# 2. Wait for Tailscale (auto-joins mesh)
tailscale ping minnie-dev  # Now has 2 IPs (old + new)

# 3. Rsync workspace
rsync -avz /opt/agents/dev/ minnie-dev-new:/opt/agents/dev/

# 4. Switch DNS (Tailscale knows new IP)
tailscale set --alias minnie-dev=minnie-dev-new

# 5. Stop old container
ssh minnie-dev-old docker stop minnie-dev

# 6. Destroy old VPS
python3 scripts/destroy-vps.py hetzner $OLD_ID

# Done. Total downtime: <1 minute

Security: Human Oversight + Containment

Deployment Gate (Human Approval Required)

No agent can spawn itself:

Prevents:


Budget Enforcement (Hard Caps)

Each agent has monthly limit:

Example:

Dev Agent budget: $200/month
Spend to date: $160 (80%)
β†’ Alert sent to Infrastructure group: "Dev Agent at 80% budget"

Spend reaches $200 (100%)
β†’ Agent paused automatically
β†’ "Dev Agent hit cap, paused until approval"
β†’ You decide: Increase budget or investigate why it's high

Credential Isolation

Each agent gets own OAuth apps:

Main: Gmail (quan@ztag.com), Calendar, Drive, Zoho (full access)
Dev: GitHub API only (no financial data)
Ops: Vultr API, monitoring APIs only

Agent CANNOT:

Agent CAN:


Audit Trail (Every Action Logged)

Structured logging:

{"ts": "2026-02-17T03:00:00Z", "agent": "dev", "action": "web_search", "query": "GitHub API rate limits", "cost": 0.02}
{"ts": "2026-02-17T03:05:00Z", "agent": "dev", "action": "exec", "command": "git status", "cost": 0.01}

Weekly review:


Kill Switch (Immediate Stop)

# Pause agent (stop API calls, keep memory)
docker pause minnie-dev

# Stop agent (graceful shutdown)
docker stop minnie-dev

# Nuke agent (delete everything, can't undo)
python3 scripts/nuke-agent.sh dev --confirm

Real-World Deployment: Dev Agent Pilot

Scenario: GitHub Monitoring for Malachi

Problem:

Solution:

Deployment:

  1. I draft proposal (ROI: 15x, budget: $200/mo)
  2. You approve
  3. I provision Hetzner VPS (€3.79/mo)
  4. Agent requests GitHub OAuth (I help)
  5. Agent starts monitoring
  6. 30-day pilot begins

Success metrics (30 days):

Decision point (Day 30):


Cost Comparison: VPS Providers

Provider Small (1 vCPU, 1GB) Medium (2 vCPU, 4GB) Billing API Notes
Hetzner $4.15/mo (€3.79) $7.50/mo (€6.84) βœ… Yes Cheapest, EU-based
Linode $5.00/mo $10.00/mo βœ… Yes Good US performance
Vultr $6.00/mo $12.00/mo βœ… Yes Current provider
DigitalOcean $6.00/mo $12.00/mo βœ… Yes Popular, good docs
AWS EC2 $8.50/mo (t3.micro) $17.00/mo (t3.small) βœ… Yes Expensive, overkill

Recommendation:

Annual savings:


Rollout Timeline

Phase 1: Dev Agent Pilot (Month 1)

Phase 2: Validate Economics (Month 2)

Phase 3: Second Agent (Month 3)

Phase 4: Fleet Operations (Month 4+)


Decision Framework: When to Deploy Agent

Must pass ALL 3 tests:

1. Mission Alignment

2. ROI Threshold

3. Specialization Necessity

Example (Dev Agent):

Example (Marketing Agent):


Summary: Key Decisions

βœ… Approved Patterns

  1. Docker for portability (works on any VPS)
  2. Tailscale for networking (provider-agnostic mesh)
  3. Git for protocol inheritance (fleet-wide updates instant)
  4. Budget caps enforced (80% alert, 100% pause)
  5. Human approval required (deployment gate)
  6. 15-min provisioning (fast, low-friction)
  7. Separate credentials per agent (security isolation)
  8. Hetzner for cost savings (37% cheaper than Vultr)

🚧 Pending Implementation

  1. Budget enforcement script (tools/budget-enforcer.py)
  2. Fleet cost dashboard (species-dna/fleet-cost-dashboard.md)
  3. VPS provisioning wrapper (tools/provision-vps.py)
  4. Migration script (tools/migrate-agent.sh)
  5. Dev Agent proposal (species-dna/deployment-proposals/dev-agent.md)

πŸ“‹ Next Actions

This Week:

  1. You review this document (feedback?)
  2. I implement budget enforcement + fleet dashboard (2 hrs)
  3. We test provisioning on Hetzner (30 min)

Next Week:

  1. I draft Dev Agent proposal (ROI, success metrics)
  2. You approve or reject
  3. If approved: Deploy Dev Agent, 30-day pilot begins

Document Location (Tailscale):
http://100.72.11.53:9876/working/infrastructure/deployment-architecture.md

Feedback welcome. Ready to implement when you are.