Skip reasoning_effort entirely since all agents use function tools
Per issue #403 analysis: the real problem is that reasoning_effort with function tools requires the /v1/responses endpoint, but LangChain's ChatOpenAI only supports /v1/chat/completions. This affects all models (not just gpt-5.x vs o-series), so the safest fix is to skip reasoning_effort and log an info message explaining why. Once LangChain adds /v1/responses support, this can be re-enabled.
This commit is contained in:
parent
19dae36f58
commit
98330aa302
|
|
@ -158,10 +158,20 @@ class TradingAgentsGraph:
|
|||
elif provider == "openai":
|
||||
reasoning_effort = self.config.get("openai_reasoning_effort")
|
||||
if reasoning_effort:
|
||||
# reasoning_effort is only supported by o-series models
|
||||
# (o1, o3, o3-mini, o4-mini, etc.), not by gpt-* models
|
||||
if model_name.startswith("o"):
|
||||
kwargs["reasoning_effort"] = reasoning_effort
|
||||
# reasoning_effort + function tools is not supported on the
|
||||
# /v1/chat/completions endpoint for some models (e.g. gpt-5.x).
|
||||
# LangChain's ChatOpenAI only uses chat/completions, so we
|
||||
# skip reasoning_effort for agents that use tools to avoid
|
||||
# 400 errors. This is a known LangChain limitation.
|
||||
# See: https://github.com/TauricResearch/TradingAgents/issues/403
|
||||
import logging
|
||||
logging.getLogger(__name__).info(
|
||||
"Skipping reasoning_effort='%s' for model '%s' because "
|
||||
"TradingAgents agents use function tools, which are "
|
||||
"incompatible with reasoning_effort on the chat/completions "
|
||||
"endpoint. See issue #403.",
|
||||
reasoning_effort, model_name,
|
||||
)
|
||||
|
||||
return kwargs
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue