Context-area files and repoMap freeze after the first turn

Aperta
#683 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
clojure

Direzione di ricerca

Start with eca.features.chat/prompt and the eca-chat--send-prompt entry point named in the issue; use the described mock-LLM test to trace how context-area files and repoMap reach each turn. Check the prompt-cache signature and the context-change notice as well. Done means current contexts are sent as proposed without duplicating prompt chips, pinned instructions remain pinned, and docs/features.md is corrected.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Summary

The context area is the line above the prompt. The editor sends its items in contexts.
ECA renders :file and :repoMap contexts into the system prompt.
ECA pins this prompt (keeps it fixed for the whole chat) unless chat.autoSyncSystemPrompt is true. The default is false.
So after turn 1, the model does not see changes to these contexts.

Expected: the model sees the current context area on every turn.

Bugs

Reproduced on master (3cf9b05) with a test that calls eca.features.chat/prompt and a mock LLM. Default config, unless stated.

  1. New context is never sent. Add b.txt or repoMap to the context area after turn 1. The model never gets it. Typing @repoMap in the prompt does not help: the server parses only @/, @~ and @. paths from the text.
  2. Edited file keeps old content. Edit a.txt after turn 1. ECA keeps sending the old text. Its block says "Treat as current and accurate".
  3. Removed file stays. Remove a.txt from the context area. ECA still sends it in every request.
  4. Prompt chip is sent twice. eca-emacs also sends @file items from the prompt text (chips) in contexts (eca-chat--send-prompt, since eca-emacs 6f8d5ef). The server cannot tell them from context-area items. The model gets the file in the user message and in the system prompt. The system prompt copy stays for the rest of the chat. Other clients: not checked.
  5. Notice is vague and repeats. ECA shows "System prompt changed (contexts), keeping current chat system prompt...". It does not say that the attached file is not sent. With bug 4 it shows again and again, because chips come and go.
  6. repoMap goes stale with no warning. The cache signature stores only :present for repoMap (to avoid git ls-files on every cache hit). A changed file tree is never detected, also with autoSyncSystemPrompt: true. The agent creates and renames files, so the map is soon wrong.

Root cause

:file and :repoMap are in static-prompt-context-types. This is the same pinned block as AGENTS.md and the rules. Pinning is right for instructions. It is wrong for data that changes.

Workaround

Set chat.autoSyncSystemPrompt: true. It fixes bugs 1 to 3. But each change then breaks the prompt cache (the provider's stored copy of the processed prompt). With bug 4, each prompt chip breaks it twice: when the chip appears, and on the next turn. Bugs 4 and 6 stay. For bug 6, /sync-system-prompt refreshes the map by hand.

Proposal

Send :file and :repoMap in the user message, after the user text. The cursor already works this way (#464).

  • Send the content once, when it is new.
  • If it changes later, send one line. The model reads it again with its tools.
  • If the user removes it, send nothing.
  • Skip a path that the prompt text already expands with @path. Prompt @ stays as it is.
  • Keep AGENTS.md and the rules in the pinned system prompt.
  • Fix the text "one-time only context" in docs/features.md.

NOTE: It might make sense to get rid of '@' in the context area completely. But I think that these are good reasons to keep it:

  1. It stays attached. The client sends the context-area list on every message until you remove an item. A prompt @ works for one message only.
  2. It can stay current (after the fix). ECA sends a short "file changed" line. A prompt @ is a snapshot (a copy from one moment). To refresh it, you mention the file again, and the full file enters the history again. Today this point is the bug.
  3. It survives /compact (the command that summarizes old messages). Prompt @ text is gone after /compact, and only the summary stays. I know this from the code, not from a run.
Lingua principale
Clojure
Stelle
1k
Fork
82
Merge medio
1g 21h
PR unite (30g)
25

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di editor-code-assistant/eca

Tutte le issue di editor-code-assistant/eca

Issue simili

Altre issue su Clojure

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.