Harness Tricks for Coding Agents on Local Models with Small Context Windows
The core problem is that most coding agent harnesses are tuned for frontier models with 200K-token context windows and the ability to self-correct.
By Dillip Chowdary • Dec 05, 2026 • Source: blog.wiseprobe.io

At a glance
- Harness
- PatchPal, for regulated/air-gapped environments
- Window target
- 16K–32K tokens (as low as 8K)
- Test hardware
- RTX A1000, 6GB VRAM, Gemma 4 E4B
- Tool overhead (full)
- ~5,900 tokens; TinyAgent: ~1,100 tokens
- Compaction threshold
- 80% of configured window
- Source paper
- NVIDIA "You don't need long context" (Belcak et al., 2026)
In this post
PatchPal, a coding agent harness built for regulated and air-gapped environments, has published a detailed breakdown of the techniques it uses to run reliably on local models with small context windows, as described in blog.wiseprobe.io's report. The post covers six harness-level adjustments and two model-prompt adjustments that make a 16K–32K window go as far as possible when a larger GPU or a frontier model is not an option.
The core problem is that most coding agent harnesses are tuned for frontier models with 200K-token context windows and the ability to self-correct. On local hardware — an RTX A1000 with 6GB of VRAM, a 6GB laptop, or a shared server — both assumptions break down.
On an RTX A1000, Gemma 4 E4B generates around 50 tokens per second in a 32K window; push to a 100K prompt in a 128K window and speed drops below 5 tokens per second, with more than 90 seconds spent just reading the prompt. Several of the harness techniques are adapted from NVIDIA's "You don't need long context" paper (Belcak et al., 2026).
01Mismatch between harness and server window size
The first technique addresses a configuration gap that is easy to overlook. Harnesses typically look up the context limit from the model name, and most local models are listed at 128K or more.
But the server running the model — whether Ollama or vLLM — may be configured with a much smaller window via OLLAMA_CONTEXT_LENGTH or --max-model-len. The harness cannot read that setting, so if it assumes 128K while the server has 32K, compaction never triggers and requests either fail silently or get truncated.
PatchPal requires the window size to be set explicitly via PATCHPAL_CONTEXT_LIMIT so the harness and server are in sync. When PatchPal detects a window of 64K or less, it activates TinyAgent, the agent profile that applies the remaining techniques.
02Cutting fixed overhead before the first message
Tool definitions in a full harness take approximately 5,900 tokens. In a 16K window that is more than a third of the total budget before any conversation is loaded.
TinyAgent enables only five core tools by default: read_file, read_lines, edit_file, write_file, and run_shell, plus optional web tools. That reduces tool definitions to around 1,100 tokens — or about 1,400 with web access enabled — leaving substantially more room for context.
A fresh 32K TinyAgent session with web tools already uses about 23% of the window before the first user message. The largest single contributor is the reply reserve: PatchPal sets aside 16% of the window (5,242 tokens at 32K) for the model's response. Teams running their own harnesses can find similar savings by auditing fixed overhead before optimizing anything else.
Advertisement
Tech Pulse Daily
Get tomorrow's pulse first
Join engineers who read Tech Pulse before stand-up. Free, weekday mornings.
03Per-read caps relative to window size
A single file read can return more text than a small window holds. TinyAgent caps each tool result at approximately 15% of the window, with a minimum floor of 2,000 characters, so the limit scales with the configured window rather than being a fixed number.
When a result is truncated, the harness appends an instruction telling the model exactly where to continue. In a 16K window, for example, it shows the truncation line number and the read_lines call to fetch the next range. This follows the NVIDIA paper's bounded document reader approach: the next-window command is embedded in the current result, so the model does not have to reason about which ranges it has already seen.
04Handoff compaction instead of summary compaction
Standard compaction summarizes older messages and preserves the last few turns verbatim. In a 16K window, the last two turns may represent the entire conversation, so very little space is actually freed. PatchPal uses handoff compaction, as described in the NVIDIA paper, which replaces the conversation with a structured forward-looking note when the context reaches 80% full.
The note contains: the objective and user preferences, established facts (exact paths, commands, and error values), changes made and whether they were verified, test results and dead ends, the remaining plan, and files and line ranges already read. The note is capped at 10% of the window, ensuring compaction always reduces total context size regardless of recent turn length. The model's last reply is preserved so follow-ups like "yes, do that" remain coherent after a compaction.
05Full conversation history saved to disk
Each compaction discards information by design. To make that loss recoverable, TinyAgent saves the full conversation to a file under ~/.patchpal/ before each compaction.
The handoff note includes the path to that file. If the model later needs an exact error message or value it saw earlier, it can grep the saved file instead of redoing the work. The 100 most recent files are retained.
The NVIDIA paper suggested this approach but did not test it. The practical benefit is that teams can compact aggressively — keeping the active window small and the model fast — without permanently losing historical context. The disk file acts as a recoverable archive for precision lookups, while the in-window note carries only what the model needs to continue.
Frequently asked questions
What is TinyAgent in PatchPal?
TinyAgent is PatchPal's agent profile for context windows of 64K or less. It reduces tool definitions from ~5,900 to ~1,100 tokens, caps per-read output at 15% of the window, and uses handoff compaction instead of summary compaction.
Why do local models need a different harness than frontier models?
Local models on modest hardware run best with 16K–32K context windows. Frontier-model defaults assume 200K+ windows and self-correction abilities that small local models lack, so defaults like compaction thresholds and tool counts need adjustment.
What is handoff compaction and how does it differ from summary compaction?
Summary compaction narrates what happened; handoff compaction writes a forward-looking note with the remaining plan, established facts, and dead ends. PatchPal caps the note at 10% of the window so compaction always frees space.
Does PatchPal lose conversation history when it compacts?
No. TinyAgent saves the full conversation to disk under ~/.patchpal/ before each compaction and includes the file path in the handoff note, so the model can grep it for precise values seen earlier.
Sources
Author
Dillip Chowdary
Writes Tech Bytes coverage of AI, engineering, and the tools that actually ship. Editor of Tech Pulse Daily.
Related on Tech Bytes
Advertisement