Bird
0
0

How can you extend a tool to handle multiple commands dynamically within the same function when used by an agent?

hard📝 Application Q9 of 15
LangChain - Agents
How can you extend a tool to handle multiple commands dynamically within the same function when used by an agent?
AUse a Tool with no function and rely on the agent to handle commands
BCreate multiple Tools each handling one command and switch between them manually
CModify the agent code to ignore tool functions and handle commands internally
DWrite a function that parses the input command and executes different logic accordingly, then wrap it in a Tool
Step-by-Step Solution
Solution:
  1. Step 1: Design a flexible tool function

    Implement a function that reads the input command and runs different code paths based on it.
  2. Step 2: Wrap this function in a Tool for agent use

    Pass this Tool to the agent so it can call the same tool for multiple commands.
  3. Final Answer:

    Write a function that parses the input command and executes different logic accordingly, then wrap it in a Tool -> Option D
  4. Quick Check:

    One Tool function can handle multiple commands [OK]
Quick Trick: Parse commands inside one Tool function [OK]
Common Mistakes:
MISTAKES
  • Creating many single-command Tools unnecessarily
  • Leaving Tool function empty
  • Ignoring tool functions in agent

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes