From 08208323f294772df15996e3408cd11605bb545c Mon Sep 17 00:00:00 2001 From: Adavya Sharma Date: Wed, 11 Mar 2026 08:07:56 +0000 Subject: [PATCH] test: cover fireworks tool-call payload sanitization --- tests/test_provider_parity.py | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/test_provider_parity.py b/tests/test_provider_parity.py index 124fcf630..bb91b055c 100644 --- a/tests/test_provider_parity.py +++ b/tests/test_provider_parity.py @@ -168,6 +168,52 @@ class TestBuildApiKwargsCustomEndpoint: extra = kwargs.get("extra_body", {}) assert "reasoning" not in extra + def test_fireworks_tool_call_payload_strips_codex_only_fields(self, monkeypatch): + agent = _make_agent( + monkeypatch, + "custom", + base_url="https://api.fireworks.ai/inference/v1", + ) + messages = [ + {"role": "user", "content": "hi"}, + { + "role": "assistant", + "content": "Checking now.", + "codex_reasoning_items": [ + {"type": "reasoning", "id": "rs_1", "encrypted_content": "blob"}, + ], + "tool_calls": [ + { + "id": "call_fw_123", + "call_id": "call_fw_123", + "response_item_id": "fc_fw_123", + "type": "function", + "function": { + "name": "terminal", + "arguments": "{\"command\":\"pwd\"}", + }, + } + ], + }, + {"role": "tool", "tool_call_id": "call_fw_123", "content": "/tmp"}, + ] + + kwargs = agent._build_api_kwargs(messages) + + assert kwargs["tools"][0]["function"]["name"] == "web_search" + assert "input" not in kwargs + assert kwargs.get("extra_body", {}) == {} + + assistant_msg = kwargs["messages"][1] + tool_call = assistant_msg["tool_calls"][0] + + assert "codex_reasoning_items" not in assistant_msg + assert tool_call["id"] == "call_fw_123" + assert tool_call["type"] == "function" + assert tool_call["function"]["name"] == "terminal" + assert "call_id" not in tool_call + assert "response_item_id" not in tool_call + class TestBuildApiKwargsCodex: def test_uses_responses_api_format(self, monkeypatch):