interlens.stop.conditions¶
interlens.stop.conditions
¶
ElapsedTimeStopCondition
¶
Bases: StopCondition
Stop once seconds of wall-clock have elapsed since the run started (monotonic clock).
Source code in src/interlens/stop/conditions.py
StopStringCondition
¶
Bases: StopCondition
Stop when a committed message's visible content contains any of the given strings (a done-signal).
Source code in src/interlens/stop/conditions.py
TokenBudget
¶
Bases: StopCondition
A per-conversation compute budget — the matched-compute primitive for fair solo-vs-pair comparisons.
per_conversation stops a conversation once ITS OWN cumulative generated tokens reach the budget, and
per_turn caps each individual turn so the allowance is spread across real conversation turns rather than
consumed by one monologue. Both are enforced via turn_cap too: the run loop shrinks the next generation to
min(speaker cap, per_turn, per_conversation - spent), so the budget is respected without overshoot.
The budget is per-conversation, not a shared pool. Spend is read from the conversation's own transcript
(metadata['n_tokens']), so the condition is stateless — in a rollout of N copies, each copy independently
gets the full budget. Cheap to count (never re-tokenizes) and trivially picklable, so it works installed
directly (run_until=TokenBudget(...)) or ambiently (with TokenBudget(per_conversation=200): conv.rollout()).
Source code in src/interlens/stop/conditions.py
TokenStopCondition
¶
Bases: StopCondition
Stop once the total generated tokens across turns reach max_tokens.
The per-turn count comes from Message.metadata['n_tokens'], which ModelParticipant.generate records —
so the source of truth is defined, not guessed. Turns without a count (e.g. seeded messages) contribute 0.
Source code in src/interlens/stop/conditions.py
TurnStopCondition
¶
Bases: StopCondition
Stop after max_turns committed turns.