context constipation

one hundred nine compactions with local LLMs

Having a local large language model on an old gaming rig is sweet. Even sweeter is using those models with pi. With Qwen3.5 in hand, I wanted to update my trip planning website very simply.

This folder has my trip to Madrid. Update the page where necessary to change the Friday DL0126 flight to a Saturday flight that is IB 5962 from Bilbao to Londonn Gatwick. Some other items will shuffle around.

Three or four user turns later, my agent blew itself out. Here’s why, with the full trajectory available here.

The initial task led to an errored edit, which is expected as I’m deadling with a less powerful LLM. The user’s next asks are relatively well-scoped too:

  • move the Madrid to London flight
  • replace the flight with Bilbao to London
  • organize the rest of the itinerary accordingly.

A reasonable strategy is to read the file, make the edit, check by reading the file, make any edit, check, edit, … and that’s exactly what the agent does.

Time Role thinkingSignature Message ID First words Input context
00:17:04 user — 02732588 “This folder has my trip to Madrid. Update the page where necessary…” —
00:17:14 assistant reasoning f4ee2e56 “I need to read the existing trip file first…” 2,262
00:17:55 assistant reasoning 762be443 “Since I can’t verify the IB5962 flight details externally…” 19
00:17:57 assistant reasoning b3c316d7 “The edit was successful, but the file structure needs to be validated…” 2,121
00:20:07 compaction — e1fad59b “No prior history. … Original Request…” 31,197 before compaction
00:20:50 user — 4fe31f09 “Error: error building site…” —
00:21:00 assistant reasoning efb653d8 “There’s a YAML syntax error at line 135…” 23,282
00:26:20 user — caa2b3d8 “Let’s now change Thursday morning to travel to San Sebastián…” —
00:27:57 compaction — 26037e2f “## Goal — Update Madrid trip page content…” 28,410 before compaction
00:31:13 user — ecfdc425 “The drive to San Sebastian is wrong, it shuld be on Thursday…” —
00:31:24 assistant reasoning fbd136c4 “I need to fix the timeline correctly…” 26,491
After this agent reasoning — repeated reads, edits, validations and compactions 107 more compactions
End 109 compactions total

At first the local LLM seemed OK, even noting lack of flight verification. However, verifying the file structure hit 31000 tokens, at the edge of 32768. OK sure, compact. But then there’s an error building the site. Fine, read the file … already 23k tokens. OK change the flight and .. compaction. OK compaction done, and read the file to edit the … compaction.

I created a perpetual compaction machine. Every time the model tried to edit the page by

  • reading the page
  • filling the context
  • triggering a compaction
  • summarizing the context
  • and then trying to edit the page

Eventually the infinite loop stops on a hallucinated error that triggers a fun failure mode.

The file is still corrupted with mojibake patterns, so I need to use write to completely recreate it with clean UTF-8 encoding.

Still corrupted. Let me use write to completely regenerate with proper encoding:

Yep, the LLM stopped at its colon. Total tokens used? 32678. Actual stop reason: “length”.

Reading the trajectory does expose the root cause of reading the whole markdown file. To fix, I used Gemini 3.8 Flash to break the website up from one index.md file into the following.

.:
calendar  index.md  logistics.yaml  research.yaml  wedding.yaml

./calendar:
2026-10-06.yaml  2026-10-09.yaml  2026-10-12.yaml  2026-10-15.yaml  2026-10-18.yaml
2026-10-07.yaml  2026-10-10.yaml  2026-10-13.yaml  2026-10-16.yaml  2026-10-19.yaml
2026-10-08.yaml  2026-10-11.yaml  2026-10-14.yaml  2026-10-17.yaml

A targeted edit using Qwen3.5 then succeeded because the agent only had to read a couple of small YAML files.

So a lesson for those using local large language models that are quite small: break your artifacts up too. If you have a large lump to pass, you will constipate your little LLM.

Published by using 620 words.