fix(fireworks_ai): default supports_tool_choice=True for unmapped models

Fireworks models absent from the cost map defaulted supports_function_calling to True but left supports_tool_choice unset, so tool_choice was rejected with UnsupportedParamsError even though the upstream request would succeed. Default supports_tool_choice to True in get_provider_info, mirroring supports_function_calling, while still letting an explicit cost-map value override it.

Fixes #35382

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Devin AI 2026-07-31 18:08:35 +00:00
parent f54f92437b
commit e45492006e
2 changed files with 30 additions and 0 deletions

View file

@ -439,18 +439,23 @@ class FireworksAIConfig(FireworksAIMixin, OpenAIGPTConfig):
supports_function_calling_value = self._get_model_cost_capability(
model=model, capability="supports_function_calling"
)
supports_tool_choice_value = self._get_model_cost_capability(model=model, capability="supports_tool_choice")
supports_reasoning_value = self._get_model_cost_capability(model=model, capability="supports_reasoning")
supports_vision_value = self._get_model_cost_capability(model=model, capability="supports_vision")
supports_pdf_input_value = self._get_model_cost_capability(model=model, capability="supports_pdf_input")
provider_specific_model_info: ProviderSpecificModelInfo = {
"supports_function_calling": True,
"supports_tool_choice": True,
"supports_prompt_caching": True, # https://docs.fireworks.ai/guides/prompt-caching
}
if supports_function_calling_value is not None:
provider_specific_model_info["supports_function_calling"] = supports_function_calling_value
if supports_tool_choice_value is not None:
provider_specific_model_info["supports_tool_choice"] = supports_tool_choice_value
# Only include supports_reasoning if True
if supports_reasoning_value:
provider_specific_model_info["supports_reasoning"] = supports_reasoning_value

View file

@ -20,6 +20,7 @@ from litellm.types.utils import (
Message,
ModelResponse,
)
from litellm.utils import supports_tool_choice
@pytest.fixture(autouse=True)
@ -467,6 +468,30 @@ def test_unmapped_model_fallback_function_calling():
assert info["supports_function_calling"] is True
def test_unmapped_model_fallback_tool_choice(monkeypatch):
"""A Fireworks model absent from the cost map must still advertise tool_choice, matching supports_function_calling. Regression for #35382 (Kimi K3)."""
monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")
litellm.model_cost = litellm.get_model_cost_map(url="")
config = FireworksAIConfig()
model = "accounts/fireworks/models/kimi-k3"
info = config.get_provider_info(model)
assert info["supports_tool_choice"] is True
assert supports_tool_choice(model=model, custom_llm_provider="fireworks_ai") is True
assert "tool_choice" in config.get_supported_openai_params(model)
def test_provider_info_tool_choice_false_override(monkeypatch):
"""An explicit supports_tool_choice=False in the cost map still wins over the Fireworks default."""
config = FireworksAIConfig()
model = "fireworks_ai/test-no-tool-choice"
monkeypatch.setitem(litellm.model_cost, model, {"supports_tool_choice": False})
info = config.get_provider_info(model)
assert info["supports_tool_choice"] is False
def test_transform_messages_helper_strips_thinking_blocks():
"""thinking_blocks must not be forwarded to Fireworks chat completions."""
config = FireworksAIConfig()