Build notes · AI Architecture & Maturity Framework
Klaros Pragmatic AI Maturity: A Situational Agentic Framework for WhatsApp CRM
The recent industry discourse around AI agent architecture—most prominently articulated at events like the YC Harness Club—focuses heavily on autonomous multi-agent swarms, self-improving prompt harnesses (DSPy), and open-ended Recursive Language Models (RLM). While these paradigms drive massive breakthroughs for coding benchmarks, applying unconstrained agentic swarms to commercial WhatsApp CRM messaging is a dangerous anti-pattern.
The short version
- Rules First: Klaros evaluates outreach through an 8-level priority tree in
agent-decision.mjs. Human staff takeover triggers a 24-hour AI pause to ensure reps are never interrupted. - Zero-Token Caching: In
learned-answer.mjs, repeat operator responses are served via Jaccard similarity at Stage 8000 ahead of the LLM at Stage 9000, delivering $0 token costs and sub-10ms latency. - Local Model Resiliency:
json-repair.mjsnormalizes code fences, trailing commas, and unescaped newlines from local Ollama/Qwen models in <0.5ms before JSON validation.
1. The Harness Paradigm: Hype vs. Commercial WhatsApp Realities
At the YC Harness Club event, researchers demonstrated how scaffolding (memory, tool REPLs, sub-agent coordination) can raise a static model's benchmark performance on ARC-AGI from 30% to 95–100%. However, commercial WhatsApp messaging in Klaros operates under strict real-world constraints:
- WhatsApp Service Window Limits: Meta requires paid, approved template messages outside the 24-hour service window. Ill-timed or malformed messages trigger spam bans against merchant phone numbers.
- Irreversible Commitments: Quoting wrong prices or promising unreleased features permanently damages merchant customer trust.
- Sub-2-Second Latency Budget: WhatsApp users expect quick answers. Multi-agent thought loops that run for 40 seconds destroy user experience and burn token margin.
2. The Klaros 5-Tier Situational AI Maturity Framework
Klaros evaluates every AI capability against a situational maturity ladder. We adopt agentic complexity only when business requirements demand it AND fail-closed guardrails are fully enforced:
- Tier 0 (Shipped): Fail-Closed Heuristic Priority Tree (24h human staff yield).
- Tier 1 (Shipped): Zero-Token Grounded Answer Cache (Jaccard similarity at Stage 8000 = $0).
- Tier 2 (Shipped): Fact-Fenced RAG & Pre-Validation JSON Repair Engine.
- Tier 3 (Q4 2026): Bounded Multi-Turn Goal Execution (3-turn slot collector for 24/7 bookings).
- Tier 4 (H1 2027): Closed-Loop Self-Improving Prompt Harness (Review queue to prompt tuning).
- Tier 5 (Late 2027+): Multi-Agent Swarms & RLMs (Restricted to back-office enterprise ERP tasks).
Test the Klaros AI Engine Live on WhatsApp
Want to experience zero-token caching, sub-10ms responses, and fact-fenced auto-replies in action?
3. Shipped Capabilities: Priority Trees, $0 Caches & JSON Repair
In agent-decision.mjs, Priority 1 evaluates detectOfflineConversation(). If human staff interacted in the last 8 hours, AI automation yields for 24 hours.
Calculate how much your business saves with zero-token caching using our interactive WhatsApp Cost Savings Calculator.
Code Blueprint: src/shared/json-repair.mjs Pre-Validation Engine
export function repairJsonString(raw) {
if (typeof raw !== 'string') return '';
let str = raw.trim();
// 1. Strip markdown code fences
str = str.replace(/^```(?:json)?\s*/i, '').replace(/\s*```$/i, '').trim();
// 2. Extract balanced JSON braces
const start = str.indexOf('{'), end = str.lastIndexOf('}');
if (start !== -1 && end > start) str = str.slice(start, end + 1);
// 3. Remove trailing commas before closing braces
str = str.replace(/,\s*([\}])\}/g, '$1');
return str;
}
4. Future Capabilities: Multi-Turn Goals & Closed-Loop Optimization
Klaros is rolling out Tier 3 bounded multi-turn slot collection (Q4 2026) to prevent off-hours booking drop-off, followed by Tier 4 closed-loop review queue prompt optimization (H1 2027) to auto-tune system prompts from operator edits.
5. Benchmarking Klaros against YC Harness Club Projects
Comparing Klaros against YC Harness Club projects:
- Prime Agent / RLM (Seth Karten): ~10% Sync. Avoided for front-of-house chat to maintain <2s latency.
- OpenJarvis (Jon Saad-Falcon): ~80% Sync. Desktop runs Ollama/Qwen locally;
json-repair.mjshandles small model quirks. - QM @ YC (Josh France & Regan Bell): ~85% Sync. State lives in D1/Durable Objects; priority tree enforces staff yield.
6. Klaros Codebase Architecture Map
Key files in the Klaros AI architecture:
agent-decision.mjs— 8-level priority tree and staff yield.uni-cloud/src/services/inbound/learned-answer.mjs— Zero-token Jaccard cache at Stage 8000.uni-cloud/src/services/ai-auto-reply.mjs— Mandatory citation verification.src/shared/json-repair.mjs— Normalizes open LLM JSON outputs in <0.5ms.
Get the next build note on WhatsApp
Message our line and type NOTES. The latest engineering note comes straight back in the thread.
Send NOTES on WhatsAppExperience the Klaros AI Engine First-Hand
Not a sales form. Message our live line and type pricing or ai-demo. You will receive our live catalog, real-time availability slots, and instant zero-token answer resolution.
+91 97893 77634 · You message first, so nothing reaches you without your explicit say-so.
Questions about the Klaros AI maturity framework
Why does Klaros use a fail-closed priority tree instead of unconstrained LLM agent loops?
On official WhatsApp Cloud APIs, freeform messages must adhere to Meta's 24-hour service window, and unvetted automated messages can trigger spam blocks. Klaros runs an 8-level heuristic priority tree in agent-decision.mjs to enforce human staff takeover detection, opt-out checks, and sequence rules before invoking an LLM.
How does the zero-token learned answers cache work in Klaros?
Verified operator responses from the review queue are stored in knowledge_answers. Inbound queries are tokenized and scored using Jaccard term similarity (MATCH_FLOOR = 0.6) at Stage 8000 in learned-answer.mjs. Matches are served instantly at $0 token cost ahead of the LLM model at Stage 9000.
What is the Pre-Validation JSON Repair Engine in json-repair.mjs?
Local desktop installations running smaller open models (like Ollama llama3.2:3b or Qwen) often produce minor markdown code fences, trailing commas, or unescaped newlines. repairJsonString() normalizes malformed JSON in <0.5ms before schema validation, preventing false-positive human handoffs.
How does Klaros compare to YC Harness Club autonomous swarms?
YC Harness Club projects like Prime Agent and OpenJarvis focus on open-ended research or coding swarms where trial-and-error is acceptable. Klaros prioritizes sub-2-second latency, fail-closed customer safety, and $0 zero-token caching, reserving multi-agent swarms strictly for optional back-office ERP tasks.
What is the roadmap for Klaros AI agent capabilities?
Klaros is rolling out Tier 3 bounded multi-turn slot collection (Q4 2026) for 24/7 appointment bookings, followed by Tier 4 closed-loop review queue prompt optimization (H1 2027) to refine system prompts automatically based on operator edits.
Written 8 September 2026. We append when the facts change. Related: Klaros chatbot as-is AI architecture, Klaros autonomous AI agent to-be architecture, all build notes.