coleam00/Archon · error
Failed to get active workflow run: ${err.message}
Error message
Failed to get active workflow run: ${err.message} What it means
getActiveWorkflowRun looks up the non-terminal workflow run for a conversation and normalizes the row. Any pool.query failure is logged (db.workflow_run_get_active_failed) and rethrown with this message. It signals the DB access layer failed, not that no active run exists (that returns null).
Source
Thrown at packages/core/src/db/workflows.ts:539
getLog().error({ err }, 'db.workflow_run_get_status_failed');
throw new Error(`Failed to get workflow run status: ${err.message}`);
}
}
export async function getActiveWorkflowRun(conversationId: string): Promise<WorkflowRun | null> {
try {
const result = await pool.query<WorkflowRun>(
`SELECT * FROM remote_agent_workflow_runs
WHERE (conversation_id = $1 OR parent_conversation_id = $2) AND status = 'running'
ORDER BY started_at DESC LIMIT 1`,
[conversationId, conversationId]
);
const row = result.rows[0];
return row ? normalizeWorkflowRun(row) : null;
} catch (error) {
const err = error as Error;
getLog().error({ err }, 'db.workflow_run_get_active_failed');
throw new Error(`Failed to get active workflow run: ${err.message}`);
}
}
/**
* Find a paused workflow run for a conversation (or its parent).
* Used by the message handler to give the chat agent the open approval gate as
* context for the turn (#2565).
* Non-throwing: returns null on DB error so the caller can fall through to normal routing.
*/
export async function getPausedWorkflowRun(conversationId: string): Promise<WorkflowRun | null> {
try {
const result = await pool.query<WorkflowRun>(
`SELECT * FROM remote_agent_workflow_runs
WHERE (conversation_id = $1 OR parent_conversation_id = $2) AND status = 'paused'
ORDER BY started_at DESC LIMIT 1`,
[conversationId, conversationId]
);
const row = result.rows[0];View on GitHub (pinned to 0773b97458)
Solutions
- Read the wrapped err.message / log event db.workflow_run_get_active_failed for the driver-level cause.
- Confirm migrations have created workflow_runs in the target database.
- Check pool health and connection limits (max_connections, pool size config).
- Restore DB connectivity, then retry; the call is read-only and safe to repeat.
Example fix
// before
const run = await getActiveWorkflowRun(conversationId);
// after
let run: WorkflowRun | null = null;
try {
run = await getActiveWorkflowRun(conversationId);
} catch (err) {
getLog().error({ err }, 'chat.active_run_lookup_failed');
} Defensive patterns
Strategy: try-catch
Validate before calling
const ping = await pool.query('SELECT 1'); // cheap reachability check Type guard
function isActiveRunLookupError(err: unknown): err is Error {
return err instanceof Error && err.message.startsWith('Failed to get active workflow run:');
} Try / catch
try {
const run = await getActiveWorkflowRun(conversationId);
} catch (err) {
// Distinguish 'DB failed' (throw) from 'no run' (null) — only the wrapper throws.
reportDbFailure(err);
throw err;
} Prevention
- Treat null return (no active run) as normal; only catch for DB failures.
- Apply schema migrations in your deploy pipeline before swapping binaries.
- Monitor pool wait times to catch saturation early.
- Retry read-only lookups on transient connection errors.
When it happens
Trigger: Calling getActiveWorkflowRun(conversationId) while the DB is down, the workflow_runs schema is absent or stale, the connection pool is exhausted, or a driver-level timeout fires on the SELECT ... WHERE conversation_id = $1 AND status NOT IN terminal query.
Common situations: DB migration not applied before app start; Postgres max_connections reached; network partition between app and database; wrong environment pointing at a database without the workflow tables.
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
- Failed to get workflow run status: ${err.message}
- Corrupt commands JSON for codebase ${id}: unable to parse st
- Codebase ${codebaseId} not found
- Conversation not found: ${conversationId}
- Resumable run snapshot changed during reset (expected ${Stri
AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01).
Data as JSON: /api/errors/7501d090312f4340.
Report an issue: GitHub.