Skip to content

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.

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.

ConceptDescriptionKey File
Intent SignalA typed classification of what the request is asking forrouting/types.ts
Classification ConfidenceHow certain the classifier is about its decisionworkflow/classifier.ts
Workflow StyleWhether the task is agentic, interactive, batch, or streamingworkload/signals.ts
Routing PromptThe assembled prompt sent to the routing enginerouting/prompt-builder.ts
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.ts

The system extracts signals from the request text to infer intent. Key signal types:

  • High urgency: “fix now”, “urgent”, “broken”, “error”, “crash”
  • Low urgency: “explain”, “review”, “when you have time”, “draft”
  • 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”
  • Simple: “hello”, “quick question”, “one-liner”
  • Medium: “component”, “function”, “small script”
  • Complex: “architecture”, “system design”, “multi-file”, “review entire codebase”
FileWhat It Does
workflow/classifier.tsMain classification entrypoint. Parses request text, returns intent classification with confidence scores
routing/prompt-builder.tsAssembles the routing prompt from classified intent + workload context
routing/types.tsType definitions for intent signals, routing decisions, and strategy selectors
workload/signals.tsSignal extraction helpers, urgency, cost sensitivity, latency sensitivity

The intent classification feeds directly into:

  1. Workload Analysis, the classified intent is combined with file-context signals to build a workload profile
  2. Strategy Engine, intent determines which strategy (cost, speed, quality, balanced) is most appropriate
  3. Provider Scoring, intent signals weight the scoring dimensions (e.g., coding intent prioritizes code-capable models)
  4. Explainability, the classified intent appears in routing explanations so users understand why a model was chosen
  • Confidence threshold: Classifications below a confidence floor are marked uncertain and 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”)