Real assistants need several tools. Riverside Books' agent should check stock, look up the price, and find a book's author. The agent must pick the right tool, or tools, for each question.
We give the agent three small tools, check stock, get price, and get author, which live in a helper file, written just like before. Then we ask one question that needs two of them, the price and the stock of The Hobbit. Run it. We list the tools the agent chose to call, and its final answer. It picked exactly the two it needed, and combined the results.
three_tools.pypython
from langchain.agents import create_agentfrom shop_tools import check_stock, get_price, get_author # three @tool functionsagent = create_agent("google_genai:gemini-flash-lite-latest", tools=[check_stock, get_price, get_author])question = "Price and stock of The Hobbit? One sentence."out = agent.invoke({"messages": [{"role": "user", "content": question}]})used = sorted(c["name"] for m in out["messages"] for c in getattr(m, "tool_calls", []))print("tools used:", used)print(out["messages"][-1].text)
Output
tools used: ['check_stock', 'get_price']
The Hobbit is priced at £8.99 and there are 7 copies in stock.
Also uses shop_tools.py
from langchain.tools import toolBOOKS = { "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"},}@tooldef check_stock(title: str) -> int: """Copies of a book in stock at Riverside Books.""" return BOOKS.get(title, {}).get("stock", 0)@tooldef get_price(title: str) -> float: """Price of a book in pounds.""" return BOOKS.get(title, {}).get("price", 0.0)@tooldef get_author(title: str) -> str: """Author of a book.""" return BOOKS.get(title, {}).get("author", "unknown")
With many tools, choice gets harder. Keep each tool focused on one job. Make the descriptions clearly different from each other. Avoid two tools that do almost the same thing. And if you have dozens of tools, consider splitting them across several smaller agents.
An agent with several tools picks the right ones for each question, and combines the results. Clear, distinct descriptions make that easier. Next, giving the agent a job description.