coleam00/Archon · error

Isolation resolution stuck in stale_cleaned loop for convers

Error message

Isolation resolution stuck in stale_cleaned loop for conversation ${conversation.id}

What it means

validateAndResolveIsolation detects that retrying isolation resolution after a stale_cleaned environment still produced a stale-cleaned state, meaning the loop guard fired. The engine retried once with a cleared isolation_env_id and still could not obtain a valid isolation environment, so it throws rather than recursing forever.

Source

Thrown at packages/core/src/orchestrator/orchestrator.ts:245

      // Clear stale reference
      await db.updateConversation(conversation.id, { isolation_env_id: null }).catch(e => {
        if (!(toError(e) instanceof ConversationNotFoundError)) {
          getLog().error(
            { err: toError(e), conversationId: conversation.id },
            'stale_isolation_clear_failed'
          );
        }
      });
      const staleMsg = codebase
        ? 'Detected a stale isolated workspace reference and cleared it. Creating a new isolated workspace now.'
        : 'Detected a stale isolated workspace reference and cleared it. Continuing without an isolated workspace.';
      await platform.sendMessage(conversationId, staleMsg).catch(e => {
        getLog().error({ err: toError(e), conversationId }, 'stale_isolation_notice_failed');
      });
      // Retry without existing env (guard against infinite recursion)
      if (!codebase) return { status: 'none', cwd: conversation.cwd ?? '/workspace', env: null };
      if (_isRetry) {
        throw new Error(
          `Isolation resolution stuck in stale_cleaned loop for conversation ${conversation.id}`
        );
      }
      return validateAndResolveIsolation(
        { ...conversation, isolation_env_id: null },
        codebase,
        platform,
        conversationId,
        hints,
        true,
        userId
      );
    }

    case 'none':
      return { status: 'none', cwd: result.cwd, env: null };

    case 'blocked':

View on GitHub (pinned to 0773b97458)

Solutions

  1. Inspect the isolation environment store/records for conversation ${conversation.id} and purge stale entries manually.
  2. Check for concurrent cleanup jobs racing with run dispatch and pause them.
  3. Clear the conversation's isolation_env_id and retry the dispatch fresh.
  4. Verify the isolation provider is healthy and returns non-stale environments.

Example fix

// before (persistence)
conversation.isolation_env_id = "env-stale-123"; // repeatedly resolves to stale_cleaned
// after (repair)
await db.updateConversation(conversation.id, { isolation_env_id: null });
// then re-dispatch
Defensive patterns

Strategy: retry

Validate before calling

const env = await getIsolationEnv(conversation.isolation_env_id);
if (env?.status === 'stale_cleaned') await clearIsolationEnvId(conversation.id);

Try / catch

try {
  await dispatch(conversationId);
} catch (e) {
  if (e.message.includes('stale_cleaned loop')) {
    await purgeStaleIsolationRecords(conversationId);
    await clearIsolationEnvId(conversationId);
    await dispatch(conversationId); // one manual retry after repair
  } else throw e;
}

Prevention

When it happens

Trigger: A conversation carries an isolation_env_id whose environment is reported stale/cleaned; the retry path clears the id and re-resolves, but validation still fails with stale_cleaned and _isRetry is true — e.g. the environment store keeps returning a stale status for the freshly resolved env.

Common situations: A stale environment record that the store fails to purge or replace; a misbehaving isolation provider marking new envs as cleaned; concurrent cleanup jobs racing with resolution; corrupted isolation env state in the database.

Related errors


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