From 7f6e509199f97e2216831d961910b49b6f50863e Mon Sep 17 00:00:00 2001 From: Lume Date: Sun, 5 Apr 2026 07:32:21 +0100 Subject: [PATCH] refactor: use _should_sanitize_tool_calls in flush_memories() Replaces hardcoded Mistral check with the new _should_sanitize_tool_calls() method. This ensures tool_calls are sanitized for all strict APIs, not just Mistral. Prevents 400 errors from Fireworks and other providers. --- run_agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run_agent.py b/run_agent.py index 5b51bc433..564508d58 100644 --- a/run_agent.py +++ b/run_agent.py @@ -5396,7 +5396,7 @@ class AIAgent: try: # Build API messages for the flush call - _is_strict_api = "api.mistral.ai" in self._base_url_lower + _needs_sanitize = self._should_sanitize_tool_calls() api_messages = [] for msg in messages: api_msg = msg.copy() @@ -5407,7 +5407,7 @@ class AIAgent: api_msg.pop("reasoning", None) api_msg.pop("finish_reason", None) api_msg.pop("_flush_sentinel", None) - if _is_strict_api: + if _needs_sanitize: self._sanitize_tool_calls_for_strict_api(api_msg) api_messages.append(api_msg)