intent-router

$npx mdskill add Tibsfox/gsd-skill-creator/intent-router

Classify query intent and dispatch to the best retrieval or reasoning strategy.

  • Solves the problem of using one retriever for all query types.
  • Depends on Pre-Route and MemFlow research for latent routing ability.
  • Uses a structured prompt to elicit routing decisions from an LLM.
  • Returns a strategy label, token budget, and retrieval depth for downstream handlers.

SKILL.md

.github/skills/intent-routerView on GitHub ↗
---
name: intent-router
description: >
  Classify the information-need of a query and dispatch it to the
  appropriate retrieval or reasoning strategy. Use before read-side
  memory access, before multi-strategy retrieval, or any time you'd
  otherwise default to "one retriever for everything". Returns a
  strategy label, a token budget, and a retrieval depth so downstream
  handlers can be specialised. Backed by Pre-Route (arxiv 2605.10235v2)
  and MemFlow (arxiv 2605.03312v1), which together show LLMs possess
  latent routing ability elicitable via a structured prompt — and that
  externalising the routing decision improves small-model performance
  by ~2x. Triggers: "route this", "what strategy", "before retrieving",
  "intent classification", or any query whose ideal handling depends on
  what KIND of question it is.
user-invocable: true
version: 1.0.2
format: 2025-10-02
triggers:
  - "route this query"
  - "what retrieval strategy"
  - "what reasoning strategy"
  - "intent classification before retrieval"
  - "front-run the memory access"
updated: 2026-05-16
status: ACTIVE
source: arxiv 2605.10235v2 (Pre-Route), 2605.03312v1 (MemFlow)
---

# Intent Router

## Why

The 2026 frontier converges on one architectural shift: **route → strategy → act**, replacing the historical *one-retriever-for-everything* pattern. Different query intents demand categorically different handlers:

- **lookup** — direct factual recall, single retrieval, small budget
- **multi-hop** — chain through intermediate facts, deeper retrieval, larger budget
- **global** — summarise/aggregate across a broad slice, retrieve broadly + compress
- **verification** — check a claim against evidence, retrieve narrowly + compare
- **deep-reason** — escalate to a higher-tier model, retrieve generously, allow chain-of-thought
- **lexical** — exact-match / keyword (BM25 territory), no embedding, narrow budget

The empirical claim: a single fixed strategy is dominated on every axis by the conditional strategy.

## How

Before any memory access or multi-strategy retrieval, run a structured-prompt classification pass that returns:

```json
{
  "strategy": "lookup|multi-hop|global|verification|deep-reason|lexical",
  "token_budget": 2000,
  "retrieval_depth": 5,
  "refinement_policy": "none|verbal-rerank|consensus-check",
  "confidence": 0.0
}
```

If confidence < 0.6, fall back to the broadest strategy (`global`) so the system degrades gracefully rather than mis-routing.

### Output format vs confidence

The full JSON envelope is the canonical form when downstream consumers read it programmatically (typed pipelines, gating code). For inline human-facing routing decisions, taper the ceremony to match the confidence:

- **confidence ≥ 0.9** — emit just the strategy label on one line (e.g., `route: lexical`). The other fields default; don't print the envelope.
- **0.6 ≤ confidence < 0.9** — emit the strategy + 1-line rationale. Skip the JSON.
- **confidence < 0.6** — emit the full JSON envelope with the `global` fallback explicit. This is the only case where the structured output earns its tokens.

Rationale: a CTA audit (`.planning/patterns/skill-audits/intent-router-2026-05-16.md`) found that high-confidence lexical-class probes produced full JSON envelopes that downstream consumers did not read. The output was surface-anchoring without information gain.

## When to skip

- You're already in a typed pipeline whose strategy is fixed (e.g., a search command that's explicitly lexical).
- The query is short enough that the routing call costs more than it saves (rule of thumb: < 20 tokens of question text).
- **Scoped exact-match lookup in a known directory** — the surface form is so cleanly lexical that classification cannot change the outcome. Triggers: "find files in `src/X/` that contain literal string `Y`", "grep for `Z` under `path/`", "list all files referencing `IDENT`". The routing decision is structurally pinned to `lexical`; just `grep`. Added 2026-05-16 from CTA audit (`.planning/patterns/skill-audits/intent-router-2026-05-16.md`) — the bounded probe showed the routing ceremony added overhead without changing the action.
- You're in a streaming/interactive context where added latency dominates the routing payoff.

