Cap the number of steps an agent loop can take
==================================================
const { runBounded } = require("./bounded-loop");
const result = await runBounded(step, isDone, { maxSteps: 10, initialState: ... });
// result.done is false if it hit maxSteps without finishing -- never loops forever

See demo.js for a loop that finishes normally and one that never satisfies its own stopping
condition (simulating a buggy agent), both handled safely.
