fix(memory): use explicit function name in tool_choice for DashScope compatibility

This commit is contained in:
Re-bin
2026-03-12 16:09:24 +00:00
parent 109ae13301
commit 774452795b

View File

@@ -112,15 +112,17 @@ class MemoryStore:
## Conversation to Process ## Conversation to Process
{self._format_messages(messages)}""" {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: try:
response = await provider.chat_with_retry( response = await provider.chat_with_retry(
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},
],
tools=_SAVE_MEMORY_TOOL, tools=_SAVE_MEMORY_TOOL,
model=model, model=model,
tool_choice="required", tool_choice={"type": "function", "function": {"name": "save_memory"}},
) )
if not response.has_tool_calls: if not response.has_tool_calls: