Skip to content

Limits of a run#

A run can stop for reasons other than finishing the work: it runs out of time, tokens or money, a script uses too much memory, or a required file is missing. This page explains each limit you can set, which limits adda enforces and which only send reminders, and what you see in your run folder when one is reached. Read it before your first long run, so a stop doesn't surprise you.

Terms used on this page#

  • Agent: a language model with a set of tools and instructions. adda runs several agents. Each agent is one node of the run: a named member of the team, such as strategizer or critic.
  • Token: a piece of text, about three quarters of a word on average. Models read and write text in tokens, and providers bill by them.
  • Delegation: one task that a node gives to another node, such as "fit a surrogate to these 60 rows". It has an id like D003 and runs in the background while the delegating node keeps working.
  • Evaluation: one call to your study's evaluator, the code that measures a design. adda records every evaluation in the run's store.
  • Wind-down: the last phase of a run that has hit a budget. adda starts no new work, each node saves what it has, and the run closes.

Enforced limits and reminders#

Some limits are enforced: at the limit, adda refuses new work or stops it. Others are reminders: the agents are told how much is left, and nothing stops. The time and token budgets share one schedule, driven by whichever of the two is further along:

  • From 75%: every agent gets a budget notice, then another every 5%.
  • From 90%: no new delegations start. Delegations that already run continue.
  • At 100%: the wind-down begins. Each node saves what exists, the node that holds the job writes the deliverable and calls Done, and the run closes after one reproduction check and one review.

In short: time, tokens, money, memory and required files are enforced; the evaluation budget is only a reminder.

You can change these fractions with the budget_warn_from, delegation_cutoff_at and wind_down_at keys in the Runtime reference.

Limit Unit Type At the limit
budget Seconds (3600), or "HH:MM:SS" in config.yaml Enforced The schedule in the preceding list. The clock counts working time: time the run spends paused for usage limits doesn't count.
token_budget Generated (output) tokens, summed over every agent Enforced The same schedule as budget. Input tokens don't count.
budget_usd Dollars (USD) Enforced When spend reaches the limit, the run winds down at once: each agent writes its notes and the run closes. If the wind-down takes too long, the run halts. To continue, raise the limit and resume the run. It has no effect on a backend that reports no cost per call, such as Ollama.
eval_budget Evaluations Reminder Agents get a notice from 75%, then every 5%, with the evaluations left. adda never refuses an evaluation and never stops the run for this budget.
mem_cap Bytes, or a size such as "8G" or "512M" Enforced, per delegation adda checks memory every 5 seconds. A delegation whose processes use more than the cap is killed, and the delegating agent is told why. The rest of the run continues.
required_deliverables File names in the study folder Enforced Done refuses to close the run while a listed file is missing. During the wind-down, Done doesn't refuse: the run closes and records which files are missing.

When you don't set mem_cap, the cap is the memory of your Slurm job if the run is on a cluster, and 4 GiB otherwise. If any agent can write the notebook, pipeline.ipynb is added to required_deliverables for you.

A worked example#

This example sets a 30-minute time budget, a $2 cost ceiling and a 100-evaluation reminder on your own study. Replace my_study with your study folder (see Write a study):

from pathlib import Path
from adda import AgenticRun

run = AgenticRun(
    Path("my_study"),   # your study folder; see Write a study
    budget=1800,        # 30 minutes of working time
    budget_usd=2.0,     # close the run at $2 of model spend
    eval_budget=100,    # notices from 75 evaluations on
)
run.execute()

While the run works, each agent's turn starts with a block that states the budgets. This one is from a run of the example study, early in the run:

<constraints>
Evaluation budget: 0/100 evals used.
Wall-clock budget: 32s/30.0min used (2%); no new delegation starts after 27.0min; the run winds down at 30.0min.
</constraints>

Here is what you see as the run reaches each limit:

  • At 75 evaluations, agents read that 25 evaluations are left. They may keep evaluating; the number can pass 100.
  • At 27 minutes (90%), a node that tries to start a delegation gets an error that begins ERROR: No new delegations: and says the delegation was not started.
  • At 30 minutes, the wind-down starts. When the run closes, my_study/runs/<timestamp>/debug/run_status.json shows "termination": "budget_wind_down".
  • If spend reaches $2 first, the run winds down and closes, and run_status.json shows "termination": "backstop_usd". To continue, raise budget_usd and pass resume_from=Path("my_study/runs/<timestamp>") to a new AgenticRun.
  • If a delegation's script uses more than 4 GiB (the default mem_cap on a laptop), the delegation fails and its result includes a line such as Killed by the memory watcher: D003 used 5.2 GiB, over the 4.0 GiB per-delegation cap (mem_cap). The run records the kill in debug/diagnostics.jsonl.

Check your understanding#

  • Which limits can stop the run, and which only remind the agents?
  • Your run has budget=3600 and token_budget=200_000. After 20 minutes it has generated 150,000 tokens. Can a node still start a delegation?
  • A delegation was killed for memory. Does the run stop?

Next, see A run's files on disk to find each of these records in your run folder.