INNER CODE UNIT · Python
_build_run_config
TauricResearch/TradingAgents · cli/run.py:59
def _build_run_config(selections: dict, checkpoint: bool | None) -> dict:
"""Assemble the run config from interactive selections, honoring env precedence.
Round counts and checkpoint follow "explicit env/flag wins": an env-applied
value on DEFAULT_CONFIG is preserved unless the user overrode it on the CLI.
"""
config = DEFAULT_CONFIG.copy()
# Research depth sets both round counts, but an explicit env override
# (TRADINGAGENTS_MAX_DEBATE_ROUNDS / _MAX_RISK_ROUNDS) wins over the
# interactive selection — leave the env-applied value in place (#977).
rounds = (("TRADINGAGENTS_MAX_DEBATE_ROUNDS", "max_debate_rounds"),
("TRADINGAGENTS_MAX_RISK_ROUNDS", "max_risk_discuss_rounds"))
depth_was_asked = not depth_from_env()
for env_var, key in rounds:
if not os.environ.get(env_var):
config[key] = selections["research_depth"]
elif depth_was_asked:
# The depth question appeared (it is skipped only when both are