Commit Graph
7 Commits
Author SHA1 Message Date
yetone 23cec6c4fb warm-up: an official reset after a spent reset card, nothing used between, is warmed (shangyuan0818)
shangyuan0818 on Discord (10-24): "Warm up on reset" on for the Codex
week. magpie spent a Codex reset card about to run out, the warm-up
after it started the week, nothing was used, then OpenAI reset
everyone's limits. No warm-up went for that second reset.

Cause: warmDue saw a reset only when the window's use fell (by 1 or
more) or its kept reset time passed. After the card and its warm-up
the window was running at 0% used, so the official reset had no use
to fall from, and the reset time kept (a week from the warm-up) was
still days off. The read after it shows the window not started (0%,
its reset a whole window from now), which nothing compared with what
was kept.

Fix: warmDue also counts a window as started over when it is not
started now (idle) and its reported reset is at least warmSlack later
than both the reset it was seen running to and the end of the window
magpie's last warm-up started (movedOn), or no reset is reported at
all. The second bound keeps a read that still carried an old reset
before showing the warm-up's own window from looking like a reset.
After the upgrade an account already in this state is warmed on the
next look: nothing for the user to do.

Siblings: the same warmDue runs for every ChatGPT account, the 5-hour
window ("all"), and Claude's warm-up (claude_warmup.go, same
codexWarmer), whose not-started windows Anthropic leaves out of the
read; each has a subtest. No other provider has a warm-up.

Tests: TestWarmAfterResetCardThenOfficialReset drives fake usage reads
through the reported sequence (card spent, warm-up, a third of the
window unused, official reset, then 12 more looks) for the Codex week,
the Codex 5 hours and a Claude week left out of the read, with a
second account running all along that must never be sent one.
TestWarmDue gets three cases. TestCodexWarmOncePerReset's last step
set two weeks warmed 10 and 35 minutes before to reset a full week
from now, which is what a not-started window reports; they now reset
a week from their warm-ups, as the backend reports a started window.

Broken by hand:
- old codex_warmup.go with the new tests: TestWarmDue "reset early,
  nothing used before" and "... left out" due false, want true;
  TestWarmAfterResetCardThenOfficialReset all three subtests "after
  the official reset, sent [a@example.com]".
- movedOn's nil-reset branch returning false: the Claude subtest and
  the "left out" case go red.
- movedOn without the warm-up bound: TestCodexWarmOncePerReset goes
  red ("all: [a@example.com:5 hours b@example.com:7 days]").

Run at 4b9694c34 plus this change (rebased onto dcfda5f16, which
changes internal/gateway only):
- gofmt -l on both files: nothing.
- go vet ./internal/provider/, GOOS=linux go vet -tags nogui
  ./internal/provider/, GOOS=windows go vet ./internal/provider/: ok.
- go build ./..., GOOS=linux go build -tags nogui ./...,
  GOOS=windows go build ./...: ok.
- go test -tags nogui -timeout 45m ./internal/provider/ in a sandbox
  HOME: ok (113s), no reds.

