Class SpendCap

java.lang.Object
ai.redouble.examples.cap.SpendCap

public class SpendCap extends Object
A dollar cap on a workflow: this piece of work may spend one cent, and once one cent is committed, no new model work starts. The order agent answers the same question again and again inside one capped workflow until the cap refuses a run.

CostLedger keeps the accounts: subscribed to the dispatcher's events, it prices every model call a finished job made from the catalog, per workflow, per model and per call. Registered as the spend gate, it is also the check every job passes before it starts. The check works on reservations - the input of the job's model calls plus the output its declaration allows, priced - and a job is refused when the workflow's spend, plus what its running jobs have reserved, plus this job's reservation would pass the cap. Counting what is in flight is what keeps a burst of jobs from slipping past the cap before the first is priced. The refused job never sends a request, and nothing already running is stopped.

A cap is in one currency and nothing is ever converted: a job whose model is priced in a currency the workflow has no cap for is refused, and so is one whose model has no price at all - a spend nobody can state cannot be admitted.

Since:
0.1 (2026-09-27)
Author:
Andrey Santrosyan
  • Constructor Details

    • SpendCap

      public SpendCap()
  • Method Details