Skip to content

Commit dfd5650

Browse files
snimuclaude
andauthored
Abort rollout when RLM worker recovery fails (#891)
Instead of returning a soft error message to the model when the worker can't be restarted, raise RLMWorkerRecoveryError (a SandboxError subclass) to cleanly abort the rollout. Continuing with a dead REPL just wastes turns. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0df300b commit dfd5650

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

verifiers/envs/experimental/rlm_env.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ class RLMCodeExecutionTimeout(Exception):
150150
"""Raised when code execution exceeds the configured timeout."""
151151

152152

153+
class RLMWorkerRecoveryError(vf.SandboxError):
154+
"""Raised when the RLM worker cannot be restarted after a failure."""
155+
156+
153157
@dataclass(frozen=True)
154158
class RLMWorkerPaths:
155159
base_dir: str
@@ -3952,19 +3956,19 @@ async def _execute_code(self, code: str, state: State) -> dict[str, Any]:
39523956
# Abort rollout immediately on timeout
39533957
raise vf.SandboxError() from e
39543958
recovered = await self._recover_from_code_timeout(state)
3955-
recovery_note = (
3956-
" The worker was restarted and the REPL state was reset."
3957-
if recovered
3958-
else " Failed to restart the worker; the REPL may be unusable."
3959-
)
3959+
if not recovered:
3960+
raise RLMWorkerRecoveryError(
3961+
"Code execution timed out and the worker could not be restarted."
3962+
) from e
39603963
# Return error to model so it can try more efficient code
39613964
return {
39623965
"status": "error",
39633966
"stdout": "",
39643967
"stderr": "",
39653968
"result": (
39663969
f"Code execution timed out after {self.code_execution_timeout} seconds."
3967-
f"{recovery_note} Your code may be too slow - consider a more "
3970+
" The worker was restarted and the REPL state was reset."
3971+
" Your code may be too slow - consider a more "
39683972
"efficient algorithm or breaking the computation into smaller steps."
39693973
),
39703974
"answer": {"ready": False, "content": ""},

0 commit comments

Comments
 (0)