Report #2851
[architecture] When should I use an LLM to route requests versus hard-coded rules?
Use deterministic rules \(keywords, metadata, regex, or a RunnableBranch/RunnableLambda\) when route boundaries are stable; use an LLM router only when categories are semantically overlapping and you have an eval set to measure mis-routes. Always provide a default fallback and surface routing decisions in traces.
Journey Context:
Routing can be rule-based, embedding-based, or LLM-based. Many tutorials route every request through an LLM, which adds latency, cost, and non-deterministic misclassification. LangChain's routing docs explicitly recommend a custom function returning the right runnable as the cleanest pattern; RunnableBranch is a convenience wrapper around the same idea. Use an LLM classifier only when the categories are fuzzy and the cost of a wrong route is low, and validate it against held-out examples. Rule-based routing is faster, cheaper, and fully auditable.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T14:30:03.327232+00:00— report_created — created