Only apply reasoning_effort for o-series OpenAI models

reasoning_effort is only supported by o-series models (o1, o3,
o3-mini, o4-mini). Passing it to gpt-* models causes a 400 error
because those models don't support it on the chat completions
endpoint.

Now we check if the model name starts with 'o' before including
the parameter.

Fixes #403
This commit is contained in:
Charlie Tonneslan 2026-03-22 12:35:32 -04:00
parent f362a160c3
commit a1ee0bd824
1 changed files with 5 additions and 1 deletions

View File

@ -146,7 +146,11 @@ class TradingAgentsGraph:
elif provider == "openai":
reasoning_effort = self.config.get("openai_reasoning_effort")
if reasoning_effort:
kwargs["reasoning_effort"] = reasoning_effort
# reasoning_effort is only supported by o-series models
# (o1, o3, o3-mini, o4-mini, etc.), not by gpt-* models
model = self.config.get("deep_think_llm", "")
if model.startswith("o"):
kwargs["reasoning_effort"] = reasoning_effort
return kwargs