diff --git a/verifiers/v1/harnesses/rlm/harness.py b/verifiers/v1/harnesses/rlm/harness.py index d67fe2acc1..d7c21d518f 100644 --- a/verifiers/v1/harnesses/rlm/harness.py +++ b/verifiers/v1/harnesses/rlm/harness.py @@ -39,6 +39,11 @@ class RLMHarnessConfig(HarnessConfig): past this many tokens. An int is a fixed threshold; a `(lo, hi)` pair draws a per-group threshold (seeded by the task index, so a task's rollouts share one draw and tasks vary). `None` disables auto-compaction; ints must be positive.""" + max_compactions: int | None = None + """Cap on auto-compactions (RLM_MAX_COMPACTIONS): once a branch has compacted this many + times it stops compacting and the context grows to the model's natural limit, restoring + the context-length stop that `summarize_at_tokens` otherwise removes. `None` = unlimited. + Requires an rlm `version` that understands RLM_MAX_COMPACTIONS.""" @model_validator(mode="after") def validate_limits(self) -> "RLMHarnessConfig": @@ -55,6 +60,10 @@ def validate_limits(self) -> "RLMHarnessConfig": raise ValueError( "`summarize_at_tokens` must be positive, or None to disable." ) + if self.max_compactions is not None and self.max_compactions <= 0: + raise ValueError( + "`max_compactions` must be positive, or None for unlimited." + ) return self @model_validator(mode="after") @@ -123,6 +132,8 @@ async def launch( } if system_prompt is not None: env["RLM_APPEND_TO_SYSTEM_PROMPT"] = system_prompt + if self.config.max_compactions is not None: + env["RLM_MAX_COMPACTIONS"] = str(self.config.max_compactions) if self.config.skills: env["RLM_SKILLS"] = ",".join(self.config.skills) if mcp_urls: