Documentation
Imagine our property platform as a busy post office. Instead of paying a highly qualified, expensive manager to read and reply to every single letter, text, or bill that comes through the door, we hav
Imagine our property platform as a busy post office. Instead of paying a highly qualified, expensive manager to read and reply to every single letter, text, or bill that comes through the door, we hav
Paperclip Orchestrator
Paperclip is the ultra-fast automated receptionist that triages every incoming email, WhatsApp message, and database event in under 0.1 seconds, routing them to the right specialist AI agent.
Imagine our property platform as a busy post office. Instead of paying a highly qualified, expensive manager to read and reply to every single letter, text, or bill that comes through the door, we have **Paperclip**. Paperclip is an ultra-fast automated receptionist. It receives every incoming email, WhatsApp text, and database event, and in less than 0.1 seconds, decides exactly what it is (e.g., a gas safety certificate, a rent query, or a tenant checking out). It then hands it over to the right "specialist" AI agent (like our Rent Accountant, Compliance Officer, or a background script running on our server called **Hermes**) to execute the work, keeping our operating costs practically at zero.
⚡ Paperclip Orchestrator & Swarm Architecture
Sovereign Engineering (ADR-252)RAIA™ (Real estate Artificial Intelligence Agent) OS utilizes an event-driven, decoupled multi-agent swarm framework. Rather than relying on a single, monolithic LLM to coordinate actions—which introduces high latency, cost, and hallucination vectors—we separate coordination from execution. **Paperclip Orchestrator** is our high-performance, No-LLM central triage and routing engine. It acts as the gatekeeper of all incoming payloads, converting them into structured database transactions that feed our background server, managed by **Hermes Agents**.
Chapter 1: The Design Philosophy (Why Decouple?)
1. The Concurrency & Latency Problem
When thousands of webhooks fire simultaneously (e.g. dozens of tenants messaging on WhatsApp, automated banks matching rent, email attachments uploading), passing them directly to LLM models for classification creates an unviable bottleneck. Latency rises above 15s per reply, and concurrent API rate-limits are hit instantly, blocking the entire pipeline.
2. The No-LLM Triage Solution
Paperclip runs as a lightweight VPS daemon. It triages incoming payloads deterministically using high-performance regex classifiers, header checks, and local schema matchers. It writes payload events directly to the database in **0.1 seconds** for under $0.00001, saving **98.5% in token costs** compared to calling Sonnet 4.6 for raw routing.
3. The Specialist Agent Swarm
Instead of one generalist AI, Paperclip triggers a swarm of highly focused specialist agents:
• Concierge Agent: Handles real-time tenant queries and maintenance triage.
• Compliance Agent: Monitors Gas, EPC, and R2R dates.
• Accounts Agent: Reconciles payments and triggers arrears dunning.
• TRIM & Audit Agents: Clean and format documents.
4. Hermes VPS Execution Engine
While Paperclip manages *live, reactive webhooks*, our server's background processes are managed by **Hermes**. Hermes is our proactive task execution agent. It runs continuous background loops, schedules overnight cron jobs, executes complex system scripts (like Playwright scraping and database healing), and communicates directly with administrators via Telegram.
Chapter 2: The Paperclip-to-Hermes Processing Loop
The relationship between live webhook streams, Paperclip orchestration, the database ledger, and Hermes execution form a continuous event-driven circle:
2.1 The Swarm Framework Taxonomy
Once Paperclip logs an incoming payload, it triggers a specialized multi-agent consensus swarm to execute work asynchronously:
1. Concierge Agent (Reactive)
Triggered immediately on tbl_conversations changes. Pulls the latest live context from tbl_asset_snapshots.snapshot_live and `snapshot_static` and crafts highly factual replies, answering tenant enquiries in seconds.
2. Compliance Guard (Validator)
Activated by document_change or tenancy_start events. Reads parsed document metadata, updates the RRA (Renters' Rights Act) checklist, and triggers warnings if any mandatory certificates are missing or expiring.
3. Accounts Agent (Financial)
Polls our automated bank reconciliation feeds and automated bank reconciliation gateway API hourly. Matches inbound bank payments to tenancy arrears records in tbl_rents. On overdue matches, triggers multi-channel dunning scripts.
4. TRIM & TRIM-Audit Agents (Document Linter)
Scans tbl_documents for newly uploaded files. Executes visual ETL parsing (Gemini Flash), sanitizes unencrypted customer PII, generates concise summaries, and flags any structural address mismatches.
Repository Code
The live codebase implementation for this specification sits within the following repository folder:
Chapter 3: Swarm Integration Webhooks & Telemetry
Paperclip runs multiple API routes within the Next.js portal to route payloads into our shared database. Below is the active routing gateway specification:
| Endpoint Route | Ingestion Stream | Action Performed | Downstream Specialist |
|---|---|---|---|
| /api/webhooks/timelines | Inbound WhatsApp | Normalizes incoming multi-channel WhatsApp payload into tbl_conversations. |
Concierge Agent |
| /api/webhooks/gmail | Inbound Email / PDFs | Strips email attachments, uploads PDF to GCS, and inserts file metadata. | TRIM & Compliance |
| /api/webhooks/telegram | Telegram Bot | Handles on-site agent queries. Detects [SNAPSHOT_GAP] tags. |
Hermes Rebuild Loop |
| /api/agents/reactive | Specialist Direct Call | Receives direct event triggers from integration tests or the Paperclip VPS engine. | Full Swarm |
Chapter 4: Agent Framework File Inventory
Our multi-agent coordination logic and VPS playbooks are organized under the following directories:
| File Path | Module & Responsibility |
|---|---|
| 03_technology/07_agent-framework/ | Base folder containing orchestrator frameworks and core routing algorithms. |
| 03_technology/07_agent-framework/playbooks/ | Contains YAML files specifying multi-agent roles, instructions, and target prompts. |
| 03_technology/11_frontend/portal/src/lib/agents/load-playbook.ts | Loads playbooks dynamically from VPS directories based on active workspace contexts. |
| 03_technology/08_channels/telegram/route.ts | Live Telegram webhook handler that converts pings into structured pipeline triggers. |
Chapter 5: Common Pitfalls & Mitigation Strategies
❌ 1. Event Storming on Real-time Payloads (Severity: Critical)
The Problem: When a tenant uploads 10 separate photos in a row on WhatsApp, 10 separate webhooks fire in 10 seconds. Directing every webhook to trigger an LLM-agent execution creates high API bills and rate limits.
Mitigation: Paperclip acts as an immediate sponge. It writes the photos to tbl_conversations instantly, but debounces downstream specialist agent triggers for **10 minutes**, collapsing multiple inputs into a single execution job.
⚠️ 2. Naming Collision on Entity Resolution (Severity: Caution)
The Problem: Different webhooks use different person structures (e.g. email uses "Mohamed Abd Alrhman", WhatsApp uses "Jadelseed"). Paperclip might create multiple duplicate rows in tbl_persons.
Mitigation: Paperclip enforces our local **Entity Resolution Trace**. It cross-checks phone numbers and emails before writing a new person, auto-aligning variations into a single person record.
Chapter 6: Swarm Vibe Check
Verification Steps (Paperclip Triage)
-
✓
Check
/portfolio/reports/pipelinesdashboard shows clean green status for active webhooks. -
✓
Verify incoming WhatsApp webhooks resolve to correct person record under
tbl_persons.
Verification Steps (Hermes Loops)
-
✓
Check Telegram
@raia_robotlogs show continuous background polling is active. -
✓
Verify
v_rra_compliance_checklistis populated and correctly indexes property license alerts.
Masterclass Reference (YouTube Live)
This architecture is built directly upon the open-source paradigm and masterclass tutorial: "Hermes + Paperclip Just Changed AI Agents Forever" (Watch Live on YouTube). It establishes Paperclip as the canonical web dashboard/orchestrator (Next.js/React) and Hermes as the persistent, VPS-scoped server agent framework—creating a perfect event-driven loop.
Architecture Details
Multi-agent architecture with a hierarchical orchestration model. The orchestrator agent manages task decomposition, worker agent dispatch, and result aggregation. Each agent runs in an isolated context with its own toolset and memory, communicating via a shared message bus.
- Core Component: Agent orchestration engine
- Data Flow: User Request → Orchestrator → Task Decomposition → Worker Agents → Result Aggregation → Response
- Integration Points: Hermes Agent framework, tool registry, memory stores, delegation bus
Configuration Reference
Key configuration parameters for this system:
| Parameter | Type | Default | Description |
|---|---|---|---|
| max_concurrent_agents | integer | 3 | Maximum number of parallel worker agents |
| agent_timeout_seconds | integer | 300 | Agent execution timeout |
| model_routing_policy | string | cost_optimized | Model selection strategy (precision, cost_optimized, speed) |
Figure 2: Agent architecture — component interaction and data flow.
Troubleshooting
| Issue | Cause | Resolution |
|---|---|---|
| Agent timeout | Complex task or downstream dependency failure | Increase timeout or break task into smaller subtasks |
| Orchestrator loop detected | Circular delegation or self-referencing task | Enforce max_spawn_depth and cycle detection |
This component is part of the RAIA (Real estate Artificial Intelligence Agent) platform mono-repo. Implementation details, API contracts, and integration tests are available in the repository.