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.

Every request is assigned exactly one of 8 routing categories. The category taxonomy is defined server-side in routing/prompt-builder.ts (DEFAULT_CATEGORIES), so it cannot be overridden by individual clients.

CategoryWhen It’s Chosen
CODINGWriting, debugging, reviewing, or explaining code. Any request involving programming languages, scripts, algorithms, or software development.
REASONINGComplex analysis, comparisons, multi-step logic, math, science explanations, strategic thinking, or anything requiring deep thought.
CREATIVEWriting stories, poems, marketing copy, brainstorming, humor, or any open-ended creative task.
VISIONOnly when the user has attached an image and wants it analyzed, described, or interpreted (requires an image attachment).
DOCUMENTOnly when the user has attached a document (PDF, text file) and wants it summarized, analyzed, or queried (requires an attachment).
FASTPure micro-interactions with no knowledge retrieval, greetings, single-word acknowledgements, or trivial arithmetic needing no explanation.
SECURITYSecurity analysis, vulnerability assessment, threat modeling, CTF challenges, penetration testing, malware analysis, or cybersecurity topics.
GENERALThe default for conversational queries, factual questions, explanations, and summaries that don’t clearly fit a more specific category. When in doubt, GENERAL.

Routing rules bias the classifier toward the more specific category when a request could match several (e.g. CODING over GENERAL for anything code-related, GENERAL over FAST whenever a fact or concept must be retrieved or explained).

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”)