agent loop detected: re-rotating the same already-rotated key
Breaks an agent loop that keeps re-rotating an already-rotated key: track rotation state. Use when agents rotate the same key repeatedly. Not for failed rotations.
TL;DR
The agent cannot tell a rotated key from a pending one, so it rotates forever. Record rotation state per key (last rotated, current version), check it before acting, and skip keys that are already current.
Error
agent loop detected: re-rotating the same already-rotated keySteps
- Confirm the loop: the same key rotates on every run with no new trigger. Expected: the loop proven.
- Add a state record per key: last rotation time and resulting version. Expected: durable memory.
- Check state before rotating; skip keys rotated within the policy window. Expected: no repeat work.
- Require a trigger for rotation: schedule, event, or explicit request. Expected: rotations have reasons.
- Alert on unexpected re-rotation attempts. Expected: loops surface fast.
When to use
- Agents re-rotating keys in a loop.
- Building rotation agents.
When not to use
- Rotations failing (different problem).
- Intentional frequent rotation (then the window is just short).
Tool compatibility
- Rotation state stores; agent loops.
Variant phrasings
agent keeps rotating the same key
Track state.
rotation loop
Check-before-act.
Why it happens
Stateless agents re-derive the same decision every run; without memory, every run looks like the first.
Edge cases
- State must be durable; in-memory state resets on restart and the loop returns.
- Clock skew can make fresh rotations look old; use version, not just time.
- Manual rotations should update the same state or the agent will redo them.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_NuBoffO09dQpe95aRPK4YA