{"record":{"id":"05f6127a3b8505b0","repo":"langgenius/dify","slug":"conversation-completed-05f612","errorCode":"conversation_completed","errorMessage":"The conversation has ended. Please start a new conversation.","messagePattern":"The conversation has ended\\. Please start a new conversation\\.","errorType":"error_code","errorClass":"ConversationCompletedError","httpStatus":400,"severity":"warning","filePath":"api/controllers/console/app/workflow.py","lineNumber":728,"sourceCode":"        external_trace_id = get_external_trace_id(request)\n        if external_trace_id:\n            args[\"external_trace_id\"] = external_trace_id\n\n        try:\n            response = AppGenerateService.generate(\n                session=session,\n                app_model=app_model,\n                user=current_user,\n                args=args,\n                invoke_from=InvokeFrom.DEBUGGER,\n                streaming=True,\n            )\n\n            return helper.compact_generate_response(response)\n        except services.errors.conversation.ConversationNotExistsError:\n            raise NotFound(\"Conversation Not Exists.\")\n        except services.errors.conversation.ConversationCompletedError:\n            raise ConversationCompletedError()\n        except InvokeRateLimitError as ex:\n            raise InvokeRateLimitHttpError(ex.description)\n        except ValueError as e:\n            raise e\n        except Exception:\n            logger.exception(\"internal server error.\")\n            raise InternalServerError()\n\n\n@console_ns.route(\"/apps/<uuid:app_id>/advanced-chat/workflows/draft/iteration/nodes/<string:node_id>/run\")\nclass AdvancedChatDraftRunIterationNodeApi(Resource):\n    @console_ns.doc(\"run_advanced_chat_draft_iteration_node\")\n    @console_ns.doc(description=\"Run draft workflow iteration node for advanced chat\")\n    @console_ns.doc(params={\"app_id\": \"Application ID\", \"node_id\": \"Node ID\"})\n    @console_ns.expect(console_ns.models[IterationNodeRunPayload.__name__])\n    @console_ns.response(\n        200,\n        \"Iteration node run started successfully\",","sourceCodeStart":710,"sourceCodeEnd":746,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/app/workflow.py#L710-L746","documentation":"Raised as ConversationCompletedError in AdvancedChatDraftWorkflowRunApi.post when AppGenerateService.generate raises services.errors.conversation.ConversationCompletedError (api/controllers/console/app/workflow.py:727-728). The referenced conversation has reached a terminal/completed state and no further messages can be appended to it; a new conversation must be started.","triggerScenarios":"POSTing a draft run against a conversation_id that is marked completed/ended. The service refuses to add turns to a finished conversation.","commonSituations":"End-of-conversation triggered by a workflow terminator node; explicit 'end conversation' action; conversation auto-completed by a max-turns rule; client reusing a conversation the user already finished.","solutions":["Start a new conversation (send conversation_id: null) to continue the session.","If the completion was unintended, review the workflow terminator/end conditions that marked the conversation completed.","Clear the front-end conversation_id once the conversation is completed so subsequent runs start a new thread."],"exampleFix":"// before: reusing a completed conversation\n{query:'hi', conversation_id: completedId}\n// after: begin a new conversation\n{query:'hi', conversation_id: null}","handlingStrategy":"validation","validationCode":"// Check conversation status before running; start new if completed\nconst conv = await getConversation(appId, payload.conversation_id)\nif (conv?.status === 'completed') payload.conversation_id = null\nawait runDraft(appId, payload)","typeGuard":null,"tryCatchPattern":"try {\n  return await runDraft(appId, payload)\n} catch (e) {\n  if (e.code === 'conversation_completed') {\n    payload.conversation_id = null; return runDraft(appId, payload)\n  }\n  throw e\n}","preventionTips":["Clear the conversation_id once the user finishes a thread.","Review workflow terminator conditions if conversations complete unexpectedly.","On completion, start a new conversation rather than reusing the id."],"tags":["workflow","advanced-chat","conversation","completed","api"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}