You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1a44050
Browse filesBrowse the repository at this point in the historyBrowse files
fix(sleep): enforce max_tokens_per_night in the nightly cycle (#317)
* fix(sleep): enforce max_tokens_per_night in the nightly cycle
The config default and the Budget controller existed, but nothing in the
engine read the key or constructed a Budget, so a night ran every step no
matter how many tokens it had already used.
Build a Budget from max_tokens_per_night at the start of each cycle and
check it, against the backend's token counter, before each step that would
start new model work: the consolidation, its skill and memory edit steps,
the held-out test replay and every per-skill fan-out group. Steps that never
started are listed in a report note, in budget skip evidence events and in
the cycle end event. A started step always finishes, so a gate decision
never rests on partial evidence and nothing is cut off mid-write.
A handoff round counts unanswered prompts and placeholder replies, so when
the budget is reached while prompts are still pending the round pauses for
answers instead of stopping. Otherwise it would stage and save a night built
from placeholders. If the budget is already spent before consolidation, the
night records no held-out scores instead of zeros.
0 or null keeps the night unbudgeted, matching Budget's existing semantics.
Negative, boolean, fractional, infinite or non-numeric values fail before
any model call. Only tonight's spend counts, so a backend reused across
nights is not stopped early.
Fixes#313
* fix(sleep): skip the final validation replay once the budget is spent
The budget check assumed the final validation replay was free because it
re-scores documents an earlier replay already scored. That holds for cached
text replies, but tool replay is never cached and a failed or timed out call
is not kept in the cache, so on those routes the final replay started new
provider calls after both edit steps had been skipped.
Check the budget before the final validation replay as well. When it is
spent, decide from the validation replay that already scored the final skill
and memory (the baseline replay, or the trial replay of the last kept edit)
instead of starting a new one, and list the skipped replay in the report
note and the budget skip events. Nights that never reach the budget still
run the fresh final replay as before.
The new tests drive ClaudeCliBackend through its real tool and text routes
with a synthetic process standing in for the claude CLI and count every
process it starts, for answered and timed out calls.
0 commit comments