From 7142746bdea7a83c05d258f21e2e7bd61350eaae Mon Sep 17 00:00:00 2001 From: Yijia-Xiao Date: Sat, 3 Oct 2026 23:16:33 +0000 Subject: [PATCH] fix(cli): keep a tier's configured thinking setting when the main provider has none (#1440) - the run config takes reasoning effort, thinking level and Claude effort from the selections only when one was chosen --- cli/run.py | 9 +++++---- tests/test_cli_config_precedence.py | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cli/run.py b/cli/run.py index 77bf95558..dc934dd42 100644 --- a/cli/run.py +++ b/cli/run.py @@ -83,10 +83,11 @@ def _build_run_config(selections: dict, checkpoint: bool | None) -> dict: config["deep_think_llm"] = selections["deep_think_llm"] config["backend_url"] = selections["backend_url"] config["llm_provider"] = selections["llm_provider"].lower() - # Provider-specific thinking configuration - config["google_thinking_level"] = selections.get("google_thinking_level") - config["openai_reasoning_effort"] = selections.get("openai_reasoning_effort") - config["anthropic_effort"] = selections.get("anthropic_effort") + # Provider-specific thinking configuration. Only the main provider's is + # asked; a tier on another provider keeps its configured value (#1440). + for key in ("google_thinking_level", "openai_reasoning_effort", "anthropic_effort"): + if selections.get(key) is not None: + config[key] = selections[key] config["output_language"] = selections.get("output_language", "English") # --checkpoint/--no-checkpoint overrides only when explicitly given; omitting # the flag preserves TRADINGAGENTS_CHECKPOINT_ENABLED / the default (#976). diff --git a/tests/test_cli_config_precedence.py b/tests/test_cli_config_precedence.py index cb94cff8a..8e9fa3bff 100644 --- a/tests/test_cli_config_precedence.py +++ b/tests/test_cli_config_precedence.py @@ -105,3 +105,15 @@ def test_a_half_set_round_count_says_which_value_won(capsys, monkeypatch): assert config["max_risk_discuss_rounds"] == 5 assert any("TRADINGAGENTS_MAX_DEBATE_ROUNDS" in line for line in printed), printed + + +@pytest.mark.unit +def test_a_tier_s_thinking_setting_survives_a_main_provider_that_has_none(monkeypatch): + """A run on Google with an OpenAI tier (#1440): the run's selections carry no + OpenAI reasoning effort, so the configured one must reach that tier.""" + monkeypatch.setitem(cli_run.DEFAULT_CONFIG, "openai_reasoning_effort", "high") + monkeypatch.setitem(cli_run.DEFAULT_CONFIG, "anthropic_effort", "low") + cfg = cli_run._build_run_config({**SELECTIONS, "llm_provider": "google", "google_thinking_level": "high"}, + checkpoint=None) + assert (cfg["openai_reasoning_effort"], cfg["anthropic_effort"], cfg["google_thinking_level"]) == \ + ("high", "low", "high")