coleam00/Archon · error

Failed to find resumable run by parent conversation: ${err.m

Error message

Failed to find resumable run by parent conversation: ${err.message}

What it means

findResumableRunByParentConversation finds a failed/paused run for a workflow scoped to a parent conversation and codebase, used to detect approved runs needing foreground resume. DB errors are logged (db.workflow_run_find_resumable_by_parent_failed) and rethrown wrapped in this message. Absence of a run is a null return, not an error.

Source

Thrown at packages/core/src/db/workflows.ts:879

    const result = await pool.query<WorkflowRun>(
      `SELECT * FROM remote_agent_workflow_runs
       WHERE workflow_name = $1
         AND parent_conversation_id = $2
         AND codebase_id = $3
         AND status IN ('failed', 'paused')
       ORDER BY CASE WHEN status = 'paused' THEN 0 ELSE 1 END, started_at DESC
       LIMIT 1`,
      [workflowName, parentConversationId, codebaseId]
    );
    const row = result.rows[0];
    return row ? normalizeWorkflowRun(row) : null;
  } catch (error) {
    const err = error as Error;
    getLog().error(
      { err, workflowName, parentConversationId, codebaseId },
      'db.workflow_run_find_resumable_by_parent_failed'
    );
    throw new Error(`Failed to find resumable run by parent conversation: ${err.message}`);
  }
}

export async function resumeWorkflowRun(
  id: string,
  cursor?: WorkflowResumeCursor
): Promise<WorkflowRun> {
  const dialect = getDialect();

  // Split into UPDATE + SELECT to support both PostgreSQL and SQLite
  // (SQLite does not support RETURNING on UPDATE statements)
  // Each phase has its own try/catch to avoid string-sniffing own errors in a shared catch.
  let updateResult: { rowCount: number };
  try {
    // Refresh started_at to NOW so the resumed row competes fairly with
    // currently-active rows in getActiveWorkflowRunByPath's older-wins
    // tiebreaker. Without this, a resumed row carries its original
    // (potentially hours-old) started_at and would sort ahead of any

View on GitHub (pinned to 0773b97458)

Solutions

  1. Inspect the wrapped err.message for schema or connectivity clues.
  2. Apply schema upgrades so parent_conversation_id and codebase_id exist on workflow_runs.
  3. Restore connectivity and retry; the lookup is read-only and safe to repeat.

Example fix

// before
const run = await findResumableRunByParentConversation({ workflowName, parentConversationId, codebaseId });
// after
try {
  const run = await findResumableRunByParentConversation({ workflowName, parentConversationId, codebaseId });
  if (run) void resumeForeground(run);
} catch (err) {
  getLog().error({ err }, 'foreground_resume_detection_failed');
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify scoped columns exist before relying on foreground-resume detection
const check = await pool.query(
  `SELECT column_name FROM information_schema.columns WHERE table_name='workflow_runs' AND column_name IN ('parent_conversation_id','codebase_id')`
);
if (check.rowCount < 2) throw new Error('schema upgrade required for parent-conversation resume');

Type guard

function isParentResumeLookupError(err: unknown): err is Error {
  return err instanceof Error && err.message.startsWith('Failed to find resumable run by parent conversation:');
}

Try / catch

try {
  const run = await findResumableRunByParentConversation({ workflowName, parentConversationId, codebaseId });
} catch (err) {
  // A failed lookup must not silently skip resume — surface it to the operator.
  getLog().error({ err }, 'foreground_resume_check_failed');
  throw err;
}

Prevention

When it happens

Trigger: Calling findResumableRunByParentConversation({ workflowName, parentConversationId, codebaseId }) while the DB is down, the schema lacks the parent_conversation_id/codebase_id columns, or the SELECT fails on permissions/timeout.

Common situations: Database opened by an older binary before those columns were added; connection reset during message handling; wrong database selected in a staging environment.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01). Data as JSON: /api/errors/68a7791be2e54191. Report an issue: GitHub.