liveBook · Manning

AI agent

As explained in Build Applications with Local AI Models on a Mac

An AI agent is a software system that perceives information, reasons about tasks, and takes actions to accomplish goals, including software-development tasks.

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

How Build Applications with Local AI Models on a Mac covers it

How deep it goes
Explains tool choice and the evaluate-and-act loop, but stops short of connecting a model or implementing that loop.
Examples
Uses calculator and current-date tools in a Python listing, plus a calculator-choice scenario.
What it assumes
Introduces the action loop from a plain-language LLM definition while using Python for the illustrative tool listing.
What you can do after
Evaluate/understand an agent’s tool choices and costs, then experiment with LangChain tools before building a full agent.
How it connects
Connects LLMs to tool calling, LangChain, local models, and hosted API costs.

Also explained in

Compare how 33 books explain AI agent →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Applications with Local AI Models on a Mac. The section links point to the parts of the book it draws on.