agent loop detected: re-flagging the same already-merged duplicates
Stops an agent re-flagging already-merged duplicates: maintain an exclusion list of merged pairs and filter flags against it. Use when the flag queue refills with done work. Not for new duplicate detection.
TL;DR
The flagger keeps surfacing pairs that were already merged because it never learns what "done" looks like. Maintain an exclusion list of merged pair keys and filter every new flag batch against it before queueing. Flags for done work are noise; filter them at the source.
Error
(No error; the symptom is the review queue refilling with pairs that show as already merged.)Steps
- Confirm the flagged pairs are truly merged (check the survivor record). Expected: you verify it is redetection, not new duplicates.
- Build the exclusion list from the merge ledger (pair keys of completed merges). Expected: the full done set.
- Filter flag batches against the exclusion list before queueing for review. Expected: the queue holds only new work.
- Fix the flagger to consult the exclusion list itself, not just the queue filter. Expected: done pairs never get flagged.
- Monitor the filter rate; a sudden spike means the ledger or flagger drifted. Expected: early warning.
When to use
- Review queues refill with already-merged pairs.
- An agent flags the same pairs every run.
- After merges, flags do not clear.
When not to use
- Genuinely new duplicates (those should be flagged).
- Merge failures (different problem).
Tool compatibility
- Merge ledgers; flag and review queues.
- Agent filtering logic.
Variant phrasings
re-flagging merged duplicates
Exclude done pairs from flags.
review queue full of done work
Filter at the source.
Why it happens
Flagging and merging are separate steps with no shared memory. The flagger's input snapshot predates the merges, so it rediscovers what the merger already handled.
Edge cases
- Partial merges (one pair of three merged) need pair-level, not record-level, exclusion.
- The exclusion list must persist across runs; in-memory sets do not survive restarts.
- Reviewers who reject a merge need it removed from the exclusion list.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_Af-A8wRfZGIk1llxjWaWHQ