Wait out a usage limit and retry, without counting it as a failed run

This commit is contained in:
2026-10-02 22:45:27 +02:00
parent 796d7d4901
commit e7ff869398
11 changed files with 106 additions and 23 deletions
+12
View File
@@ -390,6 +390,18 @@ class Cycles(unittest.TestCase):
self.assertIn("retrying the judge in a minute: the judge returned no reply; it replied: nothing\n", run.stderr)
self.assertEqual(run.stderr.strip().splitlines()[-1], 'the judge failed three times running: the judge\'s reply has no evidence of type string; it replied: {"structured_output": {"interrupt": false}}')
def test_waits_out_a_usage_limit_and_retries_without_counting_a_failure(self):
checkout = Checkout(self)
resets_at = int(time.time()) + 3600
rejected = json.dumps({"type": "rate_limit_event", "rate_limit_info": {"status": "rejected", "resetsAt": resets_at}})
limited = json.dumps({"type": "result", "api_error_status": 429, "is_error": True, "result": "You've hit your session limit"})
run = checkout.run([worker(exit=1), worker(stream=f"{rejected}\n{limited}\n", result=False, exit=1), worker(exit=1), worker(), judge(stdout=limited, exit=1), judge()])
self.assertEqual(run.code, 130)
self.assertEqual(run.roles(), ["worker"] * 4 + ["judge"] * 2 + ["worker"])
self.assertEqual([round(seconds, -1) for seconds in run.sleeps], [60, 3720, 60, 600])
self.assertIn(f"the worker hit a usage limit; retrying at {time.strftime('%Y-%m-%d %H:%M', time.localtime(resets_at + 120))}\n", run.stderr)
self.assertIn("the judge hit a usage limit; retrying at ", run.stderr)
def test_retries_the_judge_alone_when_its_verdict_quotes_nothing_in_the_transcript(self):
checkout = Checkout(self)
run = checkout.run([