{"record":{"id":"4b6869df8836c93c","repo":"bytedance/deer-flow","slug":"thread-has-a-run-in-flight-clear-the-goal-after-t","errorCode":null,"errorMessage":"Thread has a run in flight. Clear the goal after the run finishes.","messagePattern":"Thread has a run in flight\\. Clear the goal after the run finishes\\.","errorType":"http","errorClass":"HTTPException","httpStatus":409,"severity":"error","filePath":"backend/app/gateway/routers/threads.py","lineNumber":1123,"sourceCode":"        raise HTTPException(status_code=409, detail=\"Thread has a run in flight. Set the goal after the run finishes.\") from None\n    except HTTPException:\n        raise\n    except Exception:\n        logger.exception(\"Failed to set goal for thread %s\", sanitize_log_param(thread_id))\n        raise HTTPException(status_code=500, detail=\"Failed to set thread goal\") from None\n    return ThreadGoalResponse(goal=goal)\n\n\n@router.delete(\"/{thread_id}/goal\", response_model=ThreadGoalResponse)\n@require_permission(\"threads\", \"write\", owner_check=True)\nasync def clear_thread_goal(thread_id: ThreadId, request: Request) -> ThreadGoalResponse:\n    \"\"\"Clear the active goal for a thread.\"\"\"\n    checkpointer = get_checkpointer(request)\n    try:\n        async with reserve_checkpoint_write(request, thread_id, user_id=get_effective_user_id()):\n            await write_thread_goal(checkpointer, thread_id, None, as_node=\"goal\")\n    except ConflictError:\n        raise HTTPException(status_code=409, detail=\"Thread has a run in flight. Clear the goal after the run finishes.\") from None\n    except LookupError:\n        return ThreadGoalResponse(goal=None)\n    except Exception:\n        logger.exception(\"Failed to clear goal for thread %s\", sanitize_log_param(thread_id))\n        raise HTTPException(status_code=500, detail=\"Failed to clear thread goal\") from None\n    return ThreadGoalResponse(goal=None)\n\n\ndef _thread_compact_response(result: ThreadCompactionResult) -> ThreadCompactResponse:\n    return ThreadCompactResponse(\n        thread_id=result.thread_id,\n        compacted=result.compacted,\n        reason=result.reason,\n        removed_message_count=result.removed_message_count,\n        preserved_message_count=result.preserved_message_count,\n        summary_updated=result.summary_updated,\n        checkpoint_id=result.checkpoint_id,\n        total_tokens=result.total_tokens,","sourceCodeStart":1105,"sourceCodeEnd":1141,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/app/gateway/routers/threads.py#L1105-L1141","documentation":"Error \"Thread has a run in flight. Clear the goal after the run finishes.\" thrown in bytedance/deer-flow.","triggerScenarios":"Thrown at backend/app/gateway/routers/threads.py:1123 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for the in-flight run to finish, then clear the goal.","Cancel the active run first if you need to clear the goal immediately."],"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"}