Fixing the context window leak in my ChatGPT Projects setup A developer reported that overloading a ChatGPT Project with 20 or more files caused the RAG retrieval mechanism to miss critical code chunks, producing a hallucination loop in which the model insisted a TypeScript interface was missing a user_id property that was defined on line 14 of types/user.ts. The developer resolved the issue by consolidating 15 separate type files into a single CONTEXT_MAP.md, replacing full API PDFs with Markdown endpoint summaries for a reported 40% faster response time, and splitting work into feature-specific Projects. The developer also noted that single-chat workflows break down past 5,000 lines of code, at which point a dedicated IDE tool is preferable. Fixing the context window leak in my ChatGPT Projects setup I spent four hours last Thursday fighting a "hallucination loop" where ChatGPT /en/tags/chatgpt/ kept insisting my TypeScript interface was missing a property that was clearly defined in the file I'd uploaded to my Project. This happened despite the file being sitting right there in the "Knowledge" section of the Project. The fix wasn't a better prompt. It was realizing that overloading a Project with too many documents creates a "noise" floor that makes the LLM ignore specific lines of code. The specific failure point I was building a custom dashboard using Next.js 14 and a complex Zod schema for validation. I had uploaded my entire /types directory and three API documentation PDFs into a ChatGPT Project to keep the context persistent. Then I hit this: TypeError: Cannot read properties of undefined reading 'user id' I asked the AI why the validation was failing. It replied: "It looks like your UserSchema is missing the user id field. Please add it to your interface to resolve the error." I stared at the screen. The user id was right there on line 14 of types/user.ts . I told the AI it was there. It apologized, then told me it still couldn't find it. The bottleneck wasn't the model's intelligence. It was the way ChatGPT Projects handles retrieval. When you dump 20+ files into a Project, the RAG /en/tags/rag/ Retrieval-Augmented Generation mechanism sometimes retrieves the wrong "chunk" of a file or misses a critical one entirely, leading to those confident but wrong assertions. How I optimized my AI coding workflow I stopped treating the Project Knowledge base as a dumping ground. Instead, I shifted to a "Lean Context" strategy. First, I purged every file that wasn't strictly necessary for the current feature. If I'm working on the frontend UI, I don't need the full AWS infrastructure YAML files in the project knowledge. Second, I started using "Index Files." Instead of uploading 10 small .ts files, I concatenated the most important interfaces into a single CONTEXT MAP.md file. | Old Approach | New Approach | Result | | :--- | :--- | :--- | | 15 separate type files | 1 consolidated CONTEXT MAP.md | Zero "missing property" hallucinations | | Full API PDFs | Markdown summaries of endpoints | 40% faster response time | | Everything in one Project | Feature-specific Projects | Higher accuracy per task | The difference was immediate. By reducing the number of files the model had to "search" through, the precision of the code generation spiked. Connecting the dots with community patterns While cleaning up my local setup, I realized I was basically rebuilding a manual version of what people share in Prompt Sharing /en/category/prompts/ circles. The trick isn't the prompt itself, but the structure of the data you feed the AI. I've found that if you're struggling with the "forgetfulness" of a long session, you need to stop relying solely on the Project's uploaded files. I now use a "State Log" file. At the end of every major coding milestone, I ask the AI to summarize the current state of the architecture and any "gotchas" it found. I then save that summary and upload it as a new file to the Project, while deleting the old, outdated summary. This keeps the context window clean and prevents the AI from referring back to a version of the code from three hours ago. When to move beyond a single chat There is a point where the standard Workflows /en/workflows/ in a chat interface break down. For me, that happens when a project exceeds 5,000 lines of code. If you find yourself constantly correcting the AI on basic project structure, you've likely hit the "Context Ceiling." This is where I stop using the web interface and move the logic into a dedicated IDE tool or a more structured environment. If you're just starting to organize your AI-assisted builds, the PromptCube homepage /en/ is a great place to see how others are structuring their prompts to avoid the exact loop I fell into. The "Clean Context" checklist for your next Project If your AI is starting to hallucinate code that you know exists in your uploaded files, try this: 1. The 5-File Rule : Try to keep your Project Knowledge under 5 high-density files. 2. MD over PDF : Convert your documentation to Markdown. The LLM parses .md significantly better than formatted PDFs. 3. Explicit Referencing : Instead of saying "look at the files," say "Refer to the UserSchema definition in CONTEXT MAP.md on line 22." 4. The Purge : Every two hours, delete any file that represents a "previous version" of your logic. The real cost of AI coding isn't the subscription fee; it's the time you lose fighting a model that thinks it knows your code better than you do. Tightening the context is the only way to stop the drift. Next Should AI companions be banned for under 18s to prevent emotional dependence? → /en/news/9143/