Bird
0
0

Identify the error in this tool creation code:

medium📝 Debug Q14 of 15
LangChain - Agents
Identify the error in this tool creation code:
def add_numbers(a, b):
    return a + b

from langchain.agents import Tool

add_tool = Tool(name='add', func=add_numbers, description='Adds two numbers')

result = add_tool.func(5)
print(result)
AMissing one argument when calling add_tool.func
BTool name must be uppercase
CDescription is too short
DFunction add_numbers should not return a value
Step-by-Step Solution
Solution:
  1. Step 1: Check function parameters

    add_numbers requires two arguments: a and b.
  2. Step 2: Check function call

    add_tool.func is called with only one argument (5), missing the second argument.
  3. Final Answer:

    Missing one argument when calling add_tool.func -> Option A
  4. Quick Check:

    Function needs 2 args, call has 1 = D [OK]
Quick Trick: Match function parameters with call arguments count [OK]
Common Mistakes:
MISTAKES
  • Ignoring argument count mismatch
  • Thinking tool name case matters
  • Assuming description length causes error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes