The thing that makes agentic harnesses feel like magic is also the thing that makes them impossible to debug: you never see what actually went into the prompt. The model did something weird, and you are left guessing whether it was the model, your instructions, or the pile of files the harness silently stuffed into the context window.
Phase 06 of kodr is my attempt to kill that mystery. The rule: context is just an input, so treat it like one. Build it deterministically, and let me look at it before it gets sent.
What the packer does
buildWorkspaceContext walks the workspace and produces the file context for a run. Nothing clever - and that is the point:
- Deterministic order. Files are walked and sorted, so the same workspace produces the same context every time. No set-iteration roulette.
- Ignore the noise.
.git,.kodr,node_modules,dist,build,coverage- skipped. Binary-looking files filtered out. - Byte budgets. Per-file and total caps (20KB / 80KB by default), so one giant lockfile cannot eat the whole window. Truncated files are flagged as truncated.
Then the bit I like most: AGENTS.md gets pulled out of the regular file pile and lifted into the system prompt as repository instructions. Your repo’s rules are not just another file excerpt competing for attention - they are framed as instructions, separately from the code.
Make it inspectable
Two flags, --show-files and --show-context, let me dump exactly what the packer decided before any model call. And kodr run now writes context.md next to the other artifacts - prompt.md, response.md, summary.json, raw-response.json. So after a run goes sideways, the input is sitting right there on disk. No guessing.
This is the same instinct as phase 05: the value is in being able to point at the exact thing that broke.
The failure I kept
Naturally I wrote a bug. My first test asserted that every run produced a “workspace context” section - even when the temp workspace had no files in it. That coupled the base system prompt to non-empty file context, which is exactly backwards: an empty workspace should still give you the base kodr system prompt, just without file excerpts.
The fix was to split the assertions: prove the base system prompt stands on its own in an empty workspace, and cover AGENTS.md and file context in their own dedicated tests. Recorded in failures.jsonl, because the whole point of this repo is that the mistakes are the lesson.
Links:
- Phase doc: phases/06-context-packing.md
- Kodr post: blog/06-context-packing.md
- The packer: src/context-packer.mjs