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. # prefer screenshot/output folders over /home. Comma or path-delimiter separated.
# EJCLAW_ATTACHMENT_ALLOWED_DIRS=~/Pictures/Screenshots,~/Downloads/ejclaw-images # EJCLAW_ATTACHMENT_ALLOWED_DIRS=~/Pictures/Screenshots,~/Downloads/ejclaw-images
# --- Codex warm-up (optional, disabled by default) --- # --- Codex usage primer ---
# Sends a tiny real Codex prompt only when both 5h and 7d usage are 0%, so # The usage primer sends a tiny real Codex prompt at fixed KST slots
# reset countdown starts once after a fresh quota window. Keep disabled if # (08/13/18/23). These keys override its prompt, model and timeout.
# 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_WARMUP_PROMPT=Reply exactly OK. Do not run tools. # CODEX_WARMUP_PROMPT=Reply exactly OK. Do not run tools.
# CODEX_WARMUP_MODEL= # Defaults to CODEX_MODEL # CODEX_WARMUP_MODEL= # Defaults to CODEX_MODEL
# CODEX_WARMUP_INTERVAL_MS=300000 # Check every 5min # CODEX_WARMUP_COMMAND_TIMEOUT_MS=120000
# 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
# --- Per-role model overrides (paired rooms) --- # --- Per-role model overrides (paired rooms) ---
# Override global CLAUDE_MODEL/CODEX_MODEL per role. # 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_*` 설정 - 쓰이지 않던 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만 지원 - macOS launchd·nohup(WSL) 설치 경로와 `launchd/`, 쓰이지 않던 `repo-tokens/` GitHub Action. 서비스 설치는 Linux systemd만 지원
- 루트에서 import하지 않던 `yaml`, `zod`, `@modelcontextprotocol/sdk` 의존성 (agent-runner는 자체 의존성 유지) - 루트에서 import하지 않던 `yaml`, `zod`, `@modelcontextprotocol/sdk` 의존성 (agent-runner는 자체 의존성 유지)
- 기본 비활성이던 주기적 Codex warm-up 루프와 `CODEX_WARMUP_ENABLED`/`CODEX_WARMUP_INTERVAL_MS`. 고정 슬롯 usage primer는 그대로 동작
### Fixed ### Fixed

View File

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

View File

