From 234c01f69057f1ca4a221320873b1ff180b88689 Mon Sep 17 00:00:00 2001 From: Lume Date: Sun, 5 Apr 2026 07:32:31 +0100 Subject: [PATCH] refactor: use _should_sanitize_tool_calls in _handle_max_iterations() Replaces hardcoded Mistral check with the new _should_sanitize_tool_calls() method. Ensures summary generation works correctly with Fireworks and other strict APIs that reject unknown tool_call fields. --- run_agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run_agent.py b/run_agent.py index 564508d58..e4b82b073 100644 --- a/run_agent.py +++ b/run_agent.py @@ -6282,13 +6282,13 @@ class AIAgent: try: # Build API messages, stripping internal-only fields # (finish_reason, reasoning) that strict APIs like Mistral reject with 422 - _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() for internal_field in ("reasoning", "finish_reason"): api_msg.pop(internal_field, None) - if _is_strict_api: + if _needs_sanitize: self._sanitize_tool_calls_for_strict_api(api_msg) api_messages.append(api_msg)