## Integration

- `wrap:execute` and `wrap:verify` — invoke intent-router as the FIRST step in handler dispatch.
- `gsd-graphify` — already does query routing internally; intent-router exposes the same primitive uniformly to other skills.
- Future `src/memory/strategies/` directory will be the typed substrate; this skill is the policy on top.

## Cross-references

- Rosetta concept #7 (Intent Routing) — canonical definition
- College: `agent-systems / agent-memory / agent-intent-routing`
- Related skills: `graphify` (when query is graph-shaped), `gsd-explore` (when intent is exploratory)

More from Tibsfox/gsd-skill-creator

SkillDescription
3d-interaction-designDesign heuristics for three-dimensional interaction — input modalities (6DoF controllers, gaze, gesture, voice), selection and manipulation techniques (ray-cast, virtual hand, go-go, world-in-miniature), navigation (teleport, continuous, redirected walking), and feedback loops (haptic, audio, visual). Covers Fitts' law in 3D, discoverability vs affordance, safe-zone design, and comfort/simulator sickness mitigation. Use when designing VR/AR interactions, immersive walkthroughs, or any input system where the user's body is the controller.
accessibility-patternsProvides web accessibility best practices for semantic HTML, ARIA, keyboard navigation, color contrast, and screen reader patterns. Use when building UI components, reviewing accessibility, or when user mentions 'a11y', 'accessibility', 'ARIA', 'screen reader', 'keyboard navigation', 'WCAG'.
active-listeningActive listening techniques for effective communication. Covers attending behaviors, paraphrasing, reflective listening, clarifying questions, empathic response, barriers to listening, listening in conflict, and cross-cultural listening. Use when building listening skills, improving understanding in conversation, mediating disputes, or analyzing communication breakdowns.
adversarial-pr-reviewAdversarial spec-compliance PR review — cross-references diffs against approved specs, verifies runtime claims against source, detects competing PRs, audits scope/convention compliance. Use before merging.
agile-methodsAgile and Lean software development methodologies for iterative, adaptive project execution. Covers Scrum (roles, ceremonies, artifacts), Kanban (WIP limits, flow metrics), XP (TDD, pair programming, CI), SAFe overview, Lean Software Development (Poppendieck's 7 principles), user stories (INVEST criteria), estimation via story points and velocity, and the Agile Manifesto's values and principles. Includes Cynefin framework for methodology selection and GSD's relationship to Agile as a structured Lean variant.
algebraic-reasoningSymbolic manipulation, equation solving, and algebraic structures for mathematical reasoning. Covers distributive law, factoring, completing the square, linear through polynomial equation solving, systems of equations (substitution, elimination, Gaussian elimination, matrix methods), algebraic structures (groups, rings, fields), modular arithmetic, polynomial theory, and inequalities. Use when solving equations, simplifying expressions, working with algebraic structures, or performing symbolic manipulation.
algorithmic-awarenessUnderstanding how algorithmic systems shape what users see, know, and do -- from recommendation feeds to search ranking to credit scoring to hiring software. Covers the mechanics of recommendation systems, algorithmic bias and its sources, personalization's effects on information diets, opacity and accountability, AI limitations (hallucination, confident wrongness), and the human-in-the-loop question. Use when a learner needs to think critically about why particular content reached them.
algorithms-data-structuresAlgorithms and data structures from first principles through advanced analysis. Covers sorting (bubble, insertion, selection, merge, quick, heap, radix), searching (linear, binary, BFS, DFS, Dijkstra, A*), fundamental data structures (arrays, linked lists, stacks, queues, hash tables, trees, heaps, graphs, tries), complexity analysis (Big-O, Big-Omega, Big-Theta, amortized), recurrence relations, and algorithm design paradigms (divide-and-conquer, greedy, dynamic programming, backtracking). Use when analyzing, selecting, implementing, or comparing algorithms and data structures.
aminet-browserAminet search and browse: full-text search, category tree navigation, architecture filtering, package detail, and curated collections. Use when searching, browsing, or managing package collections.
aminet-emulatorFS-UAE emulator configuration and launch: hardware profiles, ROM management, WHDLoad integration, config generation, and state snapshots. Use when configuring emulation, managing ROMs, or launching Amiga software.