refactor: remove the disabled periodic Codex warm-up loop

CODEX_WARMUP_ENABLED defaulted to false and was never set, so the
warm-up loop in unified-dashboard never ran. Remove the loop, the
`enabled` / `intervalMs` config keys, the `disabled` result and the
`shouldSkip` hook it alone used. The fixed-slot usage primer keeps
calling runCodexWarmupCycle with forceAttempt exactly as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-10-01 19:08:55 +09:00
parent 12b262eaa9
commit fe7c5a7b23
10 changed files with 11 additions and 85 deletions

View File

@@ -46,21 +46,12 @@ STATUS_CHANNEL_ID= # Discord channel ID for live status updat
# prefer screenshot/output folders over /home. Comma or path-delimiter separated.
# EJCLAW_ATTACHMENT_ALLOWED_DIRS=~/Pictures/Screenshots,~/Downloads/ejclaw-images
# --- Codex warm-up (optional, disabled by default) ---
# Sends a tiny real Codex prompt only when both 5h and 7d usage are 0%, so
# reset countdown starts once after a fresh quota window. Keep disabled if
# OpenAI changes policy or starts blocking automated warm-up prompts.
# Normally only set this one line; the other knobs have conservative defaults.
# CODEX_WARMUP_ENABLED=false
# --- Codex usage primer ---
# The usage primer sends a tiny real Codex prompt at fixed KST slots
# (08/13/18/23). These keys override its prompt, model and timeout.
# CODEX_WARMUP_PROMPT=Reply exactly OK. Do not run tools.
# CODEX_WARMUP_MODEL= # Defaults to CODEX_MODEL
# CODEX_WARMUP_INTERVAL_MS=300000 # Check every 5min
# CODEX_WARMUP_MIN_INTERVAL_MS=18300000 # Per-account minimum gap: 5h5m
# CODEX_WARMUP_STAGGER_MS=1800000 # Global gap between accounts: 30min
# CODEX_WARMUP_MAX_USAGE_PCT=0 # Only warm accounts at/below this 5h usage
# CODEX_WARMUP_MAX_D7_USAGE_PCT=0 # Only warm accounts at/below this 7d usage
# CODEX_WARMUP_MAX_CONSECUTIVE_FAILURES=2
# CODEX_WARMUP_FAILURE_COOLDOWN_MS=21600000 # Back off 6h after repeated failure
# CODEX_WARMUP_COMMAND_TIMEOUT_MS=120000
# --- Per-role model overrides (paired rooms) ---
# Override global CLAUDE_MODEL/CODEX_MODEL per role.

View File

@@ -17,6 +17,7 @@
- 쓰이지 않던 export·고아 모듈(`src/dashboard.ts`, `src/dashboard-status-content.ts`, `src/restart-context-cli.ts`)과 `DELTA_HANDOFF_*` 설정
- macOS launchd·nohup(WSL) 설치 경로와 `launchd/`, 쓰이지 않던 `repo-tokens/` GitHub Action. 서비스 설치는 Linux systemd만 지원
- 루트에서 import하지 않던 `yaml`, `zod`, `@modelcontextprotocol/sdk` 의존성 (agent-runner는 자체 의존성 유지)
- 기본 비활성이던 주기적 Codex warm-up 루프와 `CODEX_WARMUP_ENABLED`/`CODEX_WARMUP_INTERVAL_MS`. 고정 슬롯 usage primer는 그대로 동작
### Fixed

View File

