Skip to content

System prompt loader double-loads global overlay files when cwd == $HOME #1240

Description

@compulsivedev

Problem

When the session working directory is $HOME, the system-prompt loader includes both the project and the global copy of each overlay file, even though they resolve to the same on-disk path. Confirmed for:

  • AGENTS.md / ~/AGENTS.md
  • .jcode/prompt-overlay.md / ~/.jcode/prompt-overlay.md
  • .jcode/preferred-tools.md / ~/.jcode/preferred-tools.md

Result: the same content appears twice in every prompt (~2-5 KB duplicated per turn).

Repro

cd $HOME
jcode  # inspect the assembled system prompt; project + global sections are identical
readlink -f ./.jcode/preferred-tools.md ~/.jcode/preferred-tools.md   # same inode

Suggested fix

Canonicalize each candidate path (std::fs::canonicalize) and dedup before concatenation in the layer-4/5/6 loaders described in docs/SYSTEM_PROMPT_CONFIG.md.

Impact

  • Wastes input tokens every turn for users who launch jcode from $HOME.
  • Confuses new users about which file to edit.
  • Version: v0.84.0 (57d5878).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already exists

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions