Skip to content

[Bug] 企微机器人对接MK嵌套智能体问答出现'NoneType' object has no attribute 'write_context' #5108

@yuxiaobin

Description

@yuxiaobin

Contact Information

MK微信群@俞晓斌

MaxKB Version

v2.7.1(专业版)

Problem Description

一个大智能体嵌套多个小智能体,大智能体对接的企微机器人。
在网页端对话,正常回答。
企微端发起对话,其他智能体都可以,唯独有一个出错

Steps to Reproduce

企微对话-意图识别-小智能体回答

嵌套多个,其中一个100%复现

网页端对话

相同的问题,可以回答

The expected correct result

No response

Related log output

2026-04-14 12:58:36 [views INFO] Received message: {'msgid': '315ce97febd772e066845c140f8d94ba', 'aibotid': 'aibfKP7VKlvI_mX-39ks5BKofkkb6lba4P4', 'chattype': 'single', 'from': {'userid': 'zhangsan'}, 'msgtype': 'text', 'response_url': 'https://qyapi.weixin.qq.com/cgi-bin/aibot/response?response_code=AAAAAAAAAASSSSSSSSSSSSSDDDDDDDDDDDDDDFFFFFFFFFFFF', 'text': {'content': '今天温度多少度?'}}
2026-04-14 12:58:41 [views INFO] Received message: {'msgid': '315ce97febd772e066845c140f8d94ba', 'aibotid': 'aibfKP7VKlvI_mX-39ks5BKofkkb6lba4P4', 'chattype': 'single', 'from': {'userid': 'zhangsan'}, 'msgtype': 'text', 'response_url': 'https://qyapi.weixin.qq.com/cgi-bin/aibot/response?response_code=AAAAAAAAAASSSSSSSSSSSSSDDDDDDDDDDDDDDFFFFFFFFFFFF', 'text': {'content': '今天温度多少度?'}}
2026-04-14 12:58:41 [views INFO] Received message: {'msgid': '0f2ecb9fc85f2f794240eb5a09119781', 'aibotid': 'aibfKP7VKlvI_mX-39ks5BKofkkb6lba4P4', 'chattype': 'single', 'from': {'userid': 'zhangsan'}, 'msgtype': 'stream', 'stream': {'id': '315ce97febd772e066845c140f8d94ba'}}
2026-04-14 12:58:42 [views INFO] Received message: {'msgid': '6ec561b7d4d26f46d161ba2b3f9da81a', 'aibotid': 'aibfKP7VKlvI_mX-39ks5BKofkkb6lba4P4', 'chattype': 'single', 'from': {'userid': 'zhangsan'}, 'msgtype': 'stream', 'stream': {'id': '315ce97febd772e066845c140f8d94ba'}}
2026-04-14 12:58:42 [workflow_manage ERROR] Exception: 2 validation errors for HumanMessage
content.str
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
content.list[union[str,dict[any,any]]]
  Input should be a valid list [type=list_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.12/v/list_type
Traceback (most recent call last):
  File "/opt/maxkb-app/community/apps/application/flow/workflow_manage.py", line 395, in hand_node_result
  File "/opt/maxkb-app/community/apps/application/flow/workflow_manage.py", line 43, in result
  File "/opt/maxkb-app/community/apps/application/flow/workflow_manage.py", line 532, in run_node_future
  File "/opt/maxkb-app/community/apps/application/flow/workflow_manage.py", line 538, in run_node
  File "/opt/maxkb-app/community/apps/application/flow/i_step_node.py", line 297, in run
  File "/opt/maxkb-app/community/apps/application/flow/step_node/ai_chat_step_node/i_chat_node.py", line 64, in _run
  File "/opt/maxkb-app/community/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py", line 177, in execute
  File "/opt/maxkb-app/community/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py", line 351, in get_history_message
  File "/opt/maxkb-app/community/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py", line 352, in <listcomp>
  File "/opt/maxkb-app/community/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py", line 139, in get_message
  File "/opt/maxkb-app/community/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py", line 131, in get_node_message
  File "/opt/py3/lib/python3.11/site-packages/langchain_core/messages/human.py", line 60, in __init__
    super().__init__(content=content, **kwargs)
  File "/opt/py3/lib/python3.11/site-packages/langchain_core/messages/base.py", line 179, in __init__
    super().__init__(content=content, **kwargs)
  File "/opt/py3/lib/python3.11/site-packages/langchain_core/load/serializable.py", line 118, in __init__
    super().__init__(*args, **kwargs)
  File "/opt/py3/lib/python3.11/site-packages/pydantic/main.py", line 250, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 2 validation errors for HumanMessage
content.str
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type
content.list[union[str,dict[any,any]]]
  Input should be a valid list [type=list_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.12/v/list_type
2026-04-14 12:58:42 [workflow_manage ERROR] Exception: 'NoneType' object has no attribute 'write_context'
Traceback (most recent call last):
  File "/opt/maxkb-app/community/apps/application/flow/workflow_manage.py", line 396, in hand_node_result
AttributeError: 'NoneType' object has no attribute 'write_context'

Additional Information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions