liveBook · Manning

AI agent

As explained in Hugging Face in Action

An agent is a specialized AI system that autonomously performs tasks by understanding language, reasoning and planning, selecting tools, and delivering results.

An AI agent is a specialized system that autonomously performs tasks by understanding natural language, reasoning and planning, selecting tools, and delivering results. It can break an ambiguous or multistep request into subtasks, call APIs or scripts, process their outputs, and return a coherent response. section 9.1

An agent typically performs four connected actions:

  • Interpret a user query with a large language model. section 9.1
  • Analyze the task, plan steps, and decide how to proceed. section 9.1
  • Select and execute known tools such as search engines, APIs, or custom scripts. section 9.1
  • Process tool outputs and deliver a clear answer. section 9.1

Search agent with smolagents

A minimal search agent combines a hosted model with DuckDuckGoSearchTool and runs a natural-language query: `model = HfApiModel(); agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model); response = agent.run("How long does it take to travel from New York to Los Angeles by train?")`. CodeAgent reasons by generating and executing Python code, while run() returns the final answer. The model can instead connect to a local Ollama server through LiteLLMModel. section 9.2.1

Figure 9.1 Roles of an agent
A diagram of a diagram

AI-generated content may be incorrect.

Use the role diagram to navigate the agent’s cycle of understanding language, planning, acting with tools, and delivering results. section 9.1

Frameworks shape the implementation. smolagents emphasizes lightweight experimentation and Python-code execution; LangChain composes prompts, memory, tools, and chains; LangGraph supports complex, stateful, multistep workflows and agent memory. section 9.0 section 9.3

How Hugging Face in Action covers it

How deep it goes
Explains agent roles, demonstrates a search agent, and extends implementation across smolagents, LangChain, and LangGraph.
Examples
Uses a weather agent, a DuckDuckGo search agent, hosted and local models, Python execution, and custom tools.
What it assumes
Assumes familiarity with language-model applications while introducing agent fundamentals, tools, state, memory, and framework setup.
What you can do after
Build agents with smolagents, LangChain, or LangGraph and equip them with tools, execution logic, state, and memory.
How it connects
Connects agents to large language models, tools, memory, prompt templates, chains, LangChain, smolagents, LangGraph, and ReAct.

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 Hugging Face in Action. The section links point to the parts of the book it draws on.