
This project is a production-grade multi-agent orchestration engine designed to maximize LLM response accuracy while minimizing cloud token expenses. The architecture coordinates a hybrid pipeline that automatically routes queries between zero-cost local inference (Ollama running gemma3:1b) and cloud-bursting capabilities on Fireworks AI (utilizing DeepSeek-V4-Pro). The core pipeline operates across several key stages: Two-Layer Caching: A local O(1) semantic cache powered by a FAISS vector index (using all-MiniLM-L6-v2 embeddings) sits alongside an exact SHA-256 prompt-hash cache. Any near-duplicate queries match at a 0.92 cosine similarity threshold, delivering immediate answers at zero token cost. Multi-Dimensional Routing: When a cache miss occurs, the query's complexity, domain, and requirements are evaluated. The Routing Engine computes utility scores for candidate models across 11 dimensions, prioritizing local execution but escalating progressively through five distinct tiers up to DeepSeek-V4-Pro if a higher reasoning capability is required. Verification & Reflection: Responses undergo defensive evaluation by the Local Verifier across seven strategies (such as schema, completeness, and AST code execution syntax checks). If verification fails, the self-healing Reflection Agent classifies the failure (e.g. formatting, hallucination) and executes context-aware retries or tier escalations. By embedding telemetry, loop-detection safety limits, and keeping all parameters config-driven via YAML files, this framework establishes a robust, highly optimized, and self-healing bridge between local compute and cloud intelligence.
13 Jul 2026