Tools in a Graph
Bind_tools.
To build an agent by hand, we first give the model some tools. Bind tools tells the model which tools exist. The model doesn't run them. It replies with tool calls, saying which tool to use, with which arguments.

- Give the model tools
- bind_tools
- It asks, it doesn't run
Asking for tool calls
Our shop tools come from a helper file. Check stock, get price, and get author. Bind tools gives them to the model. We ask a question that needs two of them. Run it. The reply has no text answer yet. Instead it has two tool calls, each with a name, and arguments.
from langchain.chat_models import init_chat_model
from shop_tools import check_stock, get_price, get_author
model = init_chat_model("google_genai:gemini-flash-lite-latest", temperature=0)
model_with_tools = model.bind_tools([check_stock, get_price, get_author])
reply = model_with_tools.invoke("Is Dune in stock, and how much is it?")
for call in reply.tool_calls:
print(call["name"], call["args"])check_stock {'title': 'Dune'}
get_price {'title': 'Dune'}Also uses shop_tools.py
from langchain.tools import tool
BOOKS = {
"The Hobbit": {"stock": 7, "price": 8.99, "author": "J.R.R. Tolkien"},
"Dune": {"stock": 3, "price": 9.99, "author": "Frank Herbert"},
"Circe": {"stock": 0, "price": 10.99, "author": "Madeline Miller"},
}
@tool
def check_stock(title: str) -> int:
"""Copies of a book in stock at Riverside Books."""
return BOOKS.get(title, {}).get("stock", 0)
@tool
def get_price(title: str) -> float:
"""Price of a book in pounds."""
return BOOKS.get(title, {}).get("price", 0.0)
@tool
def get_author(title: str) -> str:
"""Author of a book."""
return BOOKS.get(title, {}).get("author", "unknown")Tool calls
A tool call has a name, the arguments, and an ID. The model chooses tools by reading their names and docstrings, so describe each tool clearly. Next, we need something to actually run the calls.
| key | value |
|---|---|
| name | which tool |
| args | the inputs |
| id | matches the result |
| Docstrings | how the model chooses |
Summary
Bind tools tells the model about tools, and it replies with tool calls. Something else must run them. Next, the tool node.
Key takeaways- bind_tools([...])
- reply.tool_calls
- name, args, id