Not run: the full go test ./... (other sessions' full suites are
queued on this machine, one suite per machine). Not tried with a real
account: an official OpenAI reset can't be made on demand, so the
backend's reads after it come from the report and from what an idle
window reports today (0% used, reset a whole window from now). If
OpenAI's reset instead keeps the old reset time with 0% used, the
read can't tell it from a running unused window, and this change
doesn't catch it.
2026-10-24 22:22:21 +08:00
yetone 0506ea396f provider, settings, gui: Daily warm-up takes several times a day, each starting the 5-hour windows once (#1260)
Sinnhu asked for more than one daily warm-up time (e.g. 09:00, 15:05,
19:10). Settings has codexWarmAts / claudeWarmAts beside the old single
keys: the list wins when set (an empty one is off), a file from before
it reads its one time as a list of one, and the first time is written
back to codexWarmAt / claudeWarmAt so an older magpie still reads one.
Times are kept as HH:MM, sorted, once each; a bad one is refused.

The scheduler (dayStart, nextDayStart, dailyDue, heldForDay,
dayStartPassed, warmLook) takes the list: the start due is the latest
of any time that has passed, and the day kept per window is now that
start ("2026-09-28 15:05"), so each time sends once a day. A day kept by
an older magpie ("2026-09-28") counts as every start of that day had,
so nothing is sent twice on the day of the update. An account's own
time (codexWarmAtOf) stays one time.

Settings › Allowances › Daily warm-up: each time is a time field with ×
beside it while another is left, + adds one a window after the last,
Off/On as before. The times wrap in a group of their own beside + and
Off/On, so adding or removing one never moves the button pressed. New
strings in zh, en, zh-TW, ja, de.

Verified:
- go test -tags nogui ./internal/provider ./internal/settings
  ./internal/gui (temp HOME, pinned caches, pipefail): ok. go build and
  go vet -tags nogui ./...; GOOS=linux and GOOS=windows go vet -tags
  nogui on the three packages: clean.
- Fails without the change: TestWarmAtSeveralTimes (dayStart looking at
  the first time only, or a day-only key: "sent at 06:00"),
  TestWarmLookAndHoldAtSeveralTimes ("15:05 not looked at"),
  TestWarmAtKeptDayFromBefore and TestDailyDue (an old day-only record
  not honoured: "sent again"), TestWarmAtsMigrate (old key not read:
  "old file: [] ..."; first time not written back: "old file:
  ["06:00"] "" ...").
- GUI: warm-at-times.test.cjs, Chromium and WebKit, en/zh/ja/de, 900
  and 440px: 16/16; with warm-at-own, settings-groups, gui-ja, gui-de,
  gui-zh-tw, i18n-keys: 36/36 in each engine.
  Whole GUI suite (node --test, concurrency 4): 3716/3724; the 8 red
  (agent-models-redraw, azure-endpoint, context-window,
  gateway-key-limit, login-import, member-model-setting, search-api)
  each pass run alone with this change, and none reaches the warm-up
  row.

Not tried with real accounts or a live day of the scheduler.
2026-10-08 16:05:15 +08:00
yetone 1e80a84fe3 provider: a Codex warm-up asks the account's cheapest model (#604) — warmModel took a model with mini in its id or else the first listed, and a GPT-6 account lists no mini and starts with the flagship gpt-6.1-sol. warmPick takes the cheapest by list price (the model's own, else models.dev's openai price), and with no price known a mini, then a luna (GPT-6's cheap one), then the first. TestWarmPick. 2026-10-03 02:53:20 +08:00
Ns2Kracy 62ded971c0 codex: retry unused 5-hour windows after warm-up (#192)
* codex: retry warm-ups for unused five-hour windows

Keep the idle retry schedule when Codex reports zero usage and a reset a full window away. A successful warm-up request can leave the window unstarted, and a fresh reset_after_seconds on each read otherwise makes the saved reset drift indefinitely. Retry with the existing backoff until the reset begins counting down.\n\nCover the relative reset field, retries at 15 and 45 minutes, stopping once the window runs, and warming the next reset.

* test: cover a used window after Codex warm-up

Confirm the retry schedule stops both when an unused window starts counting down and when subsequent usage becomes nonzero, before the next reset triggers another warm-up.
2026-09-29 14:29:06 +08:00
yetone 69a14800d9 warmup: a window that hasn't started is started, and started again after a try that didn't take (#178) — the warm-up only acted on a window with a reset time, so a Codex or Claude account whose 5-hour window had never started (no reset time, nothing used) was never warmed. Now a window the usage reads as not started, or one the agent's windows should have but the reading lacks, is due at once when idle; a try that leaves it unstarted is tried again after 15 minutes, doubling to 4 hours; reading the usage and seeing a window not started kicks the warm-up rather than waiting its 10-minute round, and a warm-up forgets the cached usage so the new window shows. Tested with the repro of the issue, the backoff, and the kick 2026-09-29 10:50:39 +08:00
yetone 33ea9a58ab warm-up: the 5-hour windows can start at a time of day (预热是重置之后发,时间不一定是我想要的…早上六点发送一个请求,这样就可以做到一天三个五小时) — Settings has "Codex daily warm-up" and "Claude Code daily warm-up" under the warm-ups, Off or On with a time field (06:00 to begin with, local time, codexWarmAt / claudeWarmAt); each day at that time every signed-in account of that kind whose 5-hour window isn't running is sent the warm-up's one tiny request, once a day an account, the day kept in codex-warmup.json / claude-warmup.json so a restart doesn't send it again; a machine asleep then sends it on waking up to an hour late and leaves the day be after that; a failed one is tried again within the hour. It works with the reset warm-up off, weekly or on; with "Weekly and 5-hour" a window that would still be running at the time isn't started on its reset, so the windows follow one another from it (06, 11, 16, 21, then 06 again) instead of drifting round the clock. The warm-up loop looks at the wall clock every minute, running as before every 5 and at once when the time comes 2026-09-28 18:47:30 +08:00
yetone c96cfa0ba0 codex: warm-up — a ChatGPT account's next window can be started as soon as the last one resets, by a one-word request to the mini model at low effort, so the 5-hour (or weekly) clock is already running when work begins; Settings → Codex 预热: off, weekly, or weekly and 5-hour. Checked every 5 minutes, only a window seen idle (nothing used, its reset a full span away) is warmed, three tries per reset 2026-09-27 17:36:20 +08:00