Bird
Raised Fist0
Agentic AIml~20 mins

ReAct pattern (Reasoning + Acting) in Agentic AI - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
ReAct Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the core idea of ReAct pattern
What is the main advantage of combining reasoning and acting in the ReAct pattern for AI agents?
AIt allows the agent to alternate between thinking and taking actions, improving decision-making in complex tasks.
BIt enables the agent to skip reasoning and act immediately, saving time in all scenarios.
CIt forces the agent to only reason without ever taking actions, ensuring perfect planning.
DIt makes the agent act randomly without any reasoning, increasing exploration.
Attempts:
2 left
💡 Hint
Think about how combining thinking and doing helps solve problems step-by-step.
Predict Output
intermediate
2:00remaining
Output of a simple ReAct agent step
Given the following simplified ReAct agent code snippet, what will be the printed output after one reasoning and acting cycle?
Agentic AI
class SimpleReActAgent:
    def __init__(self):
        self.state = 0
    def reason(self):
        return f"Reasoning with state {self.state}"
    def act(self):
        self.state += 1
        return f"Acting to change state to {self.state}"
    def step(self):
        thought = self.reason()
        action = self.act()
        print(thought)
        print(action)
agent = SimpleReActAgent()
agent.step()
A
Reasoning with state 0
Acting to change state to 1
B
Reasoning with state 1
Acting to change state to 1
C
Acting to change state to 1
Reasoning with state 0
D
Reasoning with state 0
Reasoning with state 1
Attempts:
2 left
💡 Hint
Check the order of reasoning and acting in the step method.
Model Choice
advanced
2:00remaining
Choosing the best model for ReAct pattern
Which type of AI model is most suitable to implement the ReAct pattern effectively in a natural language task?
AA simple feedforward neural network without memory or sequential output capabilities.
BA convolutional neural network designed for image classification.
CA large language model with the ability to generate reasoning traces and actions sequentially.
DA clustering algorithm that groups data points without generating text.
Attempts:
2 left
💡 Hint
Consider which model can produce step-by-step reasoning and actions in text.
Metrics
advanced
2:00remaining
Evaluating ReAct agent performance
Which metric best captures the effectiveness of a ReAct agent in completing multi-step reasoning and acting tasks?
ATraining loss on a single-step classification task.
BTask success rate measuring how often the agent completes the task correctly.
CNumber of parameters in the model.
DTime taken to load the model into memory.
Attempts:
2 left
💡 Hint
Think about what shows the agent actually solves the task well.
🔧 Debug
expert
3:00remaining
Debugging a ReAct agent stuck in infinite reasoning
A ReAct agent repeatedly outputs reasoning steps without ever acting, causing an infinite loop. Which is the most likely cause?
AThe agent's state variable is incremented too quickly, skipping reasoning.
BThe agent's act() method is called but returns None, which is ignored.
CThe agent's reasoning method returns an empty string, causing a crash.
DThe agent's code never calls the act() method after reasoning, so it never performs actions.
Attempts:
2 left
💡 Hint
Check if the acting step is actually executed after reasoning.

Practice

(1/5)
1. What is the main purpose of the ReAct pattern in AI problem solving?
easy
A. To store large datasets efficiently
B. To speed up training of neural networks
C. To combine reasoning steps with actions for clearer problem solving
D. To replace human decision making completely

Solution

  1. Step 1: Understand the ReAct pattern components

    The ReAct pattern mixes reasoning (thought) and acting (actions) to solve problems step-by-step.
  2. Step 2: Identify the main goal

    Its goal is to help AI explain its reasoning clearly while using tools effectively.
  3. Final Answer:

    To combine reasoning steps with actions for clearer problem solving -> Option C
  4. Quick Check:

    ReAct = Reasoning + Acting [OK]
Hint: ReAct means think and do together for better answers [OK]
Common Mistakes:
  • Confusing ReAct with data storage methods
  • Thinking it speeds up training only
  • Believing it replaces humans fully
2. Which of the following shows the correct sequence of steps in the ReAct pattern?
easy
A. Action -> Thought -> Observation -> Final Answer
B. Thought -> Action -> Observation -> Final Answer
C. Observation -> Thought -> Action -> Final Answer
D. Final Answer -> Thought -> Action -> Observation

Solution

  1. Step 1: Recall the ReAct step order

    The ReAct pattern follows Thought (reasoning), then Action (doing), then Observation (seeing results), and finally Final Answer.
  2. Step 2: Match the correct sequence

    Thought -> Action -> Observation -> Final Answer matches this exact order.
  3. Final Answer:

    Thought -> Action -> Observation -> Final Answer -> Option B
  4. Quick Check:

    Step order = Thought, Action, Observation, Final Answer [OK]
Hint: Remember: Think first, then do, then check, then answer [OK]
Common Mistakes:
  • Swapping Action and Thought order
  • Placing Final Answer too early
  • Confusing Observation with Action
3. Given this simplified ReAct code snippet, what will be the final answer output?
thought = "Check if number is even"
action = "Divide number by 2"
observation = 4 / 2
final_answer = "Number is even" if observation == 2 else "Number is odd"
print(final_answer)
medium
A. None
B. Number is odd
C. Error: division by zero
D. Number is even

Solution

  1. Step 1: Evaluate the action and observation

    The action divides 4 by 2, resulting in observation = 2.
  2. Step 2: Determine the final answer based on observation

    Since observation == 2, the final answer is "Number is even".
  3. Final Answer:

    Number is even -> Option D
  4. Quick Check:

    4 / 2 = 2 -> even number [OK]
Hint: Check the observation value to decide final answer [OK]
Common Mistakes:
  • Confusing observation value with input number
  • Assuming division error
  • Ignoring the if-else condition
4. Identify the error in this ReAct pattern snippet:
thought = "Find square root"
action = "Calculate sqrt of 16"
observation = sqrt(16)
final_answer = "Square root is " + observation
print(final_answer)
medium
A. Missing import for sqrt function
B. Incorrect string concatenation with number
C. Wrong variable name for observation
D. No error, code runs fine

Solution

  1. Step 1: Check usage of sqrt function

    The code uses sqrt(16) but does not import sqrt from math module.
  2. Step 2: Identify missing import causing error

    Without 'from math import sqrt', this will cause a NameError.
  3. Final Answer:

    Missing import for sqrt function -> Option A
  4. Quick Check:

    sqrt needs import from math [OK]
Hint: Always import math functions before use [OK]
Common Mistakes:
  • Assuming string concatenation error
  • Thinking variable names are wrong
  • Believing code runs without imports
5. You want an AI agent using the ReAct pattern to answer: "Is 15 a prime number?" Which sequence best shows how the agent should reason and act?
hard
A. Thought: Check divisibility from 2 to 14 -> Action: Test divisibility by 3 -> Observation: 15 divisible by 3 -> Final Answer: Not prime
B. Thought: Check if 15 is even -> Action: Divide by 2 -> Observation: Not divisible -> Final Answer: Prime
C. Thought: Check if 15 is greater than 10 -> Action: Return yes -> Observation: None -> Final Answer: Prime
D. Thought: Guess number is prime -> Action: Return prime -> Observation: None -> Final Answer: Prime

Solution

  1. Step 1: Understand prime checking logic

    To check if 15 is prime, test divisibility by numbers from 2 up to 14.
  2. Step 2: Follow ReAct steps correctly

    The agent thinks about divisibility, acts by testing 3, observes 15 is divisible, then concludes not prime.
  3. Final Answer:

    Thought: Check divisibility from 2 to 14 -> Action: Test divisibility by 3 -> Observation: 15 divisible by 3 -> Final Answer: Not prime -> Option A
  4. Quick Check:

    Divisible by 3 means not prime [OK]
Hint: Test divisors stepwise to confirm prime status [OK]
Common Mistakes:
  • Only checking even divisibility
  • Guessing without testing
  • Ignoring observations in reasoning