0
0
Agentic_aiml~20 mins

Caching and result reuse in Agentic Ai - Practice Problems & Coding Challenges

Choose your learning style8 modes available
Challenge - 5 Problems
🎖️
Caching Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 conceptual
intermediate
1:30remaining
Why is caching important in agentic AI workflows?

Imagine you have an AI agent that performs multiple steps to answer a question. Why would caching intermediate results help?

AIt makes the agent forget previous steps faster.
BIt increases the randomness of the agent's answers.
CIt reduces repeated calculations, saving time and resources.
DIt forces the agent to always start from scratch.
Attempts:
2 left
💻 code output
intermediate
2:00remaining
What is the output of this caching example?

Consider this Python code simulating caching in an AI agent:

cache = {}
def expensive_step(x):
    if x in cache:
        return cache[x]
    result = x * x  # Simulate expensive calculation
    cache[x] = result
    return result

print(expensive_step(3))
print(expensive_step(3))
print(expensive_step(4))

What will be printed?

A
9
9
9
B
9
None
16
C
3
3
4
D
9
9
16
Attempts:
2 left
model choice
advanced
2:30remaining
Which caching strategy best suits agentic AI with changing inputs?

You have an AI agent that processes user queries with slight variations. Which caching method helps reuse results without returning outdated answers?

ACache results with approximate matching and expiration time.
BDo not use caching at all.
CCache all results indefinitely without checking input.
DCache results with exact input keys only.
Attempts:
2 left
metrics
advanced
1:30remaining
How does caching affect AI agent performance metrics?

An AI agent uses caching to store intermediate results. Which metric is most directly improved by caching?

AModel accuracy on test data
BInference latency (time to get a result)
CTraining loss during model training
DNumber of model parameters
Attempts:
2 left
🔧 debug
expert
3:00remaining
Why does this caching code cause incorrect reuse?

Review this Python snippet for caching AI agent results:

cache = {}
def process(input_data):
    if 'result' in cache:
        return cache['result']
    result = input_data + 1
    cache['result'] = result
    return result

print(process(5))
print(process(10))

What is the problem with this caching approach?

AIt caches only one result regardless of input, causing wrong reuse.
BIt does not cache any results, so no reuse happens.
CIt raises a KeyError because 'result' key is missing.
DIt caches results correctly for each input.
Attempts:
2 left