Module 9 Lesson 1: What are Tools?
The Agent's Hands. Understanding how to give an LLM the ability to execute code and interact with the physical world.
Tools: Giving the AI a "Body"
A standard LLM is like a "Brain in a Jar." It can think and write, but it cannot Do. It cannot check the current price of Bitcoin, it cannot send an email, and it cannot run a Python script. Tools are the bridge.
1. The Tool Cycle
- User: "What is the weather in London?"
- Model: Realizes it doesn't know. Sees a tool named
get_weather. - Model: Returns a "Tool Call" (JSON) instead of a text answer.
- Application: Executes the code for
get_weather("London"). - Model: Receives the result ("20 degrees") and writes the final answer.
2. Tools vs. Function Calling
- Function Calling: The raw API feature (from OpenAI/Anthropic) that outputs JSON.
- LangChain Tool: A high-level wrapper that includes a Name, a Description, and an optional Schema.
3. Why the "Description" is the most important part
The LLM doesn't see your Python code. It only sees the Description.
- Bad Description: "Function 1"
- Good Description: "Use this tool to calculate the square root of a number. Input must be an integer."
The LLM uses this description to "Decide" whether or not to use the tool.
4. Visualizing Tool Orchestration
graph TD
U[User Query] --> M[Model]
M -->|Look at tools| D[Tool Descriptions]
D -->|Match found| TC[Tool Call: 'search_web']
TC --> Code[Actual Python/API Logic]
Code --> Result[Data]
Result --> M
M --> Final[Natural Language Answer]
5. Engineering Tip: Atomic Tools
Do not build a "Swiss Army Knife" tool that does 10 things. Build 10 small, "Atomic" tools. This makes it much easier for the LLM to pick the right one without getting confused by a 500-word description.
Key Takeaways
- Tools allow models to interact with external APIs and data.
- Descriptions are the only way the AI knows what a tool does.
- The model does not run the code; your application runs the code based on the model's request.
- Atomic design is the secret to reliable tool selection.