{"record":{"id":"f231b0321c6e012f","repo":"bytedance/deer-flow","slug":"failed-to-compact-thread-context","errorCode":null,"errorMessage":"Failed to compact thread context.","messagePattern":"Failed to compact thread context\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"backend/app/gateway/routers/threads.py","lineNumber":1180,"sourceCode":"    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)\n@require_permission(\"threads\", \"read\", owner_check=True)\nasync def get_thread_state(thread_id: ThreadId, request: Request) -> ThreadStateResponse:\n    \"\"\"Get the latest materialized graph state for a thread.\"\"\"\n    # Resolve through the thread's assistant so custom middleware channels\n    # appear in the response instead of being dropped by the default schema.\n    try:","sourceCodeStart":1162,"sourceCodeEnd":1198,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/threads.py#L1162-L1198","documentation":"Error \"Failed to compact thread context.\" thrown in bytedance/deer-flow.","triggerScenarios":"Thrown at backend/app/gateway/routers/threads.py:1180 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the Gateway logs for the compaction error (often a model or token-limit issue).","Verify a summarization-capable model is configured, then retry."],"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-15T17:31:12.345Z"}