Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion frognano/runtimes/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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}"
Expand Down
4 changes: 4 additions & 0 deletions tests/test_kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down