fraud agent loop detected: re-flagging the same transaction
Breaks fraud-agent re-flag loops with a visited transaction set, a flag-state machine, and idempotent flag actions. Use when the agent flags the same transaction twice or more in one run. Not for rule engines firing on genuinely new events or queues growing from real volume.
TL;DR
The agent re-flags the same transaction because it has no memory of what it already flagged. Give it a visited set keyed on transaction id plus rule version, model flagging as a one-way state transition, and make the flag write idempotent. One pass should produce exactly one flag event.
fraud agent loop detected: re-flagging the same transactionUse this when
- Logs show the same transaction id flagged two or more times in one run.
- Flag counts grow faster than the number of distinct transactions scored.
- The loop clears on restart and then starts again from scratch.
Not for this skill when
- A rule engine fires on genuinely new transactions. That is rule tuning, not a loop.
- The queue grows because transaction volume grew. Check ingress before blaming the agent.
Steps
- Confirm the loop: search run logs for repeated transaction ids inside one run id. Verify: one id appears three or more times under the same rule version.
- Add a visited set: before scoring, skip any transaction whose id plus rule version is already in the set. Verify: re-running the batch flags zero already-seen transactions.
- Model flag state as a one-way state machine: unflagged to flagged to escalated or closed, with no edge back. Verify: a flagged transaction can only move forward.
- Make the flag action idempotent with a key built from transaction id and rule version; the system returns the existing flag on duplicates. Verify: a double POST returns the same flag id with no new row.
- Cap evaluations per transaction per run and raise one alert when the cap is hit. Verify: a run that hits the cap raises the alert exactly once and moves on.
Variant phrasings
fraud agent keeps flagging the same transaction
Same loop, looser phrasing.
agent flags transaction twice
Duplicate-flag symptom search.
reflagging loop in fraud review
Loop-focused phrasing.
Compatibility: any flagging backend that accepts idempotency keys on its flag write path; the visited set can be in-memory or shared.
Why it happens
The evaluation loop treats every cycle as a fresh look with no memory. Without a visited set, check and flag both run unconditionally, so the second cycle repeats the first. Idempotency on the write side catches it at the API even when the loop logic misses it.
Edge cases / pitfalls
- Rule version changes are legitimate re-scores: include the version in the visited key so a new rule still gets one clean pass.
- Transactions updated mid-run should be re-scored: key on transaction id plus last-updated timestamp so genuine changes are not skipped.
- Multi-agent setups need a shared visited set, and the alerting side needs its own dedupe window in case a loop escapes the scorer.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_01wAota1bbLGnCacg6QtAA