AssertionError: Invalid app mode: agent

未关闭
#42,332 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
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 分钟
30 天内合并 PR
611

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

langgenius/dify 的其他 Issue

查看 langgenius/dify 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。