Skip to content

The agent that grows with you

test: teach the hand-rolled fake pools the failure_reason kwarg

Brooklyn Nicholson9712b8f0cc71
diff --git a/tests/run_agent/test_codex_xai_oauth_recovery.py b/tests/run_agent/test_codex_xai_oauth_recovery.py
index aecbe40b8b0..57dc20efa94 100644
--- a/tests/run_agent/test_codex_xai_oauth_recovery.py
+++ b/tests/run_agent/test_codex_xai_oauth_recovery.py
@@ -456,9 +456,14 @@ def test_recover_with_credential_pool_rotates_on_xai_spending_limit_403():
status_code,
error_context=None,
api_key_hint=None,
+ failure_reason=None,
):
assert status_code == 403
assert api_key_hint == "test-key"
+ # An xAI spending-limit 403 classifies as billing, and the pool
+ # must be told so — otherwise a sole-credential pool gives a spent
+ # account the transient 60s cooldown instead of the full bench.
+ assert failure_reason == "billing"
assert error_context == {
"reason": "personal-team-blocked:spending-limit",
"message": (
diff --git a/tests/run_agent/test_run_agent.py b/tests/run_agent/test_run_agent.py
index 473e869faf7..e26728214dc 100644
--- a/tests/run_agent/test_run_agent.py
+++ b/tests/run_agent/test_run_agent.py
@@ -4680,10 +4680,12 @@ class TestCredentialPoolRecovery:
status_code,
error_context=None,
api_key_hint=None,
+ failure_reason=None,
):
assert status_code == 402
assert error_context is None
assert api_key_hint == agent.api_key
+ assert failure_reason == "billing"
return next_entry
agent._credential_pool = _Pool()
@@ -4710,11 +4712,13 @@ class TestCredentialPoolRecovery:
return []
def mark_exhausted_and_rotate(
- self, *, status_code, error_context=None, api_key_hint=None
+ self, *, status_code, error_context=None, api_key_hint=None,
+ failure_reason=None,
):
assert status_code == 429
assert error_context is None
assert api_key_hint == agent.api_key
+ assert failure_reason == "rate_limit"
return next_entry
agent._credential_pool = _Pool()