fix: escalate read/search blocking, track search loops, filter completed todos

- Block file reads after 3+ re-reads of same region (no content returned)
- Track search_files calls and block repeated identical searches
- Filter completed/cancelled todos from post-compression injection
  to prevent agent from re-doing finished work
- Add 10 new tests covering all three fixes
This commit is contained in:
0xbyt4 2026-03-08 23:01:21 +03:00
parent 9eee529a7f
commit e2fe1373f3
4 changed files with 167 additions and 9 deletions

View file

@ -105,8 +105,17 @@ class TodoStore:
"cancelled": "[~]",
}
lines = ["[Your task list was preserved across context compression]"]
for item in self._items:
# Only inject pending/in_progress items — completed/cancelled ones
# cause the model to re-do finished work after compression.
active_items = [
item for item in self._items
if item["status"] in ("pending", "in_progress")
]
if not active_items:
return None
lines = ["[Your active task list was preserved across context compression]"]
for item in active_items:
marker = markers.get(item["status"], "[?]")
lines.append(f"- {marker} {item['id']}. {item['content']} ({item['status']})")