Budgets and Limits for Agent Work

Lesson 4 of 4

Set the Limit Before the Work

Estimated time: 10 minutes

Set the limit before the work, not after

A budget or a quota only changes behaviour if it is consulted before work is admitted. Once the work is running, the limit is a report rather than a control.

Decide at the door

The moment to apply a limit is the moment work asks to enter. Admitting first and trimming later means the pool was already spent and another caller already paid for it.

Make the refusal useful

A refusal that says only no forces the caller to guess. Say which limit was reached and when room is next expected, so the caller can wait instead of retrying into the same wall.

def admit(work, limit):
    if work.size > limit.remaining:
        return "held"
    return "run"

Keep one limit per kind of resource

A single number that covers spending, sessions and storage at once is impossible to reason about. Separate the limits so a run that is heavy in one way is not blocked by an unrelated count.