AssertionError: Invalid app mode: agent

オープン
#42,332 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
64/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
flask, python
領域
api, backend

調査の方向性

Start in api/core/memory/token_buffer_memory.py at _build_prompt_message_with_files, then trace the suggested-questions request through api/services/message_service.py and api/controllers/web/message.py. Reproduce the GET /api/messages/{id}/suggested-questions failure for a conversation whose mode is agent, and verify that the request no longer raises AssertionError or returns a 500.

索引モデルが issue の本文から書いたものです。

説明

🐞 bug
Self Checks
  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.
Dify version

1.17.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

2026-09-16 06:00:47.779 ERROR [Dummy-1119] [message.py:265] 44638e7c1e425f05bd1acc755e9c74ff - internal server error.
Traceback (most recent call last):
File "/app/api/controllers/web/message.py", line 242, in get
questions = MessageService.get_suggested_questions_after_answer(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/services/message_service.py", line 426, in get_suggested_questions_after_answer
histories = memory.get_history_prompt_text(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/memory/token_buffer_memory.py", line 243, in get_history_prompt_text
prompt_messages = self.get_history_prompt_messages(max_token_limit=max_token_limit, message_limit=message_limit)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/memory/token_buffer_memory.py", line 189, in get_history_prompt_messages
user_prompt_message = self._build_prompt_message_with_files(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/memory/token_buffer_memory.py", line 86, in _build_prompt_message_with_files
raise AssertionError(f"Invalid app mode: {self.conversation.mode}")
AssertionError: Invalid app mode: agent
2026-09-16 06:00:47.780 ERROR [Dummy-1119] [app.py:875] 44638e7c1e425f05bd1acc755e9c74ff - Exception on /api/messages/dda45706-a869-4ee6-a013-7f6526a03dd0/suggested-questions [GET]
Traceback (most recent call last):
File "/app/api/controllers/web/message.py", line 242, in get
questions = MessageService.get_suggested_questions_after_answer(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/services/message_service.py", line 426, in get_suggested_questions_after_answer
histories = memory.get_history_prompt_text(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/memory/token_buffer_memory.py", line 243, in get_history_prompt_text
prompt_messages = self.get_history_prompt_messages(max_token_limit=max_token_limit, message_limit=message_limit)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/memory/token_buffer_memory.py", line 189, in get_history_prompt_messages
user_prompt_message = self._build_prompt_message_with_files(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/core/memory/token_buffer_memory.py", line 86, in _build_prompt_message_with_files
raise AssertionError(f"Invalid app mode: {self.conversation.mode}")
AssertionError: Invalid app mode: agent

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/api.py", line 404, in wrapper
resp = resource(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view
return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/resource.py", line 41, in dispatch_request
resp = meth(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/app/api/controllers/web/wraps.py", line 38, in decorated
return view(app_model, end_user, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/api/controllers/web/message.py", line 266, in get
raise InternalServerError()
werkzeug.exceptions.InternalServerError: 500 Internal Server Error: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
2026-09-16 06:00:48.685 INFO [Dummy-1120] [_client.py:1025] c1bdbd4995a851b7801963bcecc1168c - HTTP Request: POST http://plugin_daemon:5002/plugin/81dee897-d63d-4dc7-8072-6f7fb3338da3/dispatch/llm/invoke "HTTP/1.1 200 OK"

✔️ Expected Behavior
Image
❌ Actual Behavior

No response

主要言語
TypeScript
スター
157k
フォーク
24.7k
平均マージ
22時間 32分
マージ済み PR(30日)
611

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

langgenius/dify のほかの issue

langgenius/dify の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。