Back to ghost malone

Friday Router

Intelligent multi-model task routing via OpenRouter

Friday Router automatically classifies task complexity and routes to the optimal GLM model. Simple tasks get fast responses, complex problems get deep thinking — all without manual selection.

3-stage routing pipeline
      graph TD
        A["Task Input"] --> B["STAGE 1: Triage
GLM 4.7 Flash
Classify complexity"] B -->|"simple"| C["GLM 4.7 Flash
Fast responses"] B -->|"medium"| D["GLM 4
Balanced"] B -->|"complex"| E["STAGE 2: Orchestrator
GLM 5.0"] E -->|"configure"| C E -->|"configure"| D E -->|"configure"| F["STAGE 3: Sub-agent
GLM 5.0
Deep analysis"] C --> G["Response + Metadata"] D --> G F --> G style A fill:#6366f1,stroke:#4f46e5,color:#ffffff style B fill:#10b981,stroke:#059669,color:#ffffff style E fill:#f59e0b,stroke:#d97706,color:#ffffff style F fill:#8b5cf6,stroke:#7c3aed,color:#ffffff style G fill:#1a1a1a,stroke:#6366f1,color:#ffffff style C fill:#1a1a1a,stroke:#10b981,color:#ffffff style D fill:#1a1a1a,stroke:#f59e0b,color:#ffffff

🔄 The 3-Stage Routing Flow

Every task flows through three intelligent stages to ensure optimal model selection and response quality.

Stage 1
Triage
zhipu/glm-4-flash
Ultra-fast classification. Analyzes task and assigns complexity: simple, medium, or complex.
Stage 2
Orchestrator
zai/glm-5
Smart routing decisions. Selects model, configures parameters, handles fallbacks.
Stage 3
Sub-agent
varies by task
Executes task with appropriate model. Returns response with full metadata.

🧠 Models in the Pipeline

Each stage uses a specialized GLM model optimized for its role in the routing pipeline.

  • Triagezhipu/glm-4-flash Ultra-fast classification, <1s response
  • Orchestratorzai/glm-5 Smart routing and configuration
  • Simple Taskszhipu/glm-4-flash Quick responses, max 500 tokens
  • Medium Taskszhipu/glm-4 Balanced performance, max 2000 tokens
  • Complex Taskszai/glm-5 Maximum capability, max 4000 tokens
  • 📊 Task Complexity Classification

    Friday Router automatically categorizes tasks into three complexity levels, each with optimized model selection and token limits.

    Complexity Model Examples Max Tokens Typical Time
    ⚡ Simple glm-4-flash Definitions, basic questions, simple conversions, quick lookups, single-step operations 500 <1s
    🔶 Medium glm-4 Explanations with examples, comparisons, summaries, code reviews, multi-step analysis 2000 2-5s
    🟣 Complex glm-5 Architecture design, implementation from scratch, complex refactoring, multi-component systems 4000 5-15s

    📦 Installation

    Get started with Friday Router in minutes. Requires Node.js 18+ and an OpenRouter API key.

    Install via ClawHub
    clawhub install friday-router
    Or clone directly
    cd ~/.openclaw/workspace/skills
    git clone https://github.com/your-org/friday-router.git
    Set your OpenRouter API key
    export OPENROUTER_API_KEY=sk-or-v1-your-key-here
    🔑 Get your API key:

    Sign up at openrouter.ai to get your API key. OpenRouter provides unified access to multiple AI models including GLM.

    💻 CLI Usage

    Use Friday Router from the command line for quick tasks and testing.

    Direct task
    node scripts/route.mjs "What is machine learning?"
    With context
    node scripts/route.mjs "Explain React hooks" --context "frontend developer"
    With file attachment
    node scripts/route.mjs "Review this code" --file ./code.js
    Enable debug logging
    FRIDAY_LOG_LEVEL=debug node scripts/route.mjs "task"

    🔌 Programmatic API

    Integrate Friday Router into your own applications and workflows.

    Basic usage
    import { routeTask } from './scripts/route.mjs';
    
    const result = await routeTask({
      task: "Build a REST API",
      context: "Node.js backend",
      files: ["./server.js"]
    });
    
    console.log(result);
    Response format
    {
      response: "...",  // The actual response
      metadata: {
        complexity: "complex",
        model: "zai/glm-5",
        tokens: { input: 150, output: 1200 },
        time: 8423,
        retries: 0,
        routing_path: ["triage", "orchestrator", "agent"]
      }
    }

    ⚙️ Configuration

    Customize Friday Router behavior by editing config.json.

    config.json
    {
      "complexity_thresholds": {
        "simple": {
          "max_tokens": 500,
          "keywords": ["define", "what is", "quick"],
          "max_steps": 1
        },
        "medium": {
          "max_tokens": 2000,
          "keywords": ["explain", "compare", "review"],
          "max_steps": 3
        },
        "complex": {
          "max_tokens": 4000,
          "keywords": ["design", "implement", "architecture"],
          "max_steps": 10
        }
      },
      "routing": {
        "max_retries": 3,
        "timeout_ms": 60000,
        "fallback_model": "zhipu/glm-4-flash"
      }
    }
    Environment variables
    # Required
    OPENROUTER_API_KEY=sk-or-v1-...
    
    # Optional
    FRIDAY_LOG_LEVEL=debug    # Logging level
    FRIDAY_TIMEOUT=30000      # Override timeout (ms)

    📝 Real Examples

    See how Friday Router classifies and routes different types of tasks.

    Simple task example
    $ node scripts/route.mjs "Define API"
    
    Response: "API stands for Application Programming Interface..."
    
    Metadata: {
      complexity: "simple",
      model: "zhipu/glm-4-flash",
      tokens: { input: 12, output: 45 },
      time: 823
    }
    Medium task example
    $ node scripts/route.mjs "Compare REST vs GraphQL"
    
    Response: "REST and GraphQL are both API design approaches..."
    
    Metadata: {
      complexity: "medium",
      model: "zhipu/glm-4",
      tokens: { input: 18, output: 890 },
      time: 3241
    }
    Complex task example
    $ node scripts/route.mjs "Design a microservices architecture for e-commerce"
    
    Response: "For an e-commerce microservices architecture..."
    
    Metadata: {
      complexity: "complex",
      model: "zai/glm-5",
      tokens: { input: 24, output: 2100 },
      time: 8934
    }

    🛡️ Error Handling

    Friday Router includes robust error handling to ensure reliable responses.

  • Automatic retries — Up to 3 attempts with exponential backoff
  • Fallback model — If preferred model fails, uses GLM 4 Flash
  • Timeout protection — 60s max per request (configurable)
  • Error metadata — Full error details in response for debugging
  • 🚀 Performance Optimization

    Built-in optimizations ensure fast, efficient routing at scale.

  • Triage caching — Similar tasks skip re-classification
  • Parallel routing — Orchestrator preps while triage finishes
  • Model warmup — Maintains connection pools for faster responses
  • Smart batching — Groups similar tasks for efficiency
  • 🔗 Integration with Other Skills

    Friday Router works seamlessly with other skills in the ghost malone ecosystem.

  • brain — Store routing patterns for learning and optimization
  • smart-compact — Efficient context management during routing
  • orchestrator — Delegate complex tasks to specialized sub-agents
  • 🔮 Future Enhancements

    Planned improvements to make Friday Router even more powerful.

  • Learn from past routing decisions
  • Cost optimization (prefer cheaper models when appropriate)
  • A/B testing different models
  • Streaming responses
  • Batch processing mode
  • 💡 Pro tip:

    Start with simple tasks to test the routing. The triage stage learns from patterns, so the more you use it, the better it gets at classifying your specific use cases.