
Hybrid Token Routing Agent is an autonomous AI system that solves tasks while minimizing token usage and inference cost without sacrificing answer quality. Built for the LabLab AMD Developer Hackathon Act-II, the project demonstrates intelligent model selection by dynamically routing each request to the most appropriate execution path. The agent processes tasks from a JSON input file and produces structured JSON results. It uses a three-stage routing pipeline. First, a deterministic solver handles simple mathematical expressions locally, eliminating unnecessary model calls. Next, medium-complexity tasks are answered by a locally hosted Ollama Llama 3.2 model running inside Docker. Finally, only tasks requiring advanced reasoning or deeper analysis are routed to Fireworks AI models, reducing external API usage and associated costs. Before selecting a model, the agent estimates task complexity based on prompt characteristics such as length, keywords, and expected reasoning depth. It also estimates token usage and matches the task against model capability profiles to select the lowest-cost model capable of producing an accurate response. The system records the selected route, estimated token usage, confidence score, and routing reason for every task, providing transparency into its decision-making process. Running entirely in Docker makes the solution portable and reproducible while enabling efficient local inference. This project demonstrates practical AI agent design through intelligent routing, cost-aware inference, and efficient resource utilization.
13 Jul 2026