0
0
LangChainframework~20 mins

AgentExecutor setup and configuration in LangChain - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
AgentExecutor Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What is the output of this AgentExecutor run?
Given this LangChain AgentExecutor setup, what will be the printed output?
LangChain
from langchain.agents import initialize_agent, AgentType
from langchain.llms import OpenAI

llm = OpenAI(temperature=0)
agent = initialize_agent([], llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
result = agent.run("What is 2 plus 2?")
print(result)
A"4"
B"What is 2 plus 2?"
CSyntaxError due to missing tools
DRuntimeError: No tools provided
Attempts:
2 left
💡 Hint
Think about what the agent does when no tools are provided but the LLM can answer simple questions.
📝 Syntax
intermediate
2:00remaining
Which option correctly initializes AgentExecutor with tools?
Select the code snippet that correctly creates an AgentExecutor with a tool list and an OpenAI LLM.
A
from langchain.agents import initialize_agent, AgentType
from langchain.llms import OpenAI

llm = OpenAI(temperature=0)
tools = [MyTool()]
agent = initialize_agent(tools, llm, verbose=True)
B
from langchain.agents import AgentExecutor
from langchain.llms import OpenAI

llm = OpenAI(temperature=0)
agent = AgentExecutor(llm=llm, tools=[MyTool()])
C
from langchain.agents import initialize_agent
from langchain.llms import OpenAI

llm = OpenAI(temperature=0)
tools = [MyTool()]
agent = initialize_agent(llm, tools, verbose=True)
D
from langchain.agents import initialize_agent, AgentType
from langchain.llms import OpenAI

llm = OpenAI(temperature=0)
tools = [MyTool()]
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
Attempts:
2 left
💡 Hint
Check the order of arguments and the use of AgentType in initialize_agent.
🔧 Debug
advanced
2:00remaining
Why does this AgentExecutor raise a TypeError?
Consider this code snippet: from langchain.agents import initialize_agent, AgentType from langchain.llms import OpenAI llm = OpenAI(temperature=0) agent = initialize_agent([], llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) result = agent.run(12345) print(result) Why does it raise a TypeError?
ABecause OpenAI LLM does not accept numeric inputs
BBecause the tools list is empty, causing a TypeError
CBecause the input to agent.run must be a string, not an integer
DBecause verbose=True causes a conflict with integer inputs
Attempts:
2 left
💡 Hint
Check the type expected by the run method of AgentExecutor.
state_output
advanced
2:00remaining
What is the value of agent.tools after initialization?
Given this code: from langchain.agents import initialize_agent, AgentType from langchain.llms import OpenAI class DummyTool: def run(self, input): return "done" llm = OpenAI(temperature=0) tools = [DummyTool()] agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=False) What is the value of agent.tools?
A[<__main__.DummyTool object at memory_address>]
B[]
CNone
D["done"]
Attempts:
2 left
💡 Hint
Think about what initialize_agent does with the tools list.
🧠 Conceptual
expert
2:00remaining
Which statement best describes AgentExecutor's role in LangChain?
Choose the most accurate description of what AgentExecutor does in LangChain.
AAgentExecutor is a simple wrapper that only runs an LLM without any tool integration.
BAgentExecutor manages the interaction between an LLM and a set of tools to answer complex queries by deciding when and how to use each tool.
CAgentExecutor is responsible for training the LLM models used in LangChain.
DAgentExecutor only handles input validation and does not execute any logic.
Attempts:
2 left
💡 Hint
Think about how LangChain agents combine language models and tools.