|
29 | 29 | save_manual_compiler_prompt, |
30 | 30 | ) |
31 | 31 | from backend.shared.config import system_config |
| 32 | +from backend.shared.api_client_manager import RetryableProviderError |
32 | 33 | from backend.shared.models import ( |
33 | 34 | ProofCandidate, |
34 | 35 | ProofCheckRequest, |
@@ -1418,33 +1419,32 @@ async def record_failed_candidate(self, *_args, **_kwargs): |
1418 | 1419 | stage._prepare_candidate = fake_prepare_candidate |
1419 | 1420 | stage._run_smt_check = fake_smt_check |
1420 | 1421 | try: |
1421 | | - result = await stage.run( |
1422 | | - content="brainstorm source", |
1423 | | - source_type="brainstorm", |
1424 | | - source_id="topic_001", |
1425 | | - user_prompt="prove things", |
1426 | | - submitter_model="model", |
1427 | | - submitter_context=4000, |
1428 | | - submitter_max_tokens=1000, |
1429 | | - validator_model="validator", |
1430 | | - validator_context=4000, |
1431 | | - validator_max_tokens=1000, |
1432 | | - broadcast_fn=broadcast, |
1433 | | - novel_proofs_db=FakeProofDb(), |
1434 | | - theorem_candidates=[candidate], |
1435 | | - append_to_source=False, |
1436 | | - checkpoint_callback=checkpoint, |
1437 | | - ) |
| 1422 | + with self.assertRaises(RetryableProviderError) as exc: |
| 1423 | + await stage.run( |
| 1424 | + content="brainstorm source", |
| 1425 | + source_type="brainstorm", |
| 1426 | + source_id="topic_001", |
| 1427 | + user_prompt="prove things", |
| 1428 | + submitter_model="model", |
| 1429 | + submitter_context=4000, |
| 1430 | + submitter_max_tokens=1000, |
| 1431 | + validator_model="validator", |
| 1432 | + validator_context=4000, |
| 1433 | + validator_max_tokens=1000, |
| 1434 | + broadcast_fn=broadcast, |
| 1435 | + novel_proofs_db=FakeProofDb(), |
| 1436 | + theorem_candidates=[candidate], |
| 1437 | + append_to_source=False, |
| 1438 | + checkpoint_callback=checkpoint, |
| 1439 | + ) |
1438 | 1440 | finally: |
1439 | 1441 | proof_formalization_module.api_client_manager.generate_completion = old_generate_completion |
1440 | 1442 | system_config.lean4_enabled = old_lean4_enabled |
1441 | 1443 |
|
1442 | | - self.assertTrue(result.had_error) |
1443 | | - self.assertIn("TRANSIENT PROVIDER ERROR", result.error_message) |
1444 | | - self.assertEqual(result.total_candidates, 1) |
1445 | | - self.assertIn("error", checkpoint_statuses) |
1446 | | - self.assertIn("proof_check_complete", events) |
| 1444 | + self.assertIn("TRANSIENT PROVIDER ERROR", str(exc.exception)) |
| 1445 | + self.assertIn("provider_paused", checkpoint_statuses) |
1447 | 1446 | self.assertNotIn("proof_attempts_exhausted", events) |
| 1447 | + self.assertNotIn("proof_check_complete", events) |
1448 | 1448 |
|
1449 | 1449 | async def test_codex_transient_identification_error_does_not_mark_no_candidates(self): |
1450 | 1450 | old_lean4_enabled = system_config.lean4_enabled |
@@ -1473,30 +1473,30 @@ class FakeProofDb: |
1473 | 1473 | old_generate_completion = proof_identification_module.api_client_manager.generate_completion |
1474 | 1474 | proof_identification_module.api_client_manager.generate_completion = raise_codex_gateway_timeout |
1475 | 1475 | try: |
1476 | | - result = await stage.run( |
1477 | | - content="brainstorm source", |
1478 | | - source_type="brainstorm", |
1479 | | - source_id="topic_identification_timeout", |
1480 | | - user_prompt="prove things", |
1481 | | - submitter_model="model", |
1482 | | - submitter_context=4000, |
1483 | | - submitter_max_tokens=1000, |
1484 | | - validator_model="validator", |
1485 | | - validator_context=4000, |
1486 | | - validator_max_tokens=1000, |
1487 | | - broadcast_fn=broadcast, |
1488 | | - novel_proofs_db=FakeProofDb(), |
1489 | | - append_to_source=False, |
1490 | | - checkpoint_callback=checkpoint, |
1491 | | - ) |
| 1476 | + with self.assertRaises(RetryableProviderError) as exc: |
| 1477 | + await stage.run( |
| 1478 | + content="brainstorm source", |
| 1479 | + source_type="brainstorm", |
| 1480 | + source_id="topic_identification_timeout", |
| 1481 | + user_prompt="prove things", |
| 1482 | + submitter_model="model", |
| 1483 | + submitter_context=4000, |
| 1484 | + submitter_max_tokens=1000, |
| 1485 | + validator_model="validator", |
| 1486 | + validator_context=4000, |
| 1487 | + validator_max_tokens=1000, |
| 1488 | + broadcast_fn=broadcast, |
| 1489 | + novel_proofs_db=FakeProofDb(), |
| 1490 | + append_to_source=False, |
| 1491 | + checkpoint_callback=checkpoint, |
| 1492 | + ) |
1492 | 1493 | finally: |
1493 | 1494 | proof_identification_module.api_client_manager.generate_completion = old_generate_completion |
1494 | 1495 | system_config.lean4_enabled = old_lean4_enabled |
1495 | 1496 |
|
1496 | | - self.assertTrue(result.had_error) |
1497 | | - self.assertIn("OpenAI Codex failed", result.error_message) |
1498 | | - self.assertIn("error", checkpoint_statuses) |
1499 | | - self.assertIn("proof_check_complete", events) |
| 1497 | + self.assertIn("OpenAI Codex failed", str(exc.exception)) |
| 1498 | + self.assertEqual(checkpoint_statuses, []) |
| 1499 | + self.assertNotIn("proof_check_complete", events) |
1500 | 1500 | self.assertNotIn("proof_check_no_candidates", events) |
1501 | 1501 |
|
1502 | 1502 | async def test_malformed_identification_output_does_not_mark_no_candidates(self): |
|
0 commit comments