{"record":{"id":"62a2cdccec4e911e","repo":"bytedance/deer-flow","slug":"could-not-locate-target-user-message-in-recent-che","errorCode":null,"errorMessage":"Could not locate target user message in recent checkpoint history (limit={REGENERATE_HISTORY_SCAN_LIMIT})","messagePattern":"Could not locate target user message in recent checkpoint history \\(limit=(.+?)\\)","errorType":"http","errorClass":"HTTPException","httpStatus":409,"severity":"warning","filePath":"backend/app/gateway/routers/thread_runs.py","lineNumber":572,"sourceCode":"        raise HTTPException(status_code=500, detail=\"Failed to inspect checkpoint history\") from exc\n\n    previous_checkpoint, target_found = find_checkpoint_before_message_chronologically(raw_checkpoints, human_message_id)\n    if target_found:\n        if previous_checkpoint is None:\n            raise HTTPException(\n                status_code=409,\n                detail=_MISSING_REGENERATE_BASE_DETAIL,\n            )\n        return previous_checkpoint\n\n    if len(checkpoints) >= REGENERATE_HISTORY_SCAN_LIMIT:\n        logger.warning(\n            \"Could not locate target user message %s in recent checkpoint history for thread %s (limit=%s)\",\n            human_message_id,\n            thread_id,\n            REGENERATE_HISTORY_SCAN_LIMIT,\n        )\n    raise HTTPException(\n        status_code=409,\n        detail=(f\"Could not locate target user message in recent checkpoint history (limit={REGENERATE_HISTORY_SCAN_LIMIT})\"),\n    )\n\n\ndef _run_status_value(record: Any) -> str | None:\n    status = getattr(record, \"status\", None)\n    if isinstance(status, RunStatus):\n        return status.value\n    return str(status) if status is not None else None\n\n\nasync def _require_successful_source_run(thread_id: str, run_id: str, request: Request) -> RunRecord:\n    run_mgr = get_run_manager(request)\n    user_id = await get_current_user(request)\n    record = await run_mgr.get(run_id, user_id=user_id)\n    if record is None:\n        # The run-event journal is the authoritative lookup above. This fallback","sourceCodeStart":554,"sourceCodeEnd":590,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/thread_runs.py#L554-L590","documentation":"Raised in _find_base_checkpoint_before_human (HTTP 409) when the target user message id cannot be located anywhere in the scanned checkpoint history (bounded by REGENERATE_HISTORY_SCAN_LIMIT = 200 non-duration-only checkpoints). The chronological fallback could not even find the message, so no base checkpoint can be chosen.","triggerScenarios":"Regenerating a message older than the 200-checkpoint scan window; the human message never reached a checkpoint (interrupted before first checkpoint write); message id that exists only in the live stream, not in any checkpointed state.","commonSituations":"Very long threads (each graph step writes a checkpoint, so 200 covers few turns); regenerate targeting a message whose turn was aborted pre-checkpoint; stale client id.","solutions":["Regenerate the latest turn instead of an old one that fell outside the 200-checkpoint window.","Verify the message id exists in the thread's checkpointed state (GET thread state and search messages).","If long threads are the norm, raise REGENERATE_HISTORY_SCAN_LIMIT in the backend and restart the Gateway.","For messages that never checkpointed (aborted turns), resend the user message as a new run."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"const state = await getThreadState(threadId);\nconst hasMsg = state.messages.some(m => m.id === humanMessageId);\nif (!hasMsg) { /* id stale or beyond history; refresh */ }","typeGuard":null,"tryCatchPattern":"try { await regeneratePrepare(threadId, messageId); } catch (e) { if (e.status === 409 && /recent checkpoint history/.test(e.detail)) { await refreshAndRegenerateLatest(threadId); } else throw e; }","preventionTips":["Regenerate only the latest turn in long threads","Keep REGENERATE_HISTORY_SCAN_LIMIT aligned with thread depth","Refresh ids from thread state before calling"],"tags":["regenerate","checkpoint","history-limit","http-409"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}