Skip to content

Commit 61c1c27

Browse files
committed
feat(config): expose memory log, recursion limit, and news parameters in _ENV_OVERRIDES
1 parent a33fd4c commit 61c1c27

3 files changed

Lines changed: 37 additions & 1 deletion

File tree

tests/test_temperature_config.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,33 @@ def test_none_omitted(self):
8181

8282
def test_empty_string_omitted(self):
8383
assert "temperature" not in self._kwargs_for("")
84+
85+
86+
@pytest.mark.unit
87+
class TestEnvOverridesExtended:
88+
def test_env_overrides_memory_and_news_config(self, monkeypatch):
89+
import tradingagents.default_config as dc
90+
91+
monkeypatch.setenv("TRADINGAGENTS_MEMORY_LOG_MAX_ENTRIES", "25")
92+
monkeypatch.setenv("TRADINGAGENTS_MAX_RECUR_LIMIT", "150")
93+
monkeypatch.setenv("TRADINGAGENTS_NEWS_ARTICLE_LIMIT", "30")
94+
monkeypatch.setenv("TRADINGAGENTS_GLOBAL_NEWS_ARTICLE_LIMIT", "15")
95+
monkeypatch.setenv("TRADINGAGENTS_GLOBAL_NEWS_LOOKBACK_DAYS", "14")
96+
97+
importlib.reload(dc)
98+
assert dc.DEFAULT_CONFIG["memory_log_max_entries"] in ("25", 25)
99+
assert dc.DEFAULT_CONFIG["max_recur_limit"] == 150
100+
assert dc.DEFAULT_CONFIG["news_article_limit"] == 30
101+
assert dc.DEFAULT_CONFIG["global_news_article_limit"] == 15
102+
assert dc.DEFAULT_CONFIG["global_news_lookback_days"] == 14
103+
104+
for var in (
105+
"TRADINGAGENTS_MEMORY_LOG_MAX_ENTRIES",
106+
"TRADINGAGENTS_MAX_RECUR_LIMIT",
107+
"TRADINGAGENTS_NEWS_ARTICLE_LIMIT",
108+
"TRADINGAGENTS_GLOBAL_NEWS_ARTICLE_LIMIT",
109+
"TRADINGAGENTS_GLOBAL_NEWS_LOOKBACK_DAYS",
110+
):
111+
monkeypatch.delenv(var, raising=False)
112+
importlib.reload(dc)
113+

tradingagents/agents/utils/memory.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def __init__(self, config: dict = None):
2323
self._log_path = Path(path).expanduser()
2424
self._log_path.parent.mkdir(parents=True, exist_ok=True)
2525
# Optional cap on resolved entries. None disables rotation.
26-
self._max_entries = cfg.get("memory_log_max_entries")
26+
max_ent = cfg.get("memory_log_max_entries")
27+
self._max_entries = int(max_ent) if max_ent is not None else None
2728

2829
# --- Write path (Phase A) ---
2930

tradingagents/default_config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
"TRADINGAGENTS_BENCHMARK_TICKER": "benchmark_ticker",
2020
"TRADINGAGENTS_TEMPERATURE": "temperature",
2121
"TRADINGAGENTS_LLM_MAX_RETRIES": "llm_max_retries",
22+
"TRADINGAGENTS_MEMORY_LOG_MAX_ENTRIES": "memory_log_max_entries",
23+
"TRADINGAGENTS_MAX_RECUR_LIMIT": "max_recur_limit",
24+
"TRADINGAGENTS_NEWS_ARTICLE_LIMIT": "news_article_limit",
25+
"TRADINGAGENTS_GLOBAL_NEWS_ARTICLE_LIMIT": "global_news_article_limit",
26+
"TRADINGAGENTS_GLOBAL_NEWS_LOOKBACK_DAYS": "global_news_lookback_days",
2227
# Provider-specific reasoning/thinking knobs (None = each provider's own
2328
# default). Settable here for non-interactive runs; the CLI also offers an
2429
# interactive choice, which is skipped when the matching var is set.

0 commit comments

Comments
 (0)