Intent Classification
The Intent Classification Layer is the first gate every request passes through. It determines what the user is trying to accomplish, a quick autocomplete, a code review, a multi-file refactor, or a creative writing task, and tags the request with semantic intent metadata that downstream layers use for routing decisions.
Why It Matters
Section titled “Why It Matters”Not all LLM requests are equal. A “write me a React component” request needs a different provider, model, and budget than a “explain this error” request. Intent classification ensures Layerr doesn’t treat a five-minute coding task the same as a deep reasoning session.
Core Concepts
Section titled “Core Concepts”| Concept | Description | Key File |
|---|---|---|
| Intent Signal | A typed classification of what the request is asking for | routing/types.ts |
| Classification Confidence | How certain the classifier is about its decision | workflow/classifier.ts |
| Workflow Style | Whether the task is agentic, interactive, batch, or streaming | workload/signals.ts |
| Routing Prompt | The assembled prompt sent to the routing engine | routing/prompt-builder.ts |
The Classification Pipeline
Section titled “The Classification Pipeline”Raw Request | v[1] Extract Text Signals --> urgency keywords, tool keywords, complexity cues | v[2] Classify Workflow --> classifyWorkflow() in workflow/classifier.ts | v[3] Build Routing Prompt --> routing/prompt-builder.ts | v[4] Enrich Decision --> enrichRoutingDecision() in routing/enrichment.tsSignal Extraction
Section titled “Signal Extraction”The system extracts signals from the request text to infer intent. Key signal types:
Urgency Signals
Section titled “Urgency Signals”- High urgency: “fix now”, “urgent”, “broken”, “error”, “crash”
- Low urgency: “explain”, “review”, “when you have time”, “draft”
Tool Usage Prediction
Section titled “Tool Usage Prediction”- Agentic style: “create a file”, “run tests”, “deploy”, “execute”
- Interactive style: “what is”, “how do”, “explain why”
- Batch style: “refactor all”, “migrate every”, “batch process”
Complexity Signals
Section titled “Complexity Signals”- Simple: “hello”, “quick question”, “one-liner”
- Medium: “component”, “function”, “small script”
- Complex: “architecture”, “system design”, “multi-file”, “review entire codebase”
File Reference
Section titled “File Reference”| File | What It Does |
|---|---|
workflow/classifier.ts | Main classification entrypoint. Parses request text, returns intent classification with confidence scores |
routing/prompt-builder.ts | Assembles the routing prompt from classified intent + workload context |
routing/types.ts | Type definitions for intent signals, routing decisions, and strategy selectors |
workload/signals.ts | Signal extraction helpers, urgency, cost sensitivity, latency sensitivity |
Integration with Downstream Layers
Section titled “Integration with Downstream Layers”The intent classification feeds directly into:
- Workload Analysis, the classified intent is combined with file-context signals to build a workload profile
- Strategy Engine, intent determines which strategy (cost, speed, quality, balanced) is most appropriate
- Provider Scoring, intent signals weight the scoring dimensions (e.g., coding intent prioritizes code-capable models)
- Explainability, the classified intent appears in routing explanations so users understand why a model was chosen
Guardrails
Section titled “Guardrails”- Confidence threshold: Classifications below a confidence floor are marked
uncertainand trigger conservative routing (balanced strategy, premium provider) - Ambiguity fallback: Multi-intent requests (e.g., “explain and fix”) are split or routed to the most capable model
- Workspace override: Workspace profiles can pin specific intents to specific strategies (e.g., “always use speed for autocompletes”)