From ed4a605696b54522cb8c88f7c89a8544c32165fd Mon Sep 17 00:00:00 2001 From: Lume Date: Sun, 5 Apr 2026 07:34:48 +0100 Subject: [PATCH] docs: update docstring to mention Fireworks strict validation Updates _sanitize_tool_calls_for_strict_api docstring to explicitly mention Fireworks alongside Mistral as strict APIs requiring sanitization. Also documents the specific fields that are stripped (call_id, response_item_id). --- run_agent.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/run_agent.py b/run_agent.py index d374e080f49..80fc340a3eb 100644 --- a/run_agent.py +++ b/run_agent.py @@ -5324,15 +5324,18 @@ class AIAgent: def _sanitize_tool_calls_for_strict_api(api_msg: dict) -> dict: """Strip Codex Responses API fields from tool_calls for strict providers. - Providers like Mistral strictly validate the Chat Completions schema - and reject unknown fields (call_id, response_item_id) with 422. - These fields are preserved in the internal message history — this - method only modifies the outgoing API copy. + Providers like Mistral, Fireworks, and other strict OpenAI-compatible APIs + validate the Chat Completions schema and reject unknown fields (call_id, + response_item_id) with 400 or 422 errors. These fields are preserved in + the internal message history — this method only modifies the outgoing + API copy. Creates new tool_call dicts rather than mutating in-place, so the original messages list retains call_id/response_item_id for Codex Responses API compatibility (e.g. if the session falls back to a Codex provider later). + + Fields stripped: call_id, response_item_id """ tool_calls = api_msg.get("tool_calls") if not isinstance(tool_calls, list):