@@ -125,10 +125,8 @@ describe('Codex warm-up scheduler', () => {
const result = await runCodexWarmupCycle(
{
enabled: true,
prompt: 'Reply exactly OK. Do not run tools.',
model: 'gpt-5.5',
intervalMs: 300_000,
minIntervalMs: 18_300_000,
staggerMs: 1_800_000,
maxUsagePct: 0,
@@ -203,10 +201,8 @@ describe('Codex warm-up scheduler', () => {
await runCodexWarmupCycle(
{
enabled: true,
prompt: 'Reply exactly OK. Do not run tools.',
model: 'gpt-5.5',
intervalMs: 300_000,
minIntervalMs: 18_300_000,
staggerMs: 1_800_000,
maxUsagePct: 0,
@@ -263,10 +259,8 @@ describe('Codex warm-up scheduler', () => {
const result = await runCodexWarmupCycle(
{
enabled: true,
prompt: 'Reply exactly OK. Do not run tools.',
model: 'gpt-5.5',
intervalMs: 300_000,
minIntervalMs: 18_300_000,
staggerMs: 0,
maxUsagePct: 0,
@@ -326,10 +320,8 @@ describe('Codex warm-up scheduler', () => {
const result = await runCodexWarmupCycle(
{
enabled: true,
prompt: 'Reply exactly OK. Do not run tools.',
model: 'gpt-5.5',
intervalMs: 300_000,
minIntervalMs: 18_000_000,
staggerMs: 0,
maxUsagePct: 0,
@@ -375,10 +367,8 @@ describe('Codex warm-up scheduler', () => {
);
const config = {
enabled: true,
prompt: 'Reply exactly OK. Do not run tools.',
model: 'gpt-5.5',
intervalMs: 300_000,
minIntervalMs: 18_300_000,
staggerMs: 0,
maxUsagePct: 0,
@@ -434,10 +424,8 @@ describe('Codex warm-up scheduler', () => {
const result = await runCodexWarmupCycle(
{
enabled: true,
prompt: '.',
model: 'gpt-5.5',
intervalMs: 300_000,
minIntervalMs: 18_300_000,
staggerMs: 1_800_000,
maxUsagePct: 0,
@@ -462,10 +450,8 @@ describe('Codex warm-up fixed-slot forceAttempt', () => {
const t13 = new Date('2026-06-09T04:00:00.486Z').getTime();
const t18 = new Date('2026-06-09T09:00:00.000Z').getTime();
const config = {
enabled: true as const,
prompt: 'Reply exactly OK. Do not run tools.',
model: 'gpt-5.5',
intervalMs: 300_000,
minIntervalMs: 18_000_000, // 5h
staggerMs: 1_800_000,
maxUsagePct: 100,

View File

@@ -34,7 +34,6 @@ interface CodexWarmupState {
interface CodexWarmupRuntimeOptions {
nowMs?: number;
statePath?: string;
shouldSkip?: () => boolean;
ignoreZeroUsageWindow?: boolean;
/**
* Fixed-slot primer mode: bypass the opportunistic warm-up skip gates
@@ -48,7 +47,6 @@ interface CodexWarmupRuntimeOptions {
}
export type CodexWarmupCycleResult =
| { status: 'disabled' }
| { status: 'skipped'; reason: string }
| { status: 'warmed'; accountIndex: number }
| { status: 'failed'; accountIndex: number; reason: string };
@@ -336,10 +334,6 @@ export async function runCodexWarmupCycle(
config: CodexWarmupConfig,
runtime: CodexWarmupRuntimeOptions = {},
): Promise<CodexWarmupCycleResult> {
if (!config.enabled) return { status: 'disabled' };
if (runtime.shouldSkip?.())
return { status: 'skipped', reason: 'runtime_busy' };
const nowMs = runtime.nowMs ?? Date.now();
const nowIso = new Date(nowMs).toISOString();
const statePath = runtime.statePath ?? DEFAULT_STATE_FILE;

View File

@@ -31,10 +31,8 @@ describe('config/env loading', () => {
delete process.env.DISCORD_CODEX_REVIEW_BOT_TOKEN;
delete process.env.PAIRED_CARRY_FORWARD_LATEST_OWNER_FINAL;
delete process.env.PAIRED_FORCE_FRESH_CLAUDE_REVIEWER_SESSION;
delete process.env.CODEX_WARMUP_ENABLED;
delete process.env.CODEX_WARMUP_PROMPT;
delete process.env.CODEX_WARMUP_MODEL;
delete process.env.CODEX_WARMUP_INTERVAL_MS;
delete process.env.CODEX_WARMUP_MIN_INTERVAL_MS;
delete process.env.CODEX_WARMUP_STAGGER_MS;
delete process.env.CODEX_WARMUP_MAX_USAGE_PCT;
@@ -135,9 +133,8 @@ describe('config/env loading', () => {
expect(config.PAIRED_FORCE_FRESH_CLAUDE_REVIEWER_SESSION).toBe(true);
});
it('keeps Codex warm-up disabled by default and exposes conservative opt-in env config', async () => {
it('exposes conservative Codex warm-up env config', async () => {
let config = await import('./config.js');
expect(config.CODEX_WARMUP_CONFIG.enabled).toBe(false);
expect(config.CODEX_WARMUP_CONFIG.maxUsagePct).toBe(0);
expect(config.CODEX_WARMUP_CONFIG.maxD7UsagePct).toBe(0);
expect(
@@ -146,7 +143,6 @@ describe('config/env loading', () => {
vi.resetModules();
process.env.CODEX_MODEL = 'gpt-5.5';
process.env.CODEX_WARMUP_ENABLED = 'true';
process.env.CODEX_WARMUP_PROMPT = '.';
process.env.CODEX_WARMUP_STAGGER_MS = '600000';
process.env.CODEX_WARMUP_MAX_CONSECUTIVE_FAILURES = '1';
@@ -154,7 +150,6 @@ describe('config/env loading', () => {
expect(config.CODEX_WARMUP_CONFIG).toEqual(
expect.objectContaining({
enabled: true,
prompt: '.',
model: 'gpt-5.5',
staggerMs: 600000,

View File

@@ -239,7 +239,6 @@ export function loadConfig(): AppConfig {
readText('TZ') ?? Intl.DateTimeFormat().resolvedOptions().timeZone,
},
codexWarmup: {
enabled: readBoolean('CODEX_WARMUP_ENABLED', false),
prompt:
readNonEmptyText('CODEX_WARMUP_PROMPT') ??
'Reply exactly OK. Do not run tools.',
@@ -247,7 +246,6 @@ export function loadConfig(): AppConfig {
readNonEmptyText('CODEX_WARMUP_MODEL') ??
readNonEmptyText('CODEX_MODEL') ??
'codex',
intervalMs: readIntegerAtLeast('CODEX_WARMUP_INTERVAL_MS', 300000, 60000),
minIntervalMs: readIntegerAtLeast(
'CODEX_WARMUP_MIN_INTERVAL_MS',
18300000,

View File

@@ -78,10 +78,8 @@ export interface AppConfig {
timezone: string;
};
codexWarmup: {
enabled: boolean;
prompt: string;
model: string;
intervalMs: number;
minIntervalMs: number;
staggerMs: number;
maxUsagePct: number;

View File

@@ -14,7 +14,6 @@ import {
STATUS_SHOW_ROOM_DETAILS,
STATUS_SHOW_ROOMS,
USAGE_DASHBOARD_ENABLED,
CODEX_WARMUP_CONFIG,
} from './config.js';
import { getGlobalFailoverInfo } from './service-routing.js';
import {
@@ -27,7 +26,6 @@ import {
refreshActiveCodexUsage,
refreshAllCodexAccountUsage,
} from './codex-usage-collector.js';
import { runCodexWarmupCycle } from './codex-warmup.js';
import {
composeDashboardContent,
formatElapsed,
@@ -1060,35 +1058,10 @@ export async function startUnifiedDashboard(
cachedCodexUsageRows = result.rows;
if (result.fetchedAt) codexUsageFetchedAt = result.fetchedAt;
};
const isWarmupRuntimeBusy = () => {
const groups = opts.roomBindings();
return opts.queue
.getStatuses(Object.keys(groups))
.some((status) => status.status === 'processing');
};
let codexWarmupInFlight = false;
const runCodexWarmup = async () => {
if (!CODEX_WARMUP_CONFIG.enabled || codexWarmupInFlight) return;
codexWarmupInFlight = true;
try {
const result = await runCodexWarmupCycle(CODEX_WARMUP_CONFIG, {
shouldSkip: isWarmupRuntimeBusy,
});
if (result.status === 'warmed') {
applyCodexRefresh(await refreshAllCodexAccountUsage());
}
} catch (err) {
logger.warn({ err }, 'Codex warm-up cycle failed unexpectedly');
} finally {
codexWarmupInFlight = false;
}
};
void refreshAllCodexAccountUsage()
.then((r) => {
applyCodexRefresh(r);
return refreshActiveCodexUsage().then(applyCodexRefresh);
})
.then(() => runCodexWarmup());
void refreshAllCodexAccountUsage().then((r) => {
applyCodexRefresh(r);
return refreshActiveCodexUsage().then(applyCodexRefresh);
});
// Each poll spawns a Codex app-server; every 5 minutes is plenty for the
// dashboard (it used to run every minute, ~1,440 spawns a day).
setInterval(
@@ -1096,15 +1069,9 @@ export async function startUnifiedDashboard(
Math.max(opts.usageUpdateInterval, CODEX_ACTIVE_USAGE_POLL_MS),
);
setInterval(
() =>
void refreshAllCodexAccountUsage()
.then(applyCodexRefresh)
.then(() => runCodexWarmup()),
() => void refreshAllCodexAccountUsage().then(applyCodexRefresh),
CODEX_FULL_SCAN_INTERVAL,
);
if (CODEX_WARMUP_CONFIG.enabled) {
setInterval(() => void runCodexWarmup(), CODEX_WARMUP_CONFIG.intervalMs);
}
logger.info(
{

View File

@@ -17,10 +17,8 @@ const runCodexWarmupCycle = vi.fn(async () => {
vi.mock('./config.js', () => ({
CODEX_WARMUP_CONFIG: {
enabled: false,
prompt: 'Reply exactly OK. Do not run tools.',
model: 'gpt-5.5',
intervalMs: 300_000,
minIntervalMs: 18_300_000,
staggerMs: 1_800_000,
maxUsagePct: 0,
@@ -69,7 +67,6 @@ describe('usage-primer', () => {
expect(refreshAllCodexAccountUsage).not.toHaveBeenCalled();
expect(runCodexWarmupCycle).toHaveBeenCalledWith(
expect.objectContaining({
enabled: true,
minIntervalMs: 18_000_000,
maxUsagePct: 100,
maxD7UsagePct: 100,

View File

@@ -158,7 +158,6 @@ export async function runCodexPrimerCycle(): Promise<void> {
const result = await runCodexWarmupCycle(
{
...CODEX_WARMUP_CONFIG,
enabled: true,
minIntervalMs: CODEX_PRIMER_MIN_INTERVAL_MS,
maxUsagePct: CODEX_PRIMER_MAX_USAGE_PCT,
maxD7UsagePct: CODEX_PRIMER_MAX_D7_USAGE_PCT,