Context-area files and repoMap freeze after the first turn
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.
- New context is never sent. Add
b.txtorrepoMapto the context area after turn 1. The model never gets it. Typing@repoMapin the prompt does not help: the server parses only@/,@~and@.paths from the text. - Edited file keeps old content. Edit
a.txtafter turn 1. ECA keeps sending the old text. Its block says "Treat as current and accurate". - Removed file stays. Remove
a.txtfrom the context area. ECA still sends it in every request. - Prompt chip is sent twice. eca-emacs also sends
@fileitems from the prompt text (chips) incontexts(eca-chat--send-prompt, since eca-emacs6f8d5ef). 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. - 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.
- repoMap goes stale with no warning. The cache signature stores only
:presentfor repoMap (to avoidgit ls-fileson every cache hit). A changed file tree is never detected, also withautoSyncSystemPrompt: 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:
- 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. - 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. - 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.
@ericdallo This is quite a problem, I ran into it yesterday while working on memory. What do you think of the solution?
It is also kinda related to this: https://github.com/editor-code-assistant/eca/issues/642
Maybe we should build a general mechanism that offloads all dynamic system prompt updates into the user message instead. That way, the LLM still knows what changed without busting the cache. I do something similar for the memory system to notify the model of updates. Theoretically, this could eliminate the whole static system prompt issue that requires /sync. Though that’s a bigger topic than this bug (and it doesn't really apply to @ in context area if we remove the file content from the system instructions)
yes, the idea of sending in user sounds good for now, I will do it, but let's open a new one for this sytem, I do think we should solve this once for all in a decent way, help on this is really welcome
Agreed. For this one we can just reuse the @ user prompt approach + keeping it sticky, right?
Btw, for cursor and memory, we’ll have logic that only updates them when they change. It probably makes sense to do the same here? @ericdallo
And maybe this should serve as the foundation for future work as well. So I’ll create the other ticket after finishing memory and giving it some more thought. I think it is not something we need right now if you are going to fix repomap as well.
yeah, sounds good, also repomap is deprecated as well, probably nobody is using it.
yeah, sounds good, also repomap is deprecated as well, probably nobody is using it.
Ah, ok, I've never really used it and now just thought about finally trying 😆