fix(fireworks_ai): let extra_body thinking/reasoning_effort take precedence over chat_template_kwargs

This commit is contained in:
mateo-berri 2026-08-14 16:25:32 -07:00
parent 6b3977472b
commit 3b2ed3c018
4 changed files with 31 additions and 2 deletions

View file

@ -397,7 +397,7 @@ class FireworksAIConfig(FireworksAIMixin, OpenAIGPTConfig):
other_keys,
model,
)
if "reasoning_effort" in optional_params or "thinking" in optional_params:
if any(key in optional_params or key in extra_body for key in ("reasoning_effort", "thinking")):
verbose_logger.debug(
"fireworks_ai ignoring chat_template_kwargs; explicit reasoning_effort/thinking takes precedence."
)

View file

@ -127,7 +127,7 @@ class FireworksAITextCompletionConfig(FireworksAIMixin, BaseTextCompletionConfig
effort: Final = _effort_from_chat_template_kwargs(chat_template_kwargs)
if effort is None:
return result
if "reasoning_effort" in result or "thinking" in optional_params:
if any(key in result or key in optional_params for key in ("reasoning_effort", "thinking")):
verbose_logger.debug(
"fireworks_ai ignoring chat_template_kwargs; explicit reasoning_effort/thinking takes precedence."
)

View file

@ -1418,6 +1418,25 @@ def test_map_extra_body_params_chat_template_kwargs_native_thinking_wins():
assert result == {"thinking": thinking}
def test_map_extra_body_params_chat_template_kwargs_extra_body_thinking_wins():
config = FireworksAIConfig()
thinking = {"type": "enabled", "budget_tokens": 4096}
result = config.map_extra_body_params(
{"extra_body": {"thinking": thinking, "chat_template_kwargs": {"enable_thinking": False}}},
_REASONING_MODEL,
)
assert result == {"extra_body": {"thinking": thinking}}
def test_map_extra_body_params_chat_template_kwargs_extra_body_reasoning_effort_wins():
config = FireworksAIConfig()
result = config.map_extra_body_params(
{"extra_body": {"reasoning_effort": "high", "chat_template_kwargs": {"enable_thinking": False}}},
_REASONING_MODEL,
)
assert result == {"extra_body": {"reasoning_effort": "high"}}
def test_map_extra_body_params_chat_template_kwargs_dropped_for_non_reasoning_model():
config = FireworksAIConfig()
result = config.map_extra_body_params(

View file

@ -73,6 +73,16 @@ def test_map_extra_body_params_chat_template_kwargs_dropped_for_non_reasoning_mo
assert result == {}
def test_map_extra_body_params_chat_template_kwargs_extra_body_thinking_wins():
config = FireworksAITextCompletionConfig()
thinking = {"type": "enabled", "budget_tokens": 4096}
result = config.map_extra_body_params(
{"extra_body": {"thinking": thinking, "chat_template_kwargs": {"enable_thinking": False}}},
_REASONING_MODEL,
)
assert result == {"extra_body": {"thinking": thinking}}
def test_map_extra_body_params_top_level_reasoning_effort_moves_into_extra_body():
config = FireworksAITextCompletionConfig()
result = config.map_extra_body_params(