🐛 修复工具调用处理逻辑,确保每个工具调用的回复消息被正确添加

This commit is contained in:
FuQuan233 2026-05-19 13:37:01 +08:00
parent 5ac0597278
commit 42f60625ca

View file

@ -475,6 +475,8 @@ async def process_messages(context_id: int, is_group: bool = True):
await send_split_messages(handler, message.content) await send_split_messages(handler, message.content)
# 处理每个工具调用 # 处理每个工具调用
new_messages.append(llm_reply)
for tool_call in message.tool_calls: for tool_call in message.tool_calls:
tool_name = tool_call.function.name tool_name = tool_call.function.name
tool_args = json.loads(tool_call.function.arguments) tool_args = json.loads(tool_call.function.arguments)
@ -496,8 +498,6 @@ async def process_messages(context_id: int, is_group: bool = True):
bot_id=str(event.self_id) bot_id=str(event.self_id)
) )
new_messages.append(llm_reply)
new_messages.append({ new_messages.append({
"role": "tool", "role": "tool",
"tool_call_id": tool_call.id, "tool_call_id": tool_call.id,