---
title: "Comment by Ethan Frost on \"Stop Wasting 50K Tokens Per Conversation & Pre-Index Your Codebase for AI Assistants\" | Hashnode"
description: "Pre-indexing is the right approach. The default behavior of most agent frameworks is to re-read the entire codebase context on every turn, which is wildly waste"
url: "https://hashnode.com/posts/stack-shared-ai/69d9d5afc8e5007ddb4ba381/comment/69db4e28aadf1107e2a50e88"
---

[Discussion](https://hashnode.com/posts/stack-shared-ai/69d9d5afc8e5007ddb4ba381)

Comment [Stop Wasting 50K Tokens Per Conversation & Pre-Index Your Codebase for AI Assistants](https://hashnode.com/posts/stack-shared-ai/69d9d5afc8e5007ddb4ba381)

[Ethan Frost](https://hashnode.com/@ethanfrost)

[Apr 12](https://hashnode.com/posts/stack-shared-ai/69d9d5afc8e5007ddb4ba381/comment/69db4e28aadf1107e2a50e88)

Pre-indexing is the right approach. The default behavior of most agent frameworks is to re-read the entire codebase context on every turn, which is wildly wasteful. A pre-built index that the agent can query selectively — like a codebase-aware RAG layer — cuts token usage dramatically. The key insight: most agent turns only need 2-3 files of context, not the full repo. If you can pre-index with embeddings and let the agent pull just what's relevant, you save 80%+ on tokens without losing quality. This is especially critical for teams tracking cost per session.

[Akshat Bhuhagal](https://hashnode.com/@Axat)

[Apr 15](https://hashnode.com/posts/stack-shared-ai/69d9d5afc8e5007ddb4ba381/comment/69db4e28aadf1107e2a50e88#reply-69df1ff291716f3cfba9d9aa)

Thanks & totally agree, this just make so much more sense both from a cost and performance perspective
