interlens.stop.stop_condition¶
interlens.stop.stop_condition
¶
AnyStopCondition
¶
Bases: StopCondition
Fires when any member condition fires. run(until=[...]) wraps a list in this.
Source code in src/interlens/stop/stop_condition.py
StopCondition
¶
Bases: ABC
A stateful predicate that ends a Conversation.run early.
Each condition is stateful (tracks its own counters) and is checked after every committed turn via
should_stop(conversation, last_message). reset() clears state and is called at the start of each
run (and branches get fresh copies), so one instance can be reused across runs without leaking state.
A condition may also cap the next generation via turn_cap (e.g. a token budget shrinks the last turn so
it lands exactly on budget) and may be installed ambiently as a context manager (with TokenBudget(...):
conv.rollout(...) applies it to every conversation in the block). New conditions subclass this without any
change to run.
reset
¶
turn_cap
¶
An upper bound on the NEXT turn's generated tokens, or None for no cap. The run loop passes it as
max_new_tokens (bounded by the speaker's own cap), so a budget condition can prevent both overshoot and a
single turn from consuming the whole allowance. Default: no cap.
Source code in src/interlens/stop/stop_condition.py
active_stop_conditions
¶
The stop conditions currently installed by enclosing with condition: blocks (outermost first).