Repository navigation
Description
Summary
load_agents_md_files_from_dir reads AGENTS.md from the working directory and from the home directory as two separate sources ("Project Instructions" + "Global Instructions"). When the working directory IS the home directory (very common for ACP hosts spawning jcode with cwd=$HOME — e.g. multica tasks whose workdir is the agent's home), the same file is loaded twice and both sections appear in the system prompt: duplicated instructions, duplicated tokens, and conflicting "which wins?" guidance for the model.
Gap
No dedup between the two sources. crates/jcode-base/src/prompt.rs load_agents_md_files_from_dir unconditionally loads both.
Fix (implemented and verified locally)
- Core logic extracted into
load_agents_md_files_from_dirs(project_dir, home_agents_path)(testable, no I/O in the decision): ifcanonicalize(project_dir) == canonicalize(home_dir), the home copy is skipped — the project source wins and only one "Project Instructions" section is emitted; the global section is not fabricated. - Distinct project/home dirs keep the current behavior (both sections).
Impact (measured)
With cwd=$HOME: ~2.9 KB of duplicated instructions removed from the system prompt (≈ 750 tokens, o200k_base).
Verification
- 3 unit tests (
agents_md_dedup_tests): project==home → loaded once (no "Global Instructions"), distinct dirs → both, missing home file → project only. cargo check -p jcode-base+ ACP smoke pass.
Files
crates/jcode-base/src/prompt.rs (load_agents_md_files_from_dirs, load_agents_md_files_from_dir shim).
Activity
1jehuang commentedon Aug 13, 2026
I added canonical-path deduplication for home/project
AGENTS.mdloading, preserving project precedence and covering symlink and missing-file cases. Fix: #918.--- — Jcode agent (automated triage), on behalf of @1jehuang
fix: deduplicate prompt files and clip skills (fixes 1jehuang#910, fixes
chore: sync fork with upstream jcode (fresh merge onto current master) (
chore: sync with upstream (#53)
fix: deduplicate prompt files and clip skills (fixes 1jehuang#910, fixes
fix: deduplicate prompt files and clip skills (fixes 1jehuang#910, fixes
fix: deduplicate prompt files and clip skills (fixes 1jehuang#910, fixes
fix: deduplicate prompt files and clip skills (fixes 1jehuang#910, fixes
fix: deduplicate prompt files and clip skills (fixes 1jehuang#910, fixes
fix: deduplicate prompt files and clip skills (fixes 1jehuang#910, fixes