AssertionError: Invalid app mode: agent
还没有人认领这个 Issue。
评估
调研方向
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 内容生成。
描述
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
❌ Actual Behavior
No response
- 主要语言
- TypeScript
- 星标
- 157k
- 派生
- 24.7k
- 平均合并
- 22 小时 32 分钟
- 30 天内合并 PR
- 611
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
langgenius/dify 的其他 Issue
-
Annotation Reply: a stored score threshold of 0.0 is silently replaced with 1, disabling the feature 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
langgenius/dify#42639 · 1 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 70/100
langgenius/dify#42468 · 1 条评论 · 1 个 reaction ·
-
🐞 bug
难度 2/5 1-3 小时 新手友好度 86/100
langgenius/dify#42446 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 88/100
langgenius/dify#42355 · 1 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 88/100
langgenius/dify#42350 · 1 条评论 · 1 个 reaction ·
相似的 Issue
-
calcite-components needs triage refactor
难度 2/5 1-3 小时 新手友好度 75/100
Esri/calcite-design-system#15203 ·
-
难度 2/5 1-3 小时 新手友好度 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 78/100
Automattic/studio#4908 ·
-
难度 2/5 1-3 小时 新手友好度 90/100