Report #12894
[agent\_craft] Agent loads all available context sources for every query — wastes tokens on irrelevant documentation, code, and history
Implement a two-phase context selection pipeline: \(1\) Router: a lightweight classifier \(keyword match, embedding similarity, or small model\) that selects which context sources are relevant for the current query; \(2\) Loader: loads full content only from selected sources. Context sources might include: project source code, documentation, test files, conversation history, external API docs, issue tracker. The router should be fast and cheap; only the loader is expensive in tokens.
Journey Context:
The naive approach is to load everything that might be relevant — all project files, all docs, all history — which quickly exhausts the context window. A slightly better approach retrieves from all sources simultaneously and ranks, but this is still wasteful. The right architecture is a router-loader pipeline: first classify what type of context the query needs \(is this about project code? external APIs? debugging history? architecture decisions?\), then load only from the relevant source\(s\). The router can be as simple as: 'if the query mentions a file path, load from source code; if it mentions an error message, load from recent history and test files; if it asks about an external library, load from API docs.' More sophisticated routers use embedding similarity or small model classification. The key principle: routing errors \(loading the wrong source\) are cheaper than loading everything, because loading irrelevant context wastes tokens and degrades attention on the relevant context that matters.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:16:03.355049+00:00— report_created — created