kilocode icon indicating copy to clipboard operation
kilocode copied to clipboard

instructions entries silently deduplicated by basename — a second file sharing a loaded file's basename never reaches context (OpenCode loads both)

Open ServOps117 opened this issue 2 weeks ago • 3 comments

What: entries in the instructions array (project kilo.json / global ~/.config/kilo/kilo.json) are deduplicated by basename: an entry whose file name matches an already-loaded instruction file is silently dropped — no warning, no log line. Upstream OpenCode (which this CLI forked from) loads both.

Measured on @kilocode/[email protected], macOS, 2026-11-14:

  1. Global instructions already loads …/.agents/memory/MEMORY.md.
  2. Project instructions adds a different path that also ends in MEMORY.md (a second project memory index, real file, different directory).
  3. kilo debug config resolves the entry fine. A run asked to list every received MEMORY.md names exactly one and quotes the global one's content — the project-scope file never reaches the prompt.
  4. Rename the same file to any other basename (e.g. OMNIX-MEMORY-INDEX.md) → it loads and quotes verbatim. Different real paths, same basename → dropped, so the dedup keys on basename.

Also observed on 7.8.27 (all silent): symlinked instruction files are skipped (regular files load); a missing/broken entry is skipped gracefully. The silence is what makes the dedup invisible — context loss with a green debug output.

History: on a pre-7.8 build (2026-09-15) a differently-named instruction file hung the run entirely (provider request never returned, 4/4 reproductions, project and global scope). That hang is fixed in 7.8.27 — the same repro now answers in 25–55 s. Only the basename dedup remains.

Ask: either load same-basename entries (match OpenCode's behaviour) or log a loud warning whenever an instructions entry is dropped or skipped, so silent context loss is diagnosable from kilo debug.

ServOps117 avatar Nov 14 '26 02:11 ServOps117

I'd like to take this one. I couldn't reproduce basename dedup on 7.8.27 or current main. Two MEMORY.md files at different paths both load. What I do see is that a project kilo.json entry pointing outside the project root is dropped silently, whatever its name. That's an intentional security block, but it gives no warning. Was your second MEMORY.md outside the project directory? I have a PR ready that logs a warning whenever an instruction file is skipped.

Beehtrix avatar Nov 16 '26 02:11 Beehtrix

Yes — our second MEMORY.md lives under ~/.claude/projects/<project>/memory/, outside the project root. Your explanation matches a fresh measurement on our side: a file named MEMORY.md placed INSIDE the project root (same basename as the loaded global one) loads fine — the run quoted both verbatim. So the drop we reported was the outside-root block, not basename dedup; our original title was wrong and our docs are now corrected. The silent skip is exactly what made this hard to diagnose — thanks for the warning PRs.

ServOps117 avatar Nov 23 '26 00:11 ServOps117

Thanks for confirming. Since the drop was the outside-root block, #16203 (warning when an instruction file is skipped) covers this, so I've switched it to close this issue on merge. Would you mind updating the issue title to something like "instruction file outside the project root is skipped silently" so it matches?

Beehtrix avatar Nov 23 '26 03:11 Beehtrix