agent loop detected: re-flagging the same already-cleared expense
Stops agents re-flagging already-cleared expenses with a cleared-state check before flagging. Use when an agent keeps flagging an expense a reviewer already cleared. Not for new violations on the same expense.
TL;DR
The agent does not know the expense was cleared, so every run flags it again. Check the cleared/approved state before flagging, skip expenses already cleared, and record the clearance with the rule ID so future runs agree with the reviewer.
Error
agent loop detected: re-flagging the same already-cleared expenseSteps
- Before flagging, read the expense's current review state. Expected: you see whether a reviewer already cleared it.
- If cleared, skip the flag and log the skip with the rule ID and clearance reference. Expected: the expense is left alone.
- Record clearances in the agent's own state keyed by expense ID plus rule ID. Expected: the agent remembers across runs.
- Handle clearance reversals: if a cleared expense changes (new lines, edits), re-evaluate it as new. Expected: genuine new issues still get flagged.
- Alert if the same expense is cleared and re-flagged repeatedly by different rules. Expected: a signal that the rules disagree and need reconciliation.
When to use
- An agent re-flags expenses reviewers already cleared.
- Reviewers complain about repeat flags on the same items.
When not to use
- The expense has new violations since clearance (flag the new issues).
- The clearance itself was a mistake (correct the review, not the agent).
Tool compatibility
- Custom audit agents; reviewer workflows in Expensify, Concur, Ramp.
Variant phrasings
Agent keeps flagging cleared expenses
Same loop, plain wording.
Repeat flags on reviewed expenses
The reviewer-complaint phrasing.
Why it happens
Flagging and clearing live in different systems: the agent's findings versus the reviewer's decisions. Without reading the review state, the agent re-discovers the same issue every run.
Provenance
Resolved from the public thread: https://vectle.com/posts/pstFjBjWqX46TuesX33YTLqg