jackwener/OpenCLI · error · CommandExecutionError

ChatGPT deep-research-result conversation mismatch: expected

Error message

ChatGPT deep-research-result conversation mismatch: expected ${conversationId}, current page is ${currentConversationId}.

What it means

After a Deep Research run the library compares the conversation id parsed from the current page/iframe URL with the conversationId that was requested. A mismatch means the page moved to a different conversation, so results could be attributed to the wrong thread; the library throws instead of extracting.

Source

Thrown at clis/chatgpt/utils.js:1841

        return {
            url: window.location.href,
            title: document.title,
            iframes,
            deepResearchIframe: matched,
        };
    })()`)), 'chatgpt deep research iframe state');

    const generating = await isGenerating(page).catch(() => false);
    const iframe = iframeState.deepResearchIframe;
    const currentConversationId = conversationIdFromUrl(iframeState.url);
    if (conversationId) {
        if (!currentConversationId) {
            throw new CommandExecutionError(
                `ChatGPT deep-research-result did not stay on requested conversation ${conversationId}.`,
            );
        }
        if (currentConversationId !== conversationId) {
            throw new CommandExecutionError(
                `ChatGPT deep-research-result conversation mismatch: expected ${conversationId}, current page is ${currentConversationId}.`,
            );
        }
    }
    let progressCandidate = null;
    const diagnostics = {
        iframeCount: Array.isArray(iframeState.iframes) ? iframeState.iframes.length : 0,
        iframe: iframe ? {
            index: iframe.index,
            title: iframe.title,
            src: iframe.src,
            visible: iframe.visible,
            width: iframe.width,
            height: iframe.height,
            accessible: iframe.accessible,
            accessError: iframe.accessError || '',
        } : null,
        methodsTried: ['main-document-iframe'],

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use the conversation id ChatGPT actually created (read it from the URL after submission) instead of assuming the pre-request id
  2. Ensure only one automation drives the tab during the wait
  3. Retry the request in a fresh conversation and track the returned conversation id
  4. If forks are expected, treat the new id as authoritative and re-extract from that conversation
Defensive patterns

Strategy: try-catch

Validate before calling

const current = conversationIdFromUrl(await currentChatGPTUrl(page));
if (current && current !== conversationId) console.warn('conversation forked or navigated:', current);

Type guard

function isSameConversation(currentId, expectedId) { return typeof currentId === 'string' && currentId === expectedId; }

Try / catch

try {
  await waitForChatGPTDeepResearchResult(page, { conversationId });
} catch (e) {
  const m = String(e.message).match(/conversation mismatch: expected (\S+), current page is (\S+)/);
  if (m) {
    // adopt m[2] as the new authoritative conversation id and re-extract
  } else throw e;
}

Prevention

When it happens

Trigger: During waitForDeepResearchResult with a known conversationId, conversationIdFromUrl(iframeState.url) returns a different id — e.g. ChatGPT started a brand-new conversation, the user/automation navigated to another thread, or a follow-up prompt spawned a new conversation id.

Common situations: Submitting a deep-research prompt in an existing conversation but ChatGPT forks a new conversation; parallel automation scripts sharing one browser tab; clicking an old link that navigates mid-wait.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/102945665f2be4c6. Report an issue: GitHub.