Skip to content

Commit ac1d337

Browse files
authored
perf: gate daily quality sweep to off-peak hours (18:00-23:59 local) (#5131)
* perf: gate daily quality sweep to off-peak hours (18:00-23:59 local) Anthropic doubles token allowance during off-peak (6 PM-12 AM UK time). Quality sweep findings trigger LLM worker dispatch via the pulse, so landing findings in this window means resulting workers also run at 2x rates. Health issues and person stats continue on their existing 15-min/hourly cadence unaffected. Override with QUALITY_SWEEP_OFFPEAK=0 to force daytime runs. * chore: log when quality sweep is deferred by off-peak gate Addresses CodeRabbit nitpick — adds visibility into why sweeps don't run during daytime hours.
1 parent 92a6318 commit ac1d337

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

.agents/scripts/stats-functions.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,21 @@ update_health_issues() {
889889
# actionable GitHub issues for findings that warrant fixes.
890890
#######################################
891891
run_daily_quality_sweep() {
892+
# Time-of-day gate — only run during off-peak hours (18:00-23:59 local).
893+
# Anthropic doubles token allowance during off-peak (6 PM-12 AM UK time),
894+
# and model demand is lower. Quality sweep findings trigger LLM worker
895+
# dispatch via the pulse, so landing findings in this window means the
896+
# resulting workers also run at 2x rates. Override: QUALITY_SWEEP_OFFPEAK=0
897+
if [[ "${QUALITY_SWEEP_OFFPEAK:-1}" == "1" ]]; then
898+
local current_hour
899+
current_hour=$(date +%H)
900+
current_hour=$((10#$current_hour)) # strip leading zero for arithmetic
901+
if [[ "$current_hour" -lt 18 ]]; then
902+
echo "[stats] Quality sweep deferred: hour ${current_hour} is outside off-peak window (18:00-23:59)" >>"$LOGFILE"
903+
return 0
904+
fi
905+
fi
906+
892907
# Timestamp guard — run at most once per QUALITY_SWEEP_INTERVAL
893908
if [[ -f "$QUALITY_SWEEP_LAST_RUN" ]]; then
894909
local last_run

0 commit comments

Comments
 (0)