From 774452795b758ba051faf0f7ff01819c3f704fa4 Mon Sep 17 00:00:00 2001 From: Re-bin Date: Thu, 12 Mar 2026 16:09:24 +0000 Subject: [PATCH] fix(memory): use explicit function name in tool_choice for DashScope compatibility --- nanobot/agent/memory.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/nanobot/agent/memory.py b/nanobot/agent/memory.py index 802dd04..1301d47 100644 --- a/nanobot/agent/memory.py +++ b/nanobot/agent/memory.py @@ -112,15 +112,17 @@ class MemoryStore: ## Conversation to Process {self._format_messages(messages)}""" + chat_messages = [ + {"role": "system", "content": "You are a memory consolidation agent. Call the save_memory tool with your consolidation of the conversation."}, + {"role": "user", "content": prompt}, + ] + try: response = await provider.chat_with_retry( - messages=[ - {"role": "system", "content": "You are a memory consolidation agent. Call the save_memory tool with your consolidation of the conversation."}, - {"role": "user", "content": prompt}, - ], + messages=chat_messages, tools=_SAVE_MEMORY_TOOL, model=model, - tool_choice="required", + tool_choice={"type": "function", "function": {"name": "save_memory"}}, ) if not response.has_tool_calls: