mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-11-16 14:22:35 +02:00
fix(cli): write the state log, and name the analysts as users know them
- record_decision writes the run's state log, so CLI runs save full_states_log like propagate() does - with both round counts from the environment, the CLI no longer says a chosen research depth was overridden - an unknown --analysts name lists sentiment, not social
This commit is contained in:
+2
-1
@@ -90,7 +90,8 @@ def parse_analysts(value: str, asset_type: AssetType) -> list[AnalystType]:
|
||||
known = {a.value: a for a in AnalystType}
|
||||
unknown = [n for n in names if n not in known]
|
||||
if unknown:
|
||||
raise ValueError(f"unknown analyst {', '.join(unknown)}; choose from {', '.join(known)}")
|
||||
choices = ", ".join("sentiment" if name == "social" else name for name in known)
|
||||
raise ValueError(f"unknown analyst {', '.join(unknown)}; choose from {choices}")
|
||||
available = filter_analysts_for_asset_type(list(known.values()), asset_type)
|
||||
unavailable = [n for n in names if known[n] not in available]
|
||||
if unavailable:
|
||||
|
||||
+9
-7
@@ -22,7 +22,7 @@ from cli.display import (
|
||||
update_display,
|
||||
update_research_team_status,
|
||||
)
|
||||
from cli.selections import get_user_selections, unattended_gaps
|
||||
from cli.selections import depth_from_env, get_user_selections, unattended_gaps
|
||||
from cli.stats_handler import StatsCallbackHandler
|
||||
from tradingagents.agents.rating import is_review, run_rating
|
||||
from tradingagents.dataflows.symbols import safe_ticker_component
|
||||
@@ -67,17 +67,19 @@ def _build_run_config(selections: dict, checkpoint: bool | None) -> dict:
|
||||
# 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).
|
||||
for env_var, key in (("TRADINGAGENTS_MAX_DEBATE_ROUNDS", "max_debate_rounds"),
|
||||
("TRADINGAGENTS_MAX_RISK_ROUNDS", "max_risk_discuss_rounds")):
|
||||
if os.environ.get(env_var):
|
||||
# The depth prompt still appeared (it is skipped only when both are
|
||||
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
|
||||
# set), so say which half of the answer the environment overrode.
|
||||
console.print(
|
||||
f"[green]✓ {key} from environment:[/green] {config[key]} "
|
||||
f"(set by {env_var}, so the research depth you chose does not apply to it)"
|
||||
)
|
||||
else:
|
||||
config[key] = selections["research_depth"]
|
||||
config["quick_think_llm"] = selections["quick_think_llm"]
|
||||
config["deep_think_llm"] = selections["deep_think_llm"]
|
||||
config["backend_url"] = selections["backend_url"]
|
||||
|
||||
+8
-5
@@ -46,6 +46,12 @@ def get_user_selections(flags=None):
|
||||
return selections
|
||||
|
||||
|
||||
def depth_from_env() -> bool:
|
||||
"""Both round counts come from the environment, so the depth question is skipped."""
|
||||
return bool(os.environ.get("TRADINGAGENTS_MAX_DEBATE_ROUNDS")
|
||||
and os.environ.get("TRADINGAGENTS_MAX_RISK_ROUNDS"))
|
||||
|
||||
|
||||
def unattended_gaps(flags) -> list[str]:
|
||||
"""The flags and environment variables a run with no terminal still needs."""
|
||||
env = os.environ.get
|
||||
@@ -53,7 +59,7 @@ def unattended_gaps(flags) -> list[str]:
|
||||
gaps += [f"--{name} or --no-{name}" for name in ("save", "show") if flags.get(name) is None]
|
||||
if not env("TRADINGAGENTS_OUTPUT_LANGUAGE"):
|
||||
gaps.append("TRADINGAGENTS_OUTPUT_LANGUAGE")
|
||||
if not (env("TRADINGAGENTS_MAX_DEBATE_ROUNDS") and env("TRADINGAGENTS_MAX_RISK_ROUNDS")):
|
||||
if not depth_from_env():
|
||||
gaps.append("TRADINGAGENTS_MAX_DEBATE_ROUNDS and TRADINGAGENTS_MAX_RISK_ROUNDS")
|
||||
if not env("TRADINGAGENTS_LLM_PROVIDER"):
|
||||
gaps.append("TRADINGAGENTS_LLM_PROVIDER")
|
||||
@@ -190,10 +196,7 @@ def _prompt_selections(prefs, flags):
|
||||
# Research depth maps to the debate + risk round counts; when both are
|
||||
# supplied through TRADINGAGENTS_MAX_DEBATE_ROUNDS / _MAX_RISK_ROUNDS we keep
|
||||
# the run non-interactive and honor the env values (#977).
|
||||
depth_from_env = bool(os.environ.get("TRADINGAGENTS_MAX_DEBATE_ROUNDS")) and bool(
|
||||
os.environ.get("TRADINGAGENTS_MAX_RISK_ROUNDS")
|
||||
)
|
||||
if depth_from_env:
|
||||
if depth_from_env():
|
||||
selected_research_depth = DEFAULT_CONFIG["max_debate_rounds"]
|
||||
console.print(
|
||||
f"[green]✓ Research depth from environment:[/green] "
|
||||
|
||||
Reference in New Issue
Block a user