Frugal-Cascade is an advanced, cost-saving AI routing system designed to maximize accuracy while relentlessly minimizing API token usage. Inspired by cutting-edge research in LLM cascading, this agent abandons brittle, hardcoded keyword routing in favor of true autonomous confidence evaluation. At the core of the system is an "Adaptive Self-Consistency" engine running entirely locally on a lightweight Qwen 2.5 1.5B GGUF model via llama-cpp-python. For every prompt, the local model attempts to solve the task using a deterministic temperature. It then generates a secondary, creative sample. If the two samples achieve a 2/2 consensus, the agent considers itself "Confident" and returns the local answer, using zero Fireworks API tokens. If the local model disagrees with itself, it generates a tie-breaker. If it remains completely confused (1/3 agreement), the router dynamically intercepts the failure and silently escalates the complex prompt to a powerful Fireworks AI model via the api_client.py. This fallback mechanism guarantees that the agent never sacrifices accuracy to save costs. Furthermore, the agent intelligently parses the ALLOWED_MODELS environment variable to explicitly filter out models that require custom deployments (like Gemma 4), ensuring flawless, out-of-the-box compatibility with the grading harness.
Category tags: