Bird
0
0

Given this code snippet, what will the ReAct agent do when asked a question?

medium📝 Predict Output Q4 of 15
LangChain - Agents
Given this code snippet, what will the ReAct agent do when asked a question?
tools = [SearchTool(), CalculatorTool()]
agent = initialize_agent(tools, llm, agent_type='react')
response = agent.run('What is 5 plus 3?')
AThrow an error due to missing tool parameters
BReturn a generic answer without calculation
CUse SearchTool to find unrelated web results
DUse CalculatorTool to compute and return '8'
Step-by-Step Solution
Solution:
  1. Step 1: Identify tools available to the agent

    The agent has CalculatorTool and SearchTool available.
  2. Step 2: Determine which tool fits the question

    The question asks for a math calculation, so CalculatorTool is used.
  3. Final Answer:

    Use CalculatorTool to compute and return '8' -> Option D
  4. Quick Check:

    Math question triggers CalculatorTool = C [OK]
Quick Trick: Match question type to tool capability [OK]
Common Mistakes:
MISTAKES
  • Assuming generic answer without tool use
  • Expecting error without cause
  • Using wrong tool for math question

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes