A fast, lightweight intent classifier for AI agent and MCP tool routing. Given a user message, it predicts which tool or capability the agent should invoke — in under 50ms on CPU.
Built on DistilBERT (66M params), fine-tuned on 12K+ diverse examples across 8 intent categories.
Every agent framework (LangChain, LangGraph, CrewAI, AutoGen) wastes an entire LLM call just to figure out what the user wants. That's 1-3 seconds and ~$0.01 per request — just for routing.
AgentIntentRouter replaces that first LLM call with a 66M classifier that runs in ~10ms on CPU and ~2ms on GPU. Use it as the first step in your agent pipeline to instantly route to the right tool.
1from transformers import pipeline
2
3router = pipeline("text-classification", model="tripathyShaswata/AgentIntentRouter")
4
5# Single prediction
6result = router("Write a Python function to sort a list")
7print(result)
8# [{'label': 'code_generation', 'score': 0.98}]
9
10# Batch prediction
11messages = [
12 "Search for the latest AI papers",
13 "What's 25% of 1200?",
14 "Draft an email to my boss about the deadline",
15 "Hello!",
16]
17results = router(messages)
18for msg, res in zip(messages, results):
19 print(f" {res['label']:>20} ({res['score']:.2f}) — {msg}")
1from transformers import pipeline
2
3router = pipeline("text-classification", model="tripathyShaswata/AgentIntentRouter")
4
5TOOL_MAP = {
6 "code_generation": handle_code_request,
7 "web_search": handle_search,
8 "math_calculation": handle_calculation,
9 "file_operation": handle_file_ops,
10 "api_call": handle_api_call,
11 "creative_writing": handle_writing,
12 "data_analysis": handle_analysis,
13 "general_chat": handle_chat,
14}
15
16def route(user_message: str):
17 intent = router(user_message)[0]
18
19 if intent["score"] < 0.5:
20 # Low confidence — fall back to LLM for routing
21 return fallback_llm_route(user_message)
22
23 handler = TOOL_MAP[intent["label"]]
24 return handler(user_message)
Apache 2.0 — use it however you want, commercial included.