diff --git a/frognano/runtimes/kubernetes.py b/frognano/runtimes/kubernetes.py index f161de2..5afd017 100644 --- a/frognano/runtimes/kubernetes.py +++ b/frognano/runtimes/kubernetes.py @@ -33,6 +33,10 @@ _COMMAND_CONTROL_ATTEMPTS = 3 _COMMAND_START_GRACE = 60 _OUTPUT_CHUNK_BYTES = 49152 +# `git add -A` over the whole worktree runs after the agent has finished; on a +# large repository or a loaded node it can exceed the 120 s command default, +# and a timeout here discards the completed agent run and replays the task. +_GIT_STAGING_TIMEOUT = 600 _CHECK_COREUTILS = r""" set -eo pipefail @@ -751,6 +755,7 @@ def get_patch(self) -> str: f"git -C {repo} diff --cached --binary 2>/dev/null; " f"rc=$?; git -C {repo} reset --mixed HEAD >/dev/null 2>&1; " f"exit $rc", + timeout=_GIT_STAGING_TIMEOUT, workdir="/", ) if exit_code != 0: @@ -771,7 +776,7 @@ def compute_reward(self) -> tuple[float, str]: # Harbor verifiers clean untracked files; preserve agent-created files # after the non-mutating patch capture has reset the index. if self._has_git_checkout(): - output, exit_code = self.run("git add -A", timeout=120) + output, exit_code = self.run("git add -A", timeout=_GIT_STAGING_TIMEOUT) if exit_code != 0: raise RuntimeError( f"could not stage agent changes for grading: {output}" diff --git a/tests/test_kubernetes.py b/tests/test_kubernetes.py index 7d51c39..d33275b 100644 --- a/tests/test_kubernetes.py +++ b/tests/test_kubernetes.py @@ -84,15 +84,19 @@ def test_get_patch_resets_index_after_capture() -> None: runtime = object.__new__(KubernetesTaskRuntime) runtime.task = {"repo_path": "/testbed"} commands = [] + timeouts = [] def run(command, *, timeout=120, workdir=None): commands.append(command) + timeouts.append(timeout) return "diff --git a/file b/file", 0 runtime.run = run assert runtime.get_patch().startswith("diff --git") assert "git -C /testbed reset --mixed HEAD" in commands[0] + # A finished agent run must not be discarded by the 120 s command default. + assert timeouts[0] >= 600 @pytest.mark.parametrize(