#1434·khoj

Add an optional Decision Gate to speed up routine agent decisions

Author: Andrea-BrunoCreated Sep 26, 2026Updated Sep 26, 2026

Every message a user sends to Khoj currently goes to a large language model to work out the intent, whether a tool is needed, and what to do next. Even for a simple message that needs no tools and no new lookup, this costs one to three seconds and real money on every turn.

The idea is to put a small, fast decision model at the front door of the chat path. This small model does not write text. In a single quick pass it returns typed answers with confidence scores, such as whether the request needs a tool, whether it can be answered from what is already in the conversation, and what the primary intent is. A simple routing layer then sends each message to the cheapest correct path, and when the small model is unsure it falls back to the full model exactly as it does today. The agent is never worse, only faster when the decision is obvious. The decision models are small and open, so they can run on home hardware, a CPU or a small GPU.

The change is safe to adopt. It is off by default, so a user who does nothing sees the exact current behavior. When it is turned on it runs in shadow mode at first, which means it only classifies the turn and logs its recommendation through the existing logger. It does not change routing, it does not skip the model call, and it does not alter any user-visible behavior. It fails open on any error, timeout, or bad response, so the agent continues exactly as if the gate were off. It adds no heavy dependency because it talks to a local decision endpoint over plain HTTP using aiohttp, which Khoj already uses. The decision model itself is installed separately and is not bundled.

We would like to contribute this as an optional feature. The concept and the reference implementation are by Andrea Bruno and are released under Creative Commons Attribution 4.0. If Khoj adopts the idea or the code, we kindly ask to keep a short credit to Andrea Bruno and a link to the harness-superfast white paper. The decision models themselves, Von, OpenJev and Laya, are third-party open models, and only the integration architecture and the routing method are ours. The white paper is at https://github.com/Andrea-Bruno/harness-superfast.