mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix: remove post-compression file-read history injection (#2226)
Remove the [Files already read — do NOT re-read these] user message that was injected into the conversation after context compression. This message used role='user' for system-generated content, creating a fake user turn that confused models about conversation state and could contribute to task-redo behavior. The file_tools.py read tracker (warn on 3rd consecutive read, block on 4th+) already handles re-read prevention inline without injecting synthetic messages. Closes #2224. Co-authored-by: Test <test@test.com>
This commit is contained in:
parent
214047dee1
commit
4263350c5b
2 changed files with 0 additions and 92 deletions
19
run_agent.py
19
run_agent.py
|
|
@ -4345,25 +4345,6 @@ class AIAgent:
|
|||
if todo_snapshot:
|
||||
compressed.append({"role": "user", "content": todo_snapshot})
|
||||
|
||||
# Preserve file-read history so the model doesn't re-read files
|
||||
# it already examined before compression.
|
||||
try:
|
||||
from tools.file_tools import get_read_files_summary
|
||||
read_files = get_read_files_summary(task_id)
|
||||
if read_files:
|
||||
file_list = "\n".join(
|
||||
f" - {f['path']} ({', '.join(f['regions'])})"
|
||||
for f in read_files
|
||||
)
|
||||
compressed.append({"role": "user", "content": (
|
||||
"[Files already read in this session — do NOT re-read these]\n"
|
||||
f"{file_list}\n"
|
||||
"Use the information from the context summary above. "
|
||||
"Proceed with writing, editing, or responding."
|
||||
)})
|
||||
except Exception:
|
||||
pass # Don't break compression if file tracking fails
|
||||
|
||||
self._invalidate_system_prompt()
|
||||
new_system_prompt = self._build_system_prompt(system_message)
|
||||
self._cached_system_prompt = new_system_prompt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue