Yeachan-Heo/oh-my-codex · error · Error
autoresearch_active_run_exists
autoresearch_active_run_exists
Error message
autoresearch_active_run_exists:${state.run_id} What it means
assertAutoresearchLockAvailable throws (code autoresearch_active_run_exists) when the active-run state file records an active run with a run_id. Autoresearch enforces a single active run per project root to prevent concurrent runs from corrupting shared worktrees and ledgers.
Source
Thrown at src/autoresearch/runtime.ts:291
async function readJsonFile<T>(filePath: string): Promise<T> {
return JSON.parse(await readFile(filePath, 'utf-8')) as T;
}
async function readActiveRunState(projectRoot: string): Promise<AutoresearchActiveRunState | null> {
const file = activeRunStateFile(projectRoot);
if (!existsSync(file)) return null;
return readJsonFile<AutoresearchActiveRunState>(file);
}
async function writeActiveRunState(projectRoot: string, value: AutoresearchActiveRunState): Promise<void> {
await writeJsonFile(activeRunStateFile(projectRoot), value);
}
async function assertAutoresearchLockAvailable(projectRoot: string): Promise<void> {
const state = await readActiveRunState(projectRoot);
if (state?.active && state.run_id) {
throw new Error(`autoresearch_active_run_exists:${state.run_id}`);
}
}
async function activateAutoresearchRun(manifest: AutoresearchRunManifest): Promise<void> {
await writeActiveRunState(manifest.repo_root, {
schema_version: 1,
active: true,
run_id: manifest.run_id,
mission_slug: manifest.mission_slug,
repo_root: manifest.repo_root,
worktree_path: manifest.worktree_path,
status: manifest.status,
updated_at: nowIso(),
});
}
async function deactivateAutoresearchRun(manifest: AutoresearchRunManifest): Promise<void> {
const previous = await readActiveRunState(manifest.repo_root);View on GitHub (pinned to 3ad79a8a6f)
Solutions
- Check if a run with that run_id is genuinely active (process list / CI logs); if so, wait for it or cancel it
- If the previous run crashed, clear the active run state through the supported finalize/cancel command for the run_id in the message
- Inspect the active-run state file under projectRoot/.omx and verify before manually clearing it
- Avoid launching concurrent autoresearch runs against the same repo root; serialize them in your pipeline
Defensive patterns
Strategy: validation
Validate before calling
// before preparing/resuming, inspect the active-run state file
import { readFile } from 'node:fs/promises';
try {
const s = JSON.parse(await readFile(join(repoRoot, '.omx', 'active-run.json'), 'utf-8'));
if (s?.active && s.run_id) throw new Error(`Run ${s.run_id} still active`);
} catch (e) { if ((e as NodeJS.ErrnoException).code !== 'ENOENT') throw e; } Type guard
function isActiveRunState(v: unknown): v is { active: true; run_id: string } {
return typeof v === 'object' && v !== null && (v as any).active === true && typeof (v as any).run_id === 'string';
} Try / catch
try { await prepareAutoresearchRuntime(repoRoot, task); }
catch (e) { if (e instanceof Error && e.message.startsWith('autoresearch_active_run_exists')) { const id = e.message.split(':')[1]; /* cancel/finalize run id, then retry */ } throw e; } Prevention
- Serialize autoresearch runs per repo root (one at a time)
- Always finalize or cancel runs, even on error paths (try/finally)
- After crashes, clear active-run state via the supported recovery command before restarting
When it happens
Trigger: Calling prepareAutoresearchRuntime or resumeAutoresearchRuntime while another run is already active — including a stale lock left behind by a crashed process that never finalized its run state.
Common situations: Running two autoresearch commands in parallel terminals, a previous run killed by SIGKILL/OOM without cleanup, CI retrying a job while the first is still active, or a stale .omx active-run state file after an interrupted session.
Related errors
- autoresearch_active_mode_exists
- question_not_open
- Timed out acquiring task claim lock for ${teamName}/${taskId
- No autoresearch-goal mission found at ${repoRelative(cwd, pa
- Invalid autoresearch-goal mission at ${repoRelative(cwd, pat
AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27).
Data as JSON: /api/errors/f5256a71275ea31b.
Report an issue: GitHub.