langgenius/dify · warning · ConversationCompletedError
conversation_completed
conversation_completed
Error message
The conversation has ended. Please start a new conversation.
What it means
Raised by CompletionApi.post (HTTP 400, error_code 'conversation_completed') when AppGenerateService.generate raises services.errors.conversation.ConversationCompletedError. The targeted conversation has been explicitly ended/completed and will no longer accept new messages. This is a domain-level lifecycle guard from the conversation service, re-thrown here as an HTTP error.
Source
Thrown at api/controllers/console/explore/completion.py:129
installed_app.last_used_at = naive_utc_now()
db.session.commit()
try:
response = AppGenerateService.generate(
session=session,
app_model=app_model,
user=current_user,
args=args,
invoke_from=InvokeFrom.EXPLORE,
streaming=streaming,
)
# response-contract:ignore compact_generate_response
return helper.compact_generate_response(response)
except services.errors.conversation.ConversationNotExistsError:
raise NotFound("Conversation Not Exists.")
except services.errors.conversation.ConversationCompletedError:
raise ConversationCompletedError()
except services.errors.app_model_config.AppModelConfigBrokenError:
logger.exception("App model config broken.")
raise AppUnavailableError()
except ProviderTokenNotInitError as ex:
raise ProviderNotInitializeError(ex.description)
except QuotaExceededError:
raise ProviderQuotaExceededError()
except ModelCurrentlyNotSupportError:
raise ProviderModelCurrentlyNotSupportError()
except InvokeError as e:
raise CompletionRequestError(e.description)
except ValueError as e:
raise e
except Exception:
logger.exception("internal server error.")
raise InternalServerError()
View on GitHub (pinned to ef8544b173)
Solutions
- Start a brand-new completion request without the completed conversation reference.
- On the client, treat this error code as a signal to reset the conversation UI.
- Review whether an explicit stop or a TTL policy closed the conversation.
- If conversations should remain open, check the app's conversation lifecycle settings.
Example fix
// before: reusing a conversation handle after completion
if (err.code === 'conversation_completed') { retryWithSameConversation() }
// after: start fresh when the server says the conversation ended
if (err.code === 'conversation_completed') { startNewConversation() } Defensive patterns
Strategy: try-catch
Validate before calling
// For completion apps there is usually no conversation to check; if you carry one,
// verify it is not completed before posting. Requires a conversation-status API if available.
// Otherwise, the safest validation is simply to start a new completion without state.
if (carriedConversationId) { /* completion apps are stateless — prefer not sending it */ } Type guard
function isConversationUsable(conv) {
return Boolean(conv && conv.status !== 'completed' && conv.status !== 'ended');
} Try / catch
try {
await postCompletion(id, payload);
} catch (err) {
if (err.code === 'conversation_completed') {
// reset state and start fresh; do not retry the same conversation
startNewCompletion();
} else { throw err; }
} Prevention
- Treat 'conversation_completed' as terminal for that thread; never retry it.
- Reset client-side conversation state whenever this code arrives.
- Review app conversation lifecycle settings if completion is unexpected.
When it happens
Trigger: POST /console/installed-apps/<id>/completion-messages carrying args that reference a conversation already marked completed. The shared generate pipeline detects the conversation's completed state and aborts before invoking the model.
Common situations: Client continues to send to a conversation the server already closed (timeout, explicit stop, or completion); a long-lived client did not refresh after the conversation ended; completion app was wired to a conversation that a background job closed.
Related errors
- Conversation Not Exists.
- conversation_completed
- app_unavailable
- not_completion_app
- provider_not_initialize
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/aba14311337c6deb.
Report an issue: GitHub.