PatchPal TinyAgent: a coding agent on a 4B model and a 6GB laptop GPU
- Hardware
- Laptop with an NVIDIA RTX A1000 (6GB VRAM)
- Models & engines
- Ollama serving Gemma 4 E4B or Qwen3.5 4B
Context window of 16K or 32K (OLLAMA_CONTEXT_LENGTH) - Key gotcha
- Qwen3.5 4B fits fully on the GPU only up to about 32K; at 128K more than half runs on the CPU
What they built
Coding agent harnesses are usually built for cloud frontier models, which isn't an option when the code is sensitive, API costs add up, or you want it to run on the laptop in front of you. WiseProbe built TinyAgent, a version of its PatchPal agent for small open models on a laptop with an NVIDIA RTX A1000 (6GB of VRAM).
It is based on NVIDIA Research's paper You don't need long context: compact often to a handoff note about the work still ahead, and read large inputs in small, bounded pieces. TinyAgent is chosen automatically when the context limit is 64K tokens or less.
In a real session with Qwen3.5 4B at 16K, it read and summarized a ~500-line source file by following truncation hints, recovered from one empty response and compacted once. With Gemma 4 E4B at 32K, it wrote and ran a heading-extraction script over 25 docs files and got the counts right.
Setup
- Laptop with an NVIDIA RTX A1000 (6GB VRAM)
- Ollama serving Gemma 4 E4B or Qwen3.5 4B
- Context window of 16K or 32K (OLLAMA_CONTEXT_LENGTH)
- PatchPal with TinyAgent, from the CLI or Python
How it works
- At 80% context, the model writes a handoff note (objective, established facts, changes, dead ends, next step, files read) and the conversation restarts from that note
- The handoff note is capped at about 10% of the window; the full conversation is saved under ~/.patchpal/ first
- Each tool result is capped at about 15% of the window, with a hint saying exactly which lines to read next
- A short extra system prompt spells out exact tool names, the window size and to use grep before reading
- Only core tools are enabled by default, cutting tool definitions from about 5,900 tokens to 1,400
Results & numbers
- Both 4B models run fully on the GPU at 32K and below, using about 4GB of GPU memory, at about 35 tokens/s at 16K and 25 at 32K
- A 100K-token prompt with Gemma 4 E4B took over a minute to process and then generated about 5.5 tokens/s
- The heading script found 25 files and 331 headings, with none of the 67 # comments in configuration.md counted
- One compaction took context usage from 83% to 39%
Gotchas
- Qwen3.5 4B fits fully on the GPU only up to about 32K; at 128K more than half runs on the CPU
- The 16K summary guessed wrong values (90% and 10 handoffs instead of 80% and 5) for settings in a file it never read
- The model said it had handled the fence rule when its script didn't; the output was right, the claim was not
- With Ollama, LiteLLM numbers every streamed tool call 0, which merged parallel calls into one invalid call until PatchPal started a new call whenever the call ID changed
“The lesson for small models: trust what they read, and verify specifics they didn't.”— WiseProbe
Do it yourself
- Export OLLAMA_CONTEXT_LENGTH=16384 and run ollama serve
- Pull a 4B tool-calling model such as gemma4:e4b or qwen3.5:4b
- Export PATCHPAL_CONTEXT_LIMIT to match the server window
- Run patchpal --model ollama_chat/gemma4:e4b and check ollama ps shows 100% GPU before raising the window
- Keep tasks focused: single functions, reported errors, small edits
# Terminal 1: serve a 4B model with a 16K window
export OLLAMA_CONTEXT_LENGTH=16384
ollama serve
# Terminal 2: tell PatchPal the window size and run it
export PATCHPAL_CONTEXT_LIMIT=16384
patchpal --model ollama_chat/gemma4:e4bSimilar setups
Local AI: a one-click Windows app that picks a model for your PC and sets up Ollama for friends
Tired of setting up local LLMs for friends, a developer built a free MIT-licensed Windows app that detects your GPU and RAM, installs Ollama without admin rights, pulls a fitting model and opens a private chat.
A €200 mini PC as an offline AI box: a week with Gemma and Qwen
Diogo Soares ran Gemma 4 E4B and Qwen2.5-Coder 7B on a cheap NiPoGi P1 mini PC firewalled off the internet, used it from his Mac for a week, and measured what was fast and what wasn't.
Getting OpenCode to work with a local Ollama model by fixing the 4,096-token context
OpenCode on a local Ollama model ignored files, invented tasks or looped, because each ~23k-token request was silently cut to fit Ollama's default 4,096-token context on a 16 GB GPU.
OzAI: a self-hosted ChatGPT on a 16 GB MacBook with Ollama, LiteLLM and Open WebUI, and what broke
A DevOps engineer served Qwen3 8B and Qwen2.5-Coder 3B from one M1 Pro laptop as a small private platform with per-user keys, rate limits, local web search and IDE chat, and documented seven silent failures.