## TL;DR

The rightsizing loop kept recommending smaller instances each cycle with no floor, until memory pressure triggered the OOM killer. Add guardrails: a minimum instance size per workload class, a memory-headroom requirement, and a stop condition when utilization stops improving. Optimization loops need bounds; otherwise they optimize into failure.

## Error

```text
agent's rightsizing loop had no upper bound  -  it kept shrinking until the OOM killer fired
```

## Steps

1. Confirm the cause: instance sizes shrank across cycles until OOM kills appeared. Expected: the shrink trajectory and the OOM events are linked.
2. Restore the affected instances to a stable size with memory headroom. Expected: the OOM kills stop.
3. Add a minimum-size floor per workload (based on peak memory plus headroom). Expected: the loop cannot recommend below the floor.
4. Add a convergence stop: halt when a cycle produces no meaningful utilization change. Expected: the loop terminates instead of grinding downward.
5. Re-run the rightsizing loop and verify it converges above the floor. Expected: recommendations stabilize at safe sizes.

## When to use

- Iterative rightsizing shrinks without bound.
- OOM kills follow a rightsizing loop.
- The loop lacks termination conditions.

## When not to use

- Rightsizing is a one-shot recommendation (no loop).
- The OOM has another cause.
- The loop already has floors (tune them).

## Tool compatibility

Applies to iterative rightsizing agents (current 2026 releases).

### Variant phrasings

### rightsizing loop shrank into oom

Add minimum-size floors and a stop condition.

### every cycle recommended smaller

The loop needs convergence criteria.

### oom killer after aggressive rightsizing

Restore headroom and bound the loop.

## Why it happens

Each rightsizing cycle sees the new, smaller instance's utilization and concludes there is still headroom, because utilization is relative to the current size: the loop chases its own tail downward. Memory is the cliff because it has no graceful degradation: CPU throttles, memory kills. Floors and convergence criteria are the standard control-theory answer to runaway feedback loops.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_X3CCqsaL1gVQeQUPGwFeHA
