Home / use case

Cutting a local Qwen coding agent's wait on a 16GB Mac with a memory hook

At a glance
Hardware
16GB MacBook (Apple M5)
Models & engines
qwen3.5:9b through Ollama (64k context)
bge-m3 embeddings on Ollama
Key gotcha
On 40 random real prompts, the attached text was helpful for 8, neutral for 23 and possibly misleading for 9, mostly where an old fact sits next to its update

What they built

JustJinoIT runs a coding agent on a local 9B model and found that the memory index it loads into every request, a long list of links to 78 memory files, made each request slow. The local model read about 11k tokens before the question and then still had to open files to find the actual fact.

He replaced it with a UserPromptSubmit hook in plain python3 that splits memory files into line chunks, scores them against the prompt with local bge-m3 embeddings on Ollama plus BM25 keyword search, merges the two rankings with reciprocal rank fusion, and attaches only the best chunks with their dates.

He packaged the setup as claude-local-kit, which pulls the models, runs the agent on the local model in the current folder, and leaves his normal settings alone.

Setup

  • 16GB MacBook (Apple M5)
  • qwen3.5:9b through Ollama (64k context)
  • bge-m3 embeddings on Ollama
  • Hook written in plain python3, no packages

How it works

  1. Attaches the best chunks with neighboring lines, up to 2,400 characters, each with the date it was written
  2. Attaches nothing for short replies like "ok do it" (fewer than 3 search terms)
  3. If Ollama is down it falls back to keywords, and if that fails it attaches nothing, so it never blocks the agent
  4. Old and new setups ran each question back to back in alternating order, with questions written by a separate agent and graded blind by two judge models

Results & numbers

  • Median first-request input tokens fell from 11,450 to 8,030 over 50 pairs
  • Median time to finish one question fell from 90.4s to 56.4s, and the new setup was faster in 42 of 50 pairs
  • Memory questions answered correctly rose from 20 to 37 of 45, and made-up answers fell from 11 to 3
  • The expected answer appeared in the attached text for 36 of 45 held-out questions, against 17 for his earlier keyword-only hook

Gotchas

  • On 40 random real prompts, the attached text was helpful for 8, neutral for 23 and possibly misleading for 9, mostly where an old fact sits next to its update
  • A rule to skip prompts unrelated to memory worked on one question set and failed on the next, so it was removed as overfitting
  • Ollama unloads a model after 5 minutes idle by default and the next request stalls while it reloads; he sets OLLAMA_KEEP_ALIVE to 4h
  • Closing the lid once put the Mac to sleep mid-run and spoiled 3 timings, which he reran with the charger in and the lid open
“when a fact changes, edit the old line instead of appending a new one.”— JustJinoIT

Do it yourself

  1. Clone JustJinoIT/claude-local-kit on a Mac with Ollama and python3
  2. Run ./install.sh to pull qwen3.5:9b (64k context) and bge-m3
  3. Run claude-local in your project folder to use the local model
  4. Set OLLAMA_KEEP_ALIVE so the model stays loaded, and edit old memory lines instead of appending new ones
git clone https://github.com/JustJinoIT/claude-local-kit && cd claude-local-kit
./install.sh
launchctl setenv OLLAMA_KEEP_ALIVE 4h   # then restart Ollama
Source: DEV Community (JustJinoIT) · Published 2026-12-01 · Added 2026-12-02. This write-up summarizes the original source; see it for full details.

Similar setups

PatchPal TinyAgent: a coding agent on a 4B model and a 6GB laptop GPU

WiseProbe adapted its PatchPal coding agent to run Gemma 4 E4B or Qwen3.5 4B through Ollama on a 6GB RTX A1000, using handoff-note compaction and capped file reads to work inside a 16K or 32K window.

WiseProbe Blog · 2026-11-25

Company Brain: a private consultancy RAG on a 16 GB MacBook Air M4 with Ollama and Open WebUI

Ángeles Hernández Acosta’s KeepCoding final project runs Qwen3.5-4B via Ollama on a 16 GB MacBook Air M4, answers only from local documents with citations, and scored 16/22 on a locked final exam run on 6 November 2026.

GitHub · 2026-11-06

Testing a reasoning-effort fix on a local Qwen 27B for build-fix tasks

A developer ran a pre-registered overnight test on a local Qwen3.8 27B in Ollama to see if dropping a hidden reasoning-effort paragraph from the prompt helps it patch failing builds; the run was valid but scored 4/10 against a 5/10 bar.

DEV Community (hexisteme) · 2026-11-25

Hearth: a household assistant on Ollama, and proving nothing leaves the house

Hearth answers family questions from manuals and papers with citations, handles voice, notes and reminders, and runs on one home computer; its builders tested small models, prompt injection, and three ways of proving no data leaves.

DEV Community (WeekendAiProjects) · 2026-11-23