@@ -97,6 +97,12 @@ class RLMConfig:
9797 max_iterations : int = 10
9898 max_llm_calls : int = 30
9999
100+ # Head+tail cap (in CHARACTERS — unrelated to ``max_tokens``) that dspy.RLM applies to each
101+ # REPL output before it enters the planner prompt; the planner never sees the omitted middle.
102+ # Default matches dspy's own. Raise it when the planner must read large printed results whole,
103+ # but prefer slicing/summarising in REPL code — retained chars cost prompt tokens every turn.
104+ max_output_chars : int = 10_000
105+
100106 # Retry policy in _retry.py: how many times to run the WHOLE task (a full RLM trajectory) until
101107 # its output coerces into output_model. Default 1 = no retry, because a retry re-runs the entire
102108 # RLM from scratch — silently MULTIPLYING the max_iterations budget (3 retries ⇒ up to 3×
@@ -158,6 +164,8 @@ def from_env(cls) -> "RLMConfig":
158164 - ``RLM_ALLOW_INSECURE_SANDBOX`` (default ``false``).
159165 - ``RLM_MAX_ITERATIONS`` (default ``10``).
160166 - ``RLM_MAX_LLM_CALLS`` (default ``30``).
167+ - ``RLM_MAX_OUTPUT_CHARS`` (default ``10000``) — head+tail character cap on REPL
168+ output fed back to the planner (distinct from ``RLM_MAX_TOKENS``).
161169 - ``RLM_MAX_RETRIES`` (default ``3``).
162170 - ``RLM_OBSERVE`` (default ``false``).
163171 """
@@ -183,6 +191,7 @@ def from_env(cls) -> "RLMConfig":
183191 allow_insecure_sandbox = _env_bool ("RLM_ALLOW_INSECURE_SANDBOX" , False ),
184192 max_iterations = _env_int ("RLM_MAX_ITERATIONS" , 10 ),
185193 max_llm_calls = _env_int ("RLM_MAX_LLM_CALLS" , 30 ),
194+ max_output_chars = _env_int ("RLM_MAX_OUTPUT_CHARS" , 10_000 ),
186195 max_retries = _env_int ("RLM_MAX_RETRIES" , 1 ),
187196 observe = _env_bool ("RLM_OBSERVE" , False ),
188197 )
0 commit comments