| name | context-guard |
| description | Keep input small. Use before any Read or Grep call when context budget tight. |
context-guard
Gemma4:e4b default Ollama window = 4096 tokens. Treat as scarce.
Rules of thumb
- 1 line Python ≈ 12-18 tokens.
- 100 lines ≈ ~1.5k tokens. Reading a 700-line file ≈ 8-10k → blows window.
- Stay below 70% window. If unsure, run
ollama ps → CONTEXT column.
Tool preference (cheapest first)
Grep -n <pattern> <path> with head_limit=20.
Read <path> offset=N limit=40 (slice, never whole file).
Glob for file discovery, not directory listing of contents.
- Whole-file
Read only if file < 150 lines.
When tight (>70% used)
- Stop pulling new files. Finish task with what you have.
- Summarize prior reads in 1-2 sentences, drop the raw text from working memory.
- Defer remaining work as new sub-task on TASK_BOARD.
If task truly needs more
Do NOT silently expand. Propose to user (see GEMMA_WORK_RULES.md §9.3):
- Per-request
options.num_ctx (safe, ephemeral).
- New model variant via
/save or Modelfile (needs user OK).
OLLAMA_CONTEXT_LENGTH env var (needs restart, user OK).
Quote the exact command, state VRAM cost (KV cache ~2x per doubling).