Hierarchical Loops & Polymorphic Comms
This spec documents the real-time visual loops showing background agent processes, pending human gates, and chronological action events in a centralized workspace.
This spec documents the real-time visual loops showing background agent processes, pending human gates, and chronological action events in a centralized workspace.
Hierarchical Loops & Polymorphic Comms
Imagine a team of specialized assistants, each with specific expertise, working together 24/7. They handle routine tasks automatically, only asking for human input when facing truly important decisions.
Hierarchical Loops & Polymorphic Comms
Deconstructing RAIA™ (Real estate Artificial Intelligence Agent) OS into dedicated, nested state-machine loops at each tier of the Rental Pyramid, and abstracting all message deliveries into a single **Polymorphic Comms Engine** to achieve high-leverage agentic design.
1. The 3-Tier Operational Loops
The Rental Pyramid State MachinesEach layer of the pyramid runs its own dedicated background loop. An upper layer loop **cannot execute** until all invariants of the lower loops are fully satisfied and locked in.
Owner Onboarding Loop
Verifies land registry titles and completes KYC/AML checks for beneficial owners before any property registration occurs.
Physical Asset Readiness
Manages physical property readiness—securing keys, safety certificates (EPC, EICR, CP12), and municipal Selective/HMO licenses.
Tenancy Lifecycle Loop
Manages signed ASTs, deposit protections, condition inventories, rent guarantee insurance (RGI), and monthly rent ledger sync.
2. The Polymorphic Comms Engine
Object-Oriented Agent Skills
Instead of duplicating messaging logic inside individual state machines, RAIA™ (Real estate Artificial Intelligence Agent) abstracts all communication into a single **Polymorphic Comms Engine** (or comms-delivery-engine skill). The loop simply passes the recipient and template; the comms engine dynamically resolves transport and tracking:
Repository Code
The live codebase implementation for this specification sits within the following repository folder:
tbl_persons_comms_stats.
3. Unified Object-Oriented Code Specification
By modularizing our skills, we decouple business logic from transport details. Here is how our loops cleanly invoke the Polymorphic Comms skill in the code:
class CommsDeliveryEngine {
private async getPreferences(personId: string) {
// Queries tbl_persons_comms_stats & tbl_persons_channels
const { data } = await supabase
.from('tbl_persons_comms_stats')
.select('comm_preferred, whatsapp_number, email_address')
.eq('person_id', personId)
.single();
return data;
}
public async deliverMessage(
personId: string,
templateKey: string,
params: Record
) {
const pref = await this.getPreferences(personId);
const content = this.compileTemplate(templateKey, params);
// Polymorphic routing based on preferred channels
if (pref.comm_preferred === 'whatsapp') {
return await this.sendWhatsApp(pref.whatsapp_number, content);
} else if (pref.comm_preferred === 'email') {
return await this.sendEmail(pref.email_address, content);
} else {
return await this.sendSMS(pref.whatsapp_number, content); // Fallback
}
}
}
// EXAMPLE LOOP INVOCATION: T2 Property Compliance Loop
class PropertyComplianceLoop {
private comms = new CommsDeliveryEngine();
public async handleExpiringEPC(assetId: string, landlordId: string) {
await this.comms.deliverMessage(landlordId, 'epc_expiry_consent', {
cost: "£79",
date: "June 26"
});
// State machine updates to: PENDING_LANDLORD_CONSENT
}
}
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.