Bird
Raised Fist0
Agentic AIml~20 mins

Rate limiting and budget controls in Agentic AI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Rate Limiting & Budget Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Rate Limiting Purpose

Why is rate limiting important in managing AI agent requests?

ATo reduce the accuracy of AI model predictions intentionally
BTo allow unlimited requests without any restrictions
CTo prevent system overload by controlling the number of requests in a time frame
DTo increase the speed of all incoming requests simultaneously
Attempts:
2 left
💡 Hint

Think about what happens if too many requests come at once.

Model Choice
intermediate
1:30remaining
Choosing a Budget Control Strategy

You want to limit the total compute cost of AI agent calls over a month. Which budget control method is best?

ASet a fixed maximum number of API calls allowed per month
BDisable rate limiting and monitor usage manually
CAllow unlimited calls but slow down the response time
DIncrease the model size to reduce calls
Attempts:
2 left
💡 Hint

Think about how to keep costs predictable.

Predict Output
advanced
2:00remaining
Output of Rate Limiting Code Snippet

What is the output of this Python code simulating a simple rate limiter?

Agentic AI
import time

class RateLimiter:
    def __init__(self, max_calls, period):
        self.max_calls = max_calls
        self.period = period
        self.calls = []

    def allow(self):
        current = time.time()
        self.calls = [call for call in self.calls if call > current - self.period]
        if len(self.calls) < self.max_calls:
            self.calls.append(current)
            return True
        return False

limiter = RateLimiter(3, 5)
results = []
for _ in range(5):
    results.append(limiter.allow())
    time.sleep(1)
print(results)
A[False, False, False, False, False]
B[True, True, True, True, True]
C[True, False, True, False, True]
D[True, True, True, False, False]
Attempts:
2 left
💡 Hint

Consider how many calls are allowed within the 5-second window.

Metrics
advanced
1:30remaining
Interpreting Budget Control Metrics

You have a budget control system that tracks 'calls_used' and 'calls_remaining'. If calls_used = 750 and calls_remaining = 250, what is the total budget and percentage used?

ATotal budget is 1000 calls; 75% used
BTotal budget is 1000 calls; 25% used
CTotal budget is 500 calls; 150% used
DTotal budget is 1000 calls; 50% used
Attempts:
2 left
💡 Hint

Add used and remaining calls to find total, then calculate percentage.

🔧 Debug
expert
2:00remaining
Debugging Budget Control Logic

Given this budget control snippet, what error will occur when running it?

Agentic AI
class BudgetControl:
    def __init__(self, max_calls):
        self.max_calls = max_calls
        self.calls_made = 0

    def make_call(self):
        if self.calls_made < self.max_calls:
            self.calls_made += 1
            return True
        else:
            return False

budget = BudgetControl(3)
results = [budget.make_call() for _ in range(5)]
print(results)
print(budget.calls_remaining)
AIndexError: list index out of range
BAttributeError: 'BudgetControl' object has no attribute 'calls_remaining'
CTypeError: unsupported operand type(s) for +: 'int' and 'str'
DNo error; output is [True, True, True, False, False]
Attempts:
2 left
💡 Hint

Check if all attributes used are defined in the class.