fix: print编码防崩 + 未知工具时自动重注入tool schema

This commit is contained in:
Liang Jiaqing
2026-02-16 20:15:46 +08:00
parent 32ad26f4ce
commit dbc28fbc35
3 changed files with 6 additions and 2 deletions

View File

@@ -328,6 +328,7 @@ class ToolClient:
except json.JSONDecodeError as e:
print("[Warn] Failed to parse tool_use JSON:", json_str)
tool_calls = [MockToolCall('bad_json', {'msg': f'Failed to parse tool_use JSON: {json_str[:200]}'})]
self.last_tools = '' # llm肯定忘了tool schema了再提供下
except Exception as e:
print("[Error] Exception during tool_use parsing:", str(e), data)