{"record":{"id":"bd5dfb99383ac445","repo":"bytedance/deer-flow","slug":"thread-has-a-run-in-flight-compact-after-the-run","errorCode":null,"errorMessage":"Thread has a run in flight. Compact after the run finishes.","messagePattern":"Thread has a run in flight\\. Compact after the run finishes\\.","errorType":"http","errorClass":"HTTPException","httpStatus":409,"severity":"error","filePath":"backend/app/gateway/routers/threads.py","lineNumber":1174,"sourceCode":"            thread_id=thread_id,\n            as_node=\"manual_compaction\",\n        )\n    except _CHECKPOINT_MODE_ERRORS as exc:\n        raise _checkpoint_mode_http_error(exc, thread_id) from exc\n    keep = body.keep.to_tuple() if body.keep is not None else None\n    try:\n        async with reserve_checkpoint_write(request, thread_id, user_id=get_effective_user_id()):\n            result = await compact_thread_context(\n                accessor,\n                thread_id,\n                keep=keep,\n                force=body.force,\n                user_id=get_effective_user_id(),\n                agent_name=body.agent_name,\n                model_name=body.model_name,\n            )\n    except ConflictError:\n        raise HTTPException(status_code=409, detail=\"Thread has a run in flight. Compact after the run finishes.\") from None\n    except _CHECKPOINT_MODE_ERRORS as exc:\n        raise _checkpoint_mode_http_error(exc, thread_id) from exc\n    except ContextCompactionDisabled:\n        raise HTTPException(status_code=409, detail=\"Context compaction is disabled.\") from None\n    except ContextCompactionFailed:\n        raise HTTPException(status_code=500, detail=\"Failed to compact thread context.\") from None\n    except LookupError:\n        raise HTTPException(status_code=404, detail=f\"Thread {thread_id} not found\") from None\n    except HTTPException:\n        raise\n    except Exception:\n        logger.exception(\"Failed to compact thread %s\", sanitize_log_param(thread_id))\n        raise HTTPException(status_code=500, detail=\"Failed to compact thread context.\") from None\n    return _thread_compact_response(result)\n\n\n# ---------------------------------------------------------------------------\n@router.get(\"/{thread_id}/state\", response_model=ThreadStateResponse)","sourceCodeStart":1156,"sourceCodeEnd":1192,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/threads.py#L1156-L1192","documentation":"Error \"Thread has a run in flight. Compact after the run finishes.\" thrown in bytedance/deer-flow.","triggerScenarios":"Thrown at backend/app/gateway/routers/threads.py:1174 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for the in-flight run to finish before compacting.","Cancel the active run first if compaction is urgent."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}