Skip to content

BudgetThresholds

autogen.beta.eval.results.budgets.BudgetThresholds dataclass #

BudgetThresholds(max_tokens_per_task=None, max_seconds_per_task=None)

Per-task budget thresholds.

Budgets are observational in v0 — the runner records violations in RunResult.aggregates.budget_violations but never aborts a task that exceeds them. The count is intended as a regression signal in CI ("zero tasks may go over budget"), not as a kill switch.

A field set to None (the default) means "no limit".

PARAMETER DESCRIPTION
max_tokens_per_task

Maximum sum of input + output tokens across every model call in one task.

TYPE: int | None DEFAULT: None

max_seconds_per_task

Maximum wall-clock duration of one task, measured around agent.ask(...).

TYPE: float | None DEFAULT: None

max_tokens_per_task class-attribute instance-attribute #

max_tokens_per_task = None

max_seconds_per_task class-attribute instance-attribute #

max_seconds_per_task = None

exceeded_by #

exceeded_by(trace)

True iff trace exceeds any set threshold (tokens or wall-clock).

Source code in autogen/beta/eval/results/budgets.py
def exceeded_by(self, trace: "Trace") -> bool:
    """``True`` iff ``trace`` exceeds any set threshold (tokens or wall-clock)."""
    if self.max_tokens_per_task is not None and trace.tokens.total > self.max_tokens_per_task:
        return True
    return self.max_seconds_per_task is not None and trace.duration_ms / 1000 > self.max_seconds_per_task