Bird
0
0

Why does this code raise an error?

medium📝 Debug Q7 of 15
LangChain - Agents
Why does this code raise an error?
from langchain.agents import AgentExecutor
agent_executor = AgentExecutor(agent=None, tools=[])
agent_executor.run("Test")
AAgentExecutor does not accept keyword arguments
BAgent cannot be None; it must be a valid agent instance
Crun() requires two arguments
Dtools list cannot be empty
Step-by-Step Solution
Solution:
  1. Step 1: Check agent parameter validity

    Passing agent=None is invalid because AgentExecutor expects a valid agent object.

  2. Step 2: Verify other parameters

    An empty tools list is allowed; run() takes one argument; keyword args are accepted.

  3. Final Answer:

    Agent cannot be None; it must be a valid agent instance -> Option B
  4. Quick Check:

    Agent must be valid, not None [OK]
Quick Trick: AgentExecutor needs a real agent, not None [OK]
Common Mistakes:
MISTAKES
  • Thinking empty tools list causes error
  • Assuming run() needs more args
  • Believing keyword args are disallowed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes