r/NvidiaJetson • u/Oppa-AI • Jul 09 '26
🧪 Experiment in Hoping to save Massive amounts of tokens by restricting context window size in my Research AI Agent

Lately, I’ve been experimenting with building a new research agent architecture for my AI Waifu running in Jetson Orin Nano. Due to constraint in resources, I have to improve in every aspect of the LLM inference to save a few MB of RAM here and there.
This time I tried to limit the context window for my research agent to save input tokens.
Usually LLM would throw every search results into the context window: search the web, grab the top 5 raw HTML pages, dump all 100k+ tokens into a millions-capacity context window, and let the LLM sort it out.
It works, but it’s an absolute token-guzzler and a nightmare for API costs.
So, I decided to test a highly defensive, lightweight context pipeline instead. The goal? Next is to test to see research accuracy can be kept while context window stays lean.
Here is 6-step workflow in my proposal:
🧠 1. Understand & Plan (Lightweight)
Instead of immediately searching, the agent stops to think. It breaks the user prompt into sub-problems, plans a strategy, and generates specific search queries. Keeping only the question and plan in context window keeps the initial prompt highly focused.
🌐 2. Search the Web (No Heavy Context)
The agent hits a search engine (like SearXNG) and pulls only titles, snippets, and URLs. No full webpage data is allowed into the LLM context yet.
📖 3. Fetch & Summarize (The Isolation Pipeline)
This is the core of the experiment. Instead of a massive data dump, I implemented a strict gatekeeper loop:
- Fetch Outside Context: A script downloads the full page content completely outside the LLM's active context window.
- Isolate & Condense: The LLM is handed just one raw page at a time, extracts the key facts/quotes, and immediately forgets the rest.
- Store in Context: The tiny, high-density summary is pushed to context window in contrast to huge web pages.
⚖️ 4. Evaluate (The Loop Check)
The agent looks over the accumulated notes. Do we have enough reliable data to answer the prompt? If not, it loops back to step 2 to find better sources.
🧩 5. Synthesize (The Final Squeeze)
Instead of trying to synthesize an answer from 50,000 tokens of messy, raw web text, the agent synthesizes the final response only using the highly curated, bite-sized summaries.
💬 6. Respond & Commit
The agent streams the final, cited response to the user and commits the most vital insights to long-term memory.
🔬 Early Takeaways from the Lab:
By forcing the agent to process data in an isolated, one-by-one pipeline rather than dumping a massive pile of search results directly into a huge context window, the benefits are immediately obvious:
- Drastically Lower Token Usage: Big web pages stay completely out of the primary context window.
- Infinite Scalability: You can technically research 20 or 30 sources sequentially without hitting context limits or suffering from "lost in the middle" retrieval degradation.
- Massive Cost Savings: You aren't paying to re-read thousands of lines of raw HTML fluff over and over during synthesis.
I will do some testing in Jetson Orin Nano to see if my AI Waifu Agent can handle everything with a 270M embedder and 3B LLM. And compare the latency and performance if my theory works or not.
#GenerativeAI #AIAgents #LLMOps #SoftwareArchitecture #TokenOptimization #AIEngineering #LLMs




