An AI agent is an LLM that can take actions, not just generate text. Given a task, it can choose to search the web, read a file, run a calculation, or call an API, then use the result to decide what to do next. section 16.5
The evaluate-and-act loop works like this:
- Receive the task and descriptions of available tools. section 16.5.1
- Judge whether a tool is useful. If so, choose one and supply its input; otherwise, answer directly. section 16.5.2
- Read the tool’s result and answer, or repeat the loop for a multistep task. section 16.5.2
When a calculator helps
If a task needs multiplication, an agent can select a calculator tool from its description, pass in the numbers, and use the returned result in its answer. Tool descriptions matter: the model uses their wording to judge relevance rather than following a fixed selection rule. section 16.5.1 section 16.5.2
from langchain_core.tools import tool
# Define tools the agent can use
@tool
def calculator(a: float, b: float) -> str:
"""Multiply two numbers. Use this for multiplication."""
return f"The result of {a} * {b} is {a * b}"
@tool
def get_current_date() -> str:
"""Get today's date. Use this when asked about today's date."""
from datetime import date
return f"Today's date is {date.today().isoformat()}"
# List of available tools
tools = [calculator, get_current_date]
print("Available tools:")
for t in tools:
print(f" - {t.name}: {t.description}")
This Python listing defines a calculator and a current-date tool with LangChain Core, then prints their names and descriptions. It shows the available-tool layer—not a connected Ollama model or a working agent loop. section 16.5.1
Agent performance depends on the model. Smaller local models such as gemma3:4b have limited agent capabilities; larger models can do more. Repeated reasoning and tool calls also make cost important: hosted APIs charge for input and output tokens, while local inference avoids API token fees but still needs hardware and electricity. Compare quality, latency, token use, and other costs before choosing a deployment. section 16.5.2 section 16.5.6
