@@ -34,7 +34,6 @@ interface CodexWarmupState {
interface CodexWarmupRuntimeOptions { interface CodexWarmupRuntimeOptions {
nowMs?: number; nowMs?: number;
statePath?: string; statePath?: string;
shouldSkip?: () => boolean;
ignoreZeroUsageWindow?: boolean; ignoreZeroUsageWindow?: boolean;
/** /**
* Fixed-slot primer mode: bypass the opportunistic warm-up skip gates * Fixed-slot primer mode: bypass the opportunistic warm-up skip gates
@@ -48,7 +47,6 @@ interface CodexWarmupRuntimeOptions {
} }
export type CodexWarmupCycleResult = export type CodexWarmupCycleResult =
| { status: 'disabled' }
| { status: 'skipped'; reason: string } | { status: 'skipped'; reason: string }
| { status: 'warmed'; accountIndex: number } | { status: 'warmed'; accountIndex: number }
| { status: 'failed'; accountIndex: number; reason: string }; | { status: 'failed'; accountIndex: number; reason: string };
@@ -336,10 +334,6 @@ export async function runCodexWarmupCycle(
config: CodexWarmupConfig, config: CodexWarmupConfig,
runtime: CodexWarmupRuntimeOptions = {}, runtime: CodexWarmupRuntimeOptions = {},
): Promise<CodexWarmupCycleResult> { ): Promise<CodexWarmupCycleResult> {
if (!config.enabled) return { status: 'disabled' };
if (runtime.shouldSkip?.())
return { status: 'skipped', reason: 'runtime_busy' };
const nowMs = runtime.nowMs ?? Date.now(); const nowMs = runtime.nowMs ?? Date.now();
const nowIso = new Date(nowMs).toISOString(); const nowIso = new Date(nowMs).toISOString();
const statePath = runtime.statePath ?? DEFAULT_STATE_FILE; 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.DISCORD_CODEX_REVIEW_BOT_TOKEN;
delete process.env.PAIRED_CARRY_FORWARD_LATEST_OWNER_FINAL; delete process.env.PAIRED_CARRY_FORWARD_LATEST_OWNER_FINAL;
delete process.env.PAIRED_FORCE_FRESH_CLAUDE_REVIEWER_SESSION; 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_PROMPT;
delete process.env.CODEX_WARMUP_MODEL; 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_MIN_INTERVAL_MS;
delete process.env.CODEX_WARMUP_STAGGER_MS; delete process.env.CODEX_WARMUP_STAGGER_MS;
delete process.env.CODEX_WARMUP_MAX_USAGE_PCT; 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); 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'); 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.maxUsagePct).toBe(0);
expect(config.CODEX_WARMUP_CONFIG.maxD7UsagePct).toBe(0); expect(config.CODEX_WARMUP_CONFIG.maxD7UsagePct).toBe(0);
expect( expect(
@@ -146,7 +143,6 @@ describe('config/env loading', () => {
vi.resetModules(); vi.resetModules();
process.env.CODEX_MODEL = 'gpt-5.5'; process.env.CODEX_MODEL = 'gpt-5.5';
process.env.CODEX_WARMUP_ENABLED = 'true';
process.env.CODEX_WARMUP_PROMPT = '.'; process.env.CODEX_WARMUP_PROMPT = '.';
process.env.CODEX_WARMUP_STAGGER_MS = '600000'; process.env.CODEX_WARMUP_STAGGER_MS = '600000';
process.env.CODEX_WARMUP_MAX_CONSECUTIVE_FAILURES = '1'; process.env.CODEX_WARMUP_MAX_CONSECUTIVE_FAILURES = '1';
@@ -154,7 +150,6 @@ describe('config/env loading', () => {
expect(config.CODEX_WARMUP_CONFIG).toEqual( expect(config.CODEX_WARMUP_CONFIG).toEqual(
expect.objectContaining({ expect.objectContaining({
enabled: true,
prompt: '.', prompt: '.',
model: 'gpt-5.5', model: 'gpt-5.5',
staggerMs: 600000, staggerMs: 600000,

View File

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

View File

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

View File

@@ -14,7 +14,6 @@ import {
STATUS_SHOW_ROOM_DETAILS, STATUS_SHOW_ROOM_DETAILS,
STATUS_SHOW_ROOMS, STATUS_SHOW_ROOMS,
USAGE_DASHBOARD_ENABLED, USAGE_DASHBOARD_ENABLED,
CODEX_WARMUP_CONFIG,
} from './config.js'; } from './config.js';
import { getGlobalFailoverInfo } from './service-routing.js'; import { getGlobalFailoverInfo } from './service-routing.js';
import { import {
@@ -27,7 +26,6 @@ import {
refreshActiveCodexUsage, refreshActiveCodexUsage,
refreshAllCodexAccountUsage, refreshAllCodexAccountUsage,
} from './codex-usage-collector.js'; } from './codex-usage-collector.js';
import { runCodexWarmupCycle } from './codex-warmup.js';
import { import {
composeDashboardContent, composeDashboardContent,
formatElapsed, formatElapsed,
@@ -1060,35 +1058,10 @@ export async function startUnifiedDashboard(
cachedCodexUsageRows = result.rows; cachedCodexUsageRows = result.rows;
if (result.fetchedAt) codexUsageFetchedAt = result.fetchedAt; if (result.fetchedAt) codexUsageFetchedAt = result.fetchedAt;
}; };
const isWarmupRuntimeBusy = () => { void refreshAllCodexAccountUsage().then((r) => {
const groups = opts.roomBindings(); applyCodexRefresh(r);
return opts.queue return refreshActiveCodexUsage().then(applyCodexRefresh);
.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());
// Each poll spawns a Codex app-server; every 5 minutes is plenty for the // 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). // dashboard (it used to run every minute, ~1,440 spawns a day).
setInterval( setInterval(
@@ -1096,15 +1069,9 @@ export async function startUnifiedDashboard(
Math.max(opts.usageUpdateInterval, CODEX_ACTIVE_USAGE_POLL_MS), Math.max(opts.usageUpdateInterval, CODEX_ACTIVE_USAGE_POLL_MS),
); );
setInterval( setInterval(
() => () => void refreshAllCodexAccountUsage().then(applyCodexRefresh),
void refreshAllCodexAccountUsage()
.then(applyCodexRefresh)
.then(() => runCodexWarmup()),
CODEX_FULL_SCAN_INTERVAL, CODEX_FULL_SCAN_INTERVAL,
); );
if (CODEX_WARMUP_CONFIG.enabled) {
setInterval(() => void runCodexWarmup(), CODEX_WARMUP_CONFIG.intervalMs);
}
logger.info( logger.info(
{ {

View File

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

View File

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