Skip to content
DeepForgeby svx
All problems
MediumNLPnlp-267

Tool Error Retry Policy

Problem

Simulate a retry policy over attempt outcomes. After a failure that is in retryable, retry only while retries_used < max_retries; stop on 'success', on a non-retryable outcome, or when retries are exhausted.

Return [attempts, status] where status is the last outcome, 'success', or 'exhausted' when outcomes run out mid-retry.

Hint

max_retries counts retries after the first attempt, not total attempts.

Test cases

case 1
in: [["timeout","timeout","success"],["timeout"],2]
expected: [3,"success"]
case 2
in: [["timeout","timeout","success"],["timeout"],1]
expected: [2,"timeout"]
case 3
in: [["auth"],["timeout"],3]
expected: [1,"auth"]
case 4
in: [[],["timeout"],1]
expected: [0,"exhausted"]
case 5
in: [["timeout"],["timeout"],3]
expected: [1,"exhausted"]
Starter codePython
def tool_retry_policy(outcomes, retryable, max_retries):
    # Your code here
    pass

5 test cases · run your code against them in the editor