Asoba Zorora Documentation

Routing Mechanism

Deterministic pattern matching for workflow routing.

Overview

Zorora uses deterministic routing with pattern matching instead of LLM-based orchestration. This ensures 100% reliability with 4B models and eliminates routing failures.

Routing Decision Tree

Priority Order

  1. File Operations (highest priority)
  2. Code Generation
  3. Research Queries
  4. Simple Q&A (fallback)

Pattern Matching

File Operations:

if re.search(r'\b(save|load|list|show|delete)\b', user_input.lower()):
    return {"workflow": "file_op", "action": "..."}

Code Generation:

if re.search(r'\b(write|create|generate).*\b(function|class|script|code)', user_input.lower()):
    return {"workflow": "code", "tool": "use_codestral"}

Research Queries:

if re.search(r'\b(what|why|how|tell me|based on|newsroom|web search)\b', user_input.lower()):
    return {"workflow": "research", "action": "multi_source_research"}

Simple Q&A (Fallback):

return {"workflow": "qa", "tool": "use_reasoning_model"}

Routing Examples

File Operations

Input: “save research to file.txt” Route: file_opsave action

Input: “load previous research” Route: file_opload action

Input: “list all research” Route: file_oplist action

Code Generation

Input: “write a function to parse JSON” Route: codeuse_codestral

Input: “create a REST API endpoint” Route: codeuse_codestral

Input: “generate a Python script” Route: codeuse_codestral

Research Queries

Input: “What are the latest developments in LLM architectures?” Route: researchmulti_source_research

Input: “Why do solar panels degrade over time?” Route: researchmulti_source_research

Input: “How does battery storage work?” Route: researchmulti_source_research

Simple Q&A

Input: “Explain async/await” Route: qause_reasoning_model

Input: “What is a virtual power plant?” Route: qause_reasoning_model

Slash Commands

Slash commands bypass pattern matching and force specific workflows:

Why Pattern Matching?

Problem: LLM Routing Fails with 4B Models

LLM-based routing requires:

4B models fail at:

Solution: Deterministic Pattern Matching

Benefits:

Trade-offs:

Implementation

Simplified Router

File: simplified_router.py

Core Function:

def route(self, user_input: str) -> Dict[str, Any]:
    # Priority 1: File operations
    if re.search(r'\b(save|load|list|show|delete)\b', user_input.lower()):
        return {"workflow": "file_op", "action": "..."}
    
    # Priority 2: Code generation
    if re.search(r'\b(write|create|generate).*\b(function|class|script|code)', user_input.lower()):
        return {"workflow": "code", "tool": "use_codestral"}
    
    # Priority 3: Research queries
    if re.search(r'\b(what|why|how|tell me|based on|newsroom|web search)\b', user_input.lower()):
        return {"workflow": "research", "action": "multi_source_research"}
    
    # Priority 4: Simple Q&A (fallback)
    return {"workflow": "qa", "tool": "use_reasoning_model"}

Pattern Matching Rules

File Operations:

Code Generation:

Research Queries:

Simple Q&A:

Performance

Routing Decision: 0ms

Comparison:

Extending Routing

Adding New Patterns

Step 1: Add pattern to simplified_router.py

# Priority X: New workflow
if re.search(r'\b(new_keyword)\b', user_input.lower()):
    return {"workflow": "new_workflow", "action": "..."}

Step 2: Implement workflow handler

Step 3: Test pattern matching

Adding Slash Commands

Step 1: Add command handler in repl.py

if cmd_lower.startswith('/newcommand'):
    # Handle command
    return result

Step 2: Update command documentation

Step 3: Test command

See Also