You should see intervals.py, retry.py, two test files, README.md and TASKS.md directly inside that folder.
Python 3.10+
The initial local check needs Python 3.10+ on your computer; the MonkeyCode task environment also needs Python to check the fix. It uses the standard library only. Running it locally by hand needs no account or API key. Get Python ↗
Before opening the project in MonkeyCode, open a terminal in the extracted folder containing intervals.py and run this command.
Check command
python3 -m unittest discover -v
On Windows, if python3 is unavailable but the Python launcher is installed, use py -3 in its place in every command and in the prompt.
Expected before the fix
Ran 8 tests
FAILED (failures=1)
8 tests run. Only test_touching_is_not_overlap fails. This failure is the starting point of the exercise.
Seeing “Ran 0 tests”? Check the working folder. Zero tests is not a passing result for this exercise.
Open these files in MonkeyCode
In your browser
Put the extracted example files in a new GitHub repository you own.
In MonkeyCode settings, connect your GitHub identity and grant access to that repository.
Create a project, give it a name and select the connected identity and example repository.
Start a task for the example project, check the selected repository and model, then paste the prompt below into the task input.
Start a local task in the example folder. Confirm the folder and model, then paste the prompt below into the task input.
Paste this into MonkeyCode
Fix the half-open interval bug in intervals.py: (1, 3) and (3, 5) must not overlap. Only change intervals.py; do not weaken tests. Run python3 -m unittest discover -v. Report the diff, exact command and outcome. Done: all 8 existing tests pass, including the touching, empty and reversed cases.
Let the task finish, then review the changed files and its check output. Keep the original tests.
04
Check the result
Run the same check command again and review the diff. Use these three checks to decide whether to accept the change.
Check command
python3 -m unittest discover -v
✓Only intervals.py was edited; generated cache files do not count as source changes.
✓The original tests are unchanged and all 8 pass, including touching, empty and reversed intervals.
✓The task reports the change, the exact command and its result.
Expected after the fix
Ran 8 tests
OK
Check the test count as well as “OK”. A different correct implementation is fine if it meets the task requirements.
↗
All three checks passed? Your first task is complete.
You have opened a project, requested a focused change and checked the result yourself. Save the diff before starting another task.
Keep going, when you’re ready
TASKS.md includes two optional follow-ups. Treat each as a separate task and review its changes against the previous step.
Add four retry-policy tests without changing retry.py. The total should reach 12 passing tests.
Add a “How it works” section to README.md without changing code. All 12 tests should still pass.
Reference solution & check output+
Compare after trying the task. These locally checked reference files show the expected behavior; they are not a recorded MonkeyCode run.
Before · one failing testreturn a[0] <= b[1] and b[0] <= a[1]
[1, 3) + [3, 5) → True
After · eight passing testsreturn a[0] < b[1] and b[0] < a[1]
[1, 3) + [3, 5) → False
The results below are a locally authored and tested Codex reference exercise, not a MonkeyCode product run or a customer benchmark. No timing, token-cost or agent-success rate is claimed.
1. Bug fix
Touching intervals do not overlap. Only intervals.py changes.
Open recorded output and diff
--- a/intervals.py
+++ b/intervals.py
@@ -2,4 +2,4 @@
def overlaps(a, b):
if a[0] >= a[1] or b[0] >= b[1]:
return False
- return a[0] <= b[1] and b[0] <= a[1]
+ return a[0] < b[1] and b[0] < a[1]
test_empty (test_intervals.IntervalTests.test_empty) ... ok
test_reversed (test_intervals.IntervalTests.test_reversed) ... ok
test_separated (test_intervals.IntervalTests.test_separated) ... ok
test_shared_interior (test_intervals.IntervalTests.test_shared_interior) ... ok
test_touching_is_not_overlap (test_intervals.IntervalTests.test_touching_is_not_overlap) ... ok
test_budget (test_retry.RetryTests.test_budget) ... ok
test_success (test_retry.RetryTests.test_success) ... ok
test_transient (test_retry.RetryTests.test_transient) ... ok
----------------------------------------------------------------------
Ran 8 tests in 0.000s
OK
2. Add tests
Four retry tests cover rate limits, permanent errors, budget boundaries and invalid arguments.
test_empty (test_intervals.IntervalTests.test_empty) ... ok
test_reversed (test_intervals.IntervalTests.test_reversed) ... ok
test_separated (test_intervals.IntervalTests.test_separated) ... ok
test_shared_interior (test_intervals.IntervalTests.test_shared_interior) ... ok
test_touching_is_not_overlap (test_intervals.IntervalTests.test_touching_is_not_overlap) ... ok
test_before_budget (test_retry.AddedRetryTests.test_before_budget) ... ok
test_invalid_attempts (test_retry.AddedRetryTests.test_invalid_attempts) ... ok
test_permanent_error (test_retry.AddedRetryTests.test_permanent_error) ... ok
test_rate_limit (test_retry.AddedRetryTests.test_rate_limit) ... ok
test_budget (test_retry.RetryTests.test_budget) ... ok
test_success (test_retry.RetryTests.test_success) ... ok
test_transient (test_retry.RetryTests.test_transient) ... ok
----------------------------------------------------------------------
Ran 12 tests in 0.000s
OK
3. Explain the code
A README section explains the two modules and keeps the reproducible command.
Open recorded output and diff
--- a/README.md
+++ b/README.md
@@ -9,3 +9,11 @@
```
The initial interval test intentionally fails. Work on a copy.
+
+## How it works
+
+- `intervals.py` checks half-open intervals: touching endpoints do not overlap.
+- Empty or reversed intervals never overlap.
+- `retry.py` retries 408, 429, 500, 502, 503 and 504 responses only.
+- A retry is allowed only while `attempt < max_attempts`; attempts start at 1.
+- Non-positive attempt values or budgets raise `ValueError`.
test_empty (test_intervals.IntervalTests.test_empty) ... ok
test_reversed (test_intervals.IntervalTests.test_reversed) ... ok
test_separated (test_intervals.IntervalTests.test_separated) ... ok
test_shared_interior (test_intervals.IntervalTests.test_shared_interior) ... ok
test_touching_is_not_overlap (test_intervals.IntervalTests.test_touching_is_not_overlap) ... ok
test_before_budget (test_retry.AddedRetryTests.test_before_budget) ... ok
test_invalid_attempts (test_retry.AddedRetryTests.test_invalid_attempts) ... ok
test_permanent_error (test_retry.AddedRetryTests.test_permanent_error) ... ok
test_rate_limit (test_retry.AddedRetryTests.test_rate_limit) ... ok
test_budget (test_retry.RetryTests.test_budget) ... ok
test_success (test_retry.RetryTests.test_success) ... ok
test_transient (test_retry.RetryTests.test_transient) ... ok
----------------------------------------------------------------------
Ran 12 tests in 0.000s
OK
Unzip the reference archive, enter its top-level folder and run python3 verify.py. It uses temporary copies and checks the intentional failure, the fixes, the documentation and a mutation. The public answers make this unsuitable as a blind benchmark.
Check command
python3 verify.py
Need a hand?
Do I need an account or an API key?
The local Python exercise itself needs neither. To ask MonkeyCode to do the task, the hosted service needs an account and available model usage; the desktop app needs an available account or configured model connection.
What if Python is missing?
Install Python 3.10 or later in the environment where the tests run. Check python3 --version there. On Windows with the Python launcher, use py -3 --version and replace python3 with py -3 in the commands and prompt.
Why does the first check fail?
The starter deliberately contains a boundary bug. Expect 8 tests with exactly one failure, test_touching_is_not_overlap. If you see zero tests or a different failure, check the folder, Python installation and starter files first.
Why can’t I see my GitHub repository?
Check the connected GitHub account and the app’s repository access. Organization repositories may require owner approval. Refresh the repository selection after changing access.
What if the task does not fix the bug?
Keep the failure output and ask for a correction within the same file scope. If tests or unrelated source files were changed, start with a freshly extracted copy. Accept the result only after all 8 original tests pass.
We use cookies only for analytics (GA4 + Matomo) to improve the docs. No ads, no tracking across sites.