Complexity Grader
Purpose
The Complexity Grader assigns every incoming request to exactly one complexity bucket before any other processing occurs. The bucket drives:
- Model selection: short-answer requests do not need the highest-capability model; deep-research and full-document requests do
- Token budget: estimated output token count allows the inference layer to pre-allocate compute and enforce latency budgets
- Tool activation: only certain buckets unlock RAG, web search, or agentic tool calls
- Latency targeting: web surface has hard latency SLAs (≤4s for short-answer; ≤12s for medium); the grader ensures requests are not over-processed
Inputs / Signals
| Signal |
How to read it |
| Message length |
Long message with pasted document → likely medium or full-document |
| Verb intent |
"What is…" / "Define" → short-answer; "Draft…" → medium/full-document; "Compare all jurisdictions…" → deep-research |
| Quantifier adverbs |
"thoroughly", "all options", "comprehensive", "compare" → escalate to deep-research |
| Number of jurisdictions |
>2 jurisdictions mentioned → deep-research |
| Document attachment |
Any attached or pasted document → at least medium; multi-document → full-document |
| Workflow reference |
Reference to a workflow.* or agentic skill → agentic |
| Domain specificity |
Named statute / article number → may require web check (recency) |
Complexity Buckets
short-answer
- Estimated output: ≤ 200 tokens
- Typical requests: single factual question ("What is the limitation period for contract claims in the UAE?"), greeting, yes/no legal question, simple definition, quick calculation with a single variable
- Tools activated: none; model answers from training
- Latency target: ≤ 4 seconds first token on web; ≤ 2 seconds on API
medium
- Estimated output: 200–1,500 tokens
- Typical requests: drafting a single clause, reviewing a 1–2 page excerpt, answering a single-jurisdiction legal question with some elaboration, producing a structured short memo
- Tools activated: RAG if user references their own documents; no web search unless freshness is critical
- Latency target: ≤ 12 seconds on web
deep-research
- Estimated output: 1,500+ tokens
- Typical requests: multi-jurisdiction comparison, recent amendment lookup, regulatory landscape overview, case law research, comparative analysis with recommendations
- Tools activated: RAG (firm KB + public legal corpus), web search for recent amendments/rulings, legal data hunter if needed
- Latency target: up to 30 seconds acceptable with a progress indicator; warn user if exceeding 20 seconds
full-document
- Estimated output: 3,000+ tokens, structured output
- Typical requests: full contract draft, complete memorandum of law, due diligence report, full lease or NDA generation
- Tools activated: RAG for precedents; template engine if available; web for any jurisdiction-specific verification
- Latency target: streaming output expected; total generation may take 60–120 seconds; user should see progress
agentic
- Estimated output: multi-step, variable
- Typical requests: any request referencing a
workflow.* skill, multi-step M&A diligence, automated clause-by-clause review with output to a structured report, deposition prep workflow, automated regulatory filing sequence
- Tools activated: full tool suite as specified by the workflow; may include connector calls (Linear, CRM, document storage), calculator tools, multi-turn confirmation gates
- Latency target: asynchronous; user should be informed that results will be delivered in stages
Logic — Grading Rules
Apply rules in order; first match wins:
- If the message is a greeting, chitchat, admin question, or feature question about Louis →
short-answer
- If the message contains a workflow.* reference or multi-step procedure description →
agentic
- If the message attaches multiple documents (>2) or asks for a complete contract draft →
full-document
- If the message contains "compare", "all jurisdictions", "comprehensive", "thoroughly", "case law search", "recent amendments", or ≥3 jurisdictions →
deep-research
- If the message attaches a single document for review or asks for a single clause draft →
medium
- If none of the above match →
short-answer (default; err toward the lighter bucket)
Output
Return a single JSON object on one line:
{
"complexity": "short-answer|medium|deep-research|full-document|agentic",
"estimated_tokens_out": <integer>,
"needs_tools": ["rag", "web", "calc", "legal-data-hunter"],
"confidence": 0.0-1.0,
"grading_reason": "<one sentence>"
}
If the request is ambiguous between two buckets, default to the lighter bucket and include a note in grading_reason. Over-grading (escalating a short-answer to deep-research) wastes compute and harms latency more than under-grading.
Why This Matters
Latency is the single most reported user-experience complaint in legal AI products. The grader prevents two failure modes:
- Over-processing: a greeting triggers RAG retrieval and web search → 8-second response to "Hi"
- Under-processing: a multi-jurisdiction regulatory comparison is handled with no tools → hallucinated answer citing non-existent statutes
The grader is a cheap operation (runs in < 100ms) and pays for itself in reduced compute waste and improved latency across all other requests.
Related Skills
- [[router-intent-detection]]
- [[router-tool-selector]]
- [[router-confidence-scorer]]
- [[router-platform-aware]]
- [[router-jurisdiction-detector]]
- [[router-skip-rag-when-not-needed]]
1---2name: router-complexity-grader3description: Use at the start of every request pipeline to grade the complexity of the incoming request and assign it to a complexity bucket. Buckets drive downstream model selection, token budget, tool activation, and latency targets. Five buckets ranging from short-answer (under 200 tokens) to agentic (multi-step with tool calls and gates). Outputs a JSON object consumed by the tool selector and model router.4license: MIT5---67# Complexity Grader89## Purpose1011The Complexity Grader assigns every incoming request to exactly one complexity bucket before any other processing occurs. The bucket drives:12131. **Model selection**: short-answer requests do not need the highest-capability model; deep-research and full-document requests do142. **Token budget**: estimated output token count allows the inference layer to pre-allocate compute and enforce latency budgets153. **Tool activation**: only certain buckets unlock RAG, web search, or agentic tool calls164. **Latency targeting**: web surface has hard latency SLAs (≤4s for short-answer; ≤12s for medium); the grader ensures requests are not over-processed1718## Inputs / Signals1920| Signal | How to read it |21|---|---|22| Message length | Long message with pasted document → likely medium or full-document |23| Verb intent | "What is…" / "Define" → short-answer; "Draft…" → medium/full-document; "Compare all jurisdictions…" → deep-research |24| Quantifier adverbs | "thoroughly", "all options", "comprehensive", "compare" → escalate to deep-research |25| Number of jurisdictions | >2 jurisdictions mentioned → deep-research |26| Document attachment | Any attached or pasted document → at least medium; multi-document → full-document |27| Workflow reference | Reference to a workflow.* or agentic skill → agentic |28| Domain specificity | Named statute / article number → may require web check (recency) |2930## Complexity Buckets3132### `short-answer`33- **Estimated output**: ≤ 200 tokens34- **Typical requests**: single factual question ("What is the limitation period for contract claims in the UAE?"), greeting, yes/no legal question, simple definition, quick calculation with a single variable35- **Tools activated**: none; model answers from training36- **Latency target**: ≤ 4 seconds first token on web; ≤ 2 seconds on API3738### `medium`39- **Estimated output**: 200–1,500 tokens40- **Typical requests**: drafting a single clause, reviewing a 1–2 page excerpt, answering a single-jurisdiction legal question with some elaboration, producing a structured short memo41- **Tools activated**: RAG if user references their own documents; no web search unless freshness is critical42- **Latency target**: ≤ 12 seconds on web4344### `deep-research`45- **Estimated output**: 1,500+ tokens46- **Typical requests**: multi-jurisdiction comparison, recent amendment lookup, regulatory landscape overview, case law research, comparative analysis with recommendations47- **Tools activated**: RAG (firm KB + public legal corpus), web search for recent amendments/rulings, legal data hunter if needed48- **Latency target**: up to 30 seconds acceptable with a progress indicator; warn user if exceeding 20 seconds4950### `full-document`51- **Estimated output**: 3,000+ tokens, structured output52- **Typical requests**: full contract draft, complete memorandum of law, due diligence report, full lease or NDA generation53- **Tools activated**: RAG for precedents; template engine if available; web for any jurisdiction-specific verification54- **Latency target**: streaming output expected; total generation may take 60–120 seconds; user should see progress5556### `agentic`57- **Estimated output**: multi-step, variable58- **Typical requests**: any request referencing a `workflow.*` skill, multi-step M&A diligence, automated clause-by-clause review with output to a structured report, deposition prep workflow, automated regulatory filing sequence59- **Tools activated**: full tool suite as specified by the workflow; may include connector calls (Linear, CRM, document storage), calculator tools, multi-turn confirmation gates60- **Latency target**: asynchronous; user should be informed that results will be delivered in stages6162## Logic — Grading Rules6364Apply rules in order; first match wins:65661. If the message is a greeting, chitchat, admin question, or feature question about Louis → `short-answer`672. If the message contains a workflow.* reference or multi-step procedure description → `agentic`683. If the message attaches multiple documents (>2) or asks for a complete contract draft → `full-document`694. If the message contains "compare", "all jurisdictions", "comprehensive", "thoroughly", "case law search", "recent amendments", or ≥3 jurisdictions → `deep-research`705. If the message attaches a single document for review or asks for a single clause draft → `medium`716. If none of the above match → `short-answer` (default; err toward the lighter bucket)7273## Output7475Return a single JSON object on one line:7677```json78{79 "complexity": "short-answer|medium|deep-research|full-document|agentic",80 "estimated_tokens_out": <integer>,81 "needs_tools": ["rag", "web", "calc", "legal-data-hunter"],82 "confidence": 0.0-1.0,83 "grading_reason": "<one sentence>"84}85```8687If the request is ambiguous between two buckets, default to the lighter bucket and include a note in `grading_reason`. Over-grading (escalating a short-answer to deep-research) wastes compute and harms latency more than under-grading.8889## Why This Matters9091Latency is the single most reported user-experience complaint in legal AI products. The grader prevents two failure modes:92931. **Over-processing**: a greeting triggers RAG retrieval and web search → 8-second response to "Hi"942. **Under-processing**: a multi-jurisdiction regulatory comparison is handled with no tools → hallucinated answer citing non-existent statutes9596The grader is a cheap operation (runs in < 100ms) and pays for itself in reduced compute waste and improved latency across all other requests.9798## Related Skills99100- [[router-intent-detection]]101- [[router-tool-selector]]102- [[router-confidence-scorer]]103- [[router-platform-aware]]104- [[router-jurisdiction-detector]]105- [[router-skip-rag-when-not-needed]]