Poindexter-Labs/PDL-SWE-Bench huggingface dataset:
Domain: HTTP-client retry helper

Issue:
Fix the retry function so that the maximum retry count is respected when the wrapped operation raises a timeout.

Repository files:
content: # Present so pytest adds the repository root to sys.path, making `import src`
# resolve from the test suite.

path: conftest.py

content: # No third-party dependencies — this example task is pure standard library.
# (Kept as a lockfile so the offline install path is still exercised.)

path: requirements.lock

path: src/__init__.py

content: """A tiny retry helper."""


class Timeout(Exception):
    """Raised when the wrapped operation times out."""


def retry(operation, max_attempts):
    """Call ``operation`` until it returns a value, or until ``max_attempts``
    calls have failed, then re-raise the last exception.

    ``operation`` is a zero-argument callable. ``max_attempts`` is the maximum
    number of times ``operation`` may be called.
    """
    last_exc = None
    attempts = 0
    while attempts <= max_attempts:
        try:
            return operation()
        except Exception as exc:  # noqa: BLE001 - retry on any operation error
            last_exc = exc
            attempts += 1
    raise last_exc

path: src/retry.py

content: """Tests for the retry helper."""

from src.retry import retry, Timeout


def test_returns_first_success_without_retrying():
    calls = []

    def op():
        calls.append(1)
        return "ok"

    assert retry(op, max_attempts=3) == "ok"
    assert len(calls) == 1


def test_retries_until_success():
    calls = []

    def op():
        calls.append(1)
        if len(calls) < 2:
            raise Timeout("slow")
        return "ok"

    assert retry(op, max_attempts=5) == "ok"
    assert len(calls) == 2

path: tests/public/test_retry.py

Reference patch:
--- a/src/retry.py
+++ b/src/retry.py
@@ -14,7 +14,7 @@
     """
     last_exc = None
     attempts = 0
-    while attempts <= max_attempts:
+    while attempts < max_attempts:
         try:
             return operation()
         except Exception as exc:  # noqa: BLE001 - retry on any operation error


Hidden acceptance tests (diff):
diff --git a/tests/hidden/test_retry_hidden.py b/tests/hidden/test_retry_hidden.py
new file mode 100644
--- /dev/null
+++ b/tests/hidden/test_retry_hidden.py
@@ -0,0 +1,26 @@
+"""Hidden test — NOT visible to the agent. Mounted only for final evaluation.
+
+This is the FAIL_TO_PASS test: it fails on the buggy code (which calls the
+operation one time too many) and passes once the max-attempts guard is fixed.
+The runner runs this with the frozen workspace on PYTHONPATH so `import src`
+resolves.
+"""
+
+from src.retry import retry, Timeout
+
+
+def test_respects_max_attempts_on_timeout():
+    calls = []
+
+    def op():
+        calls.append(1)
+        raise Timeout("always times out")
+
+    try:
+        retry(op, max_attempts=3)
+    except Timeout:
+        pass
+    else:  # pragma: no cover - guard for a wrong return path
+        raise AssertionError("expected Timeout to propagate after max_attempts")
+
+    assert len(calls) == 3, f"expected exactly 3 attempts, got {len(calls)}"