Overview

1 Understanding agentic applications

This chapter introduces agentic applications as systems that wrap large language models with tools, memory, and autonomous reasoning so they can pursue goals through multi-step loops rather than single prompt-response exchanges. It distinguishes fully autonomous AI agents—where the model directs its own reasoning and tool use—from agentic workflows, where developers define a controllable graph of steps with optional dynamic routing. The motivation is pragmatic: real work spans judgment-heavy, multi-stage processes, and well-designed agentic systems can compress hours of manual coordination into minutes, while poorly designed ones waste tokens and erode trust. The book adopts CrewAI to teach both the practical primitives and the design mindset needed to build these systems.

The core building block is the augmented LLM: retrieval for external knowledge, tools for acting in the world, and memory for state. Function calling lets models request tool executions in structured form, turning text predictors into capable operators. The chapter surveys proven design patterns—prompt chaining with validation gates, routing to specialized handlers, parallelization via sectioning and voting, orchestrator‑workers for dynamic delegation, and evaluator‑optimizer loops for reflection—and advises choosing the simplest combination that meets requirements, usually starting with workflows and adding autonomy selectively. CrewAI’s primitives map cleanly to these patterns: agents (defined by role, goal, backstory), tasks with clear success criteria and structured outputs, tools with focused purposes, plus crews and flows that combine controlled logic with pockets of agentic reasoning. Emphasis is placed on small, focused agents with limited tool sets and on investing heavily in task design.

Shipping agentic applications is hard: errors compound across steps, token costs rise quickly, evaluation is nondeterministic and must assess intermediates, human oversight is essential for impactful actions, and long contexts degrade model performance, making context management a first-class concern. The recommended progression is incremental—single call, then augmented LLM, then workflow, and only then multi‑agent—while monitoring reliability, retries, and cost and choosing model tiers appropriately. The chapter closes by positioning CrewAI’s crews and flows as practical orchestration mechanisms and by introducing the Model Context Protocol, which CrewAI can both consume and expose, enabling standardized connections to external capabilities and broader interoperability.

At the heart of each AI agent is the agent loop, in which the LLM reasons, calls tools at will, and decides when to stop.
In an agentic workflow, the system follows code paths that were pre-defined by the developer. Those steps can include arbitrary logic expressed in code, LLM calls, as well as dynamic routing based on the results of a previous step.
The application sends the user's prompt along with tool definitions to the LLM. Instead of answering directly, the LLM returns a structured tool call. The application + executes the tool and sends the result back, and the LLM produces its final response. The LLM never executes tools itself — it only requests them.
Each agent is initialized with a role, goal, and a compelling backstory.
The documentation writer agent has a well-defined role, a clearly laid out goal, and a compelling backstory. It has access to three tools: one to search the web for a specific query, one to summarize a snippet of text, and one to format any given text as markdown to create a nice document.
A crew is like a cross-functional team that works on a given set of tasks until they are completed.
An example flow that generates a book based on a topic that is given as input and returns a link to a generated PDF in the end. It contains two crews that are being executed in two different steps of the workflow, a shared state, parallel execution, and dynamic routing based on the output of a crew.

Summary

  • Agentic AI turns a model that predicts text into a system that gets work done. An AI agent reasons, calls tools, observes results, and loops until the task is complete. Agentic workflows follow developer-defined code paths and trade flexibility for predictability.
  • The augmented LLM is the atomic building block of every agentic system: a language model enhanced with retrieval, tools, and memory.
  • Five recurring design patterns cover most agentic architectures: prompt chaining, routing, parallelization, orchestrator-workers, and evaluator-optimizer. They sit on a spectrum from simple to complex, and real applications often combine several.
  • Production agentic systems face compounding errors across steps, high token costs, non-deterministic evaluation, the need for human oversight, and context degradation over long interactions.
  • CrewAI organizes agentic systems around agents (defined by role, goal, and backstory), tasks, tools, crews, and flows. Crews handle multi-agent collaboration, while flows give explicit control over execution order and logic. MCP connects agents to external capabilities through a standardized protocol.

FAQ

Why aren’t raw LLMs enough for real-world tasks?On their own, LLMs take a prompt, generate text, and stop. They don’t autonomously plan multi-step work, call external tools, or iterate based on feedback. Real work (research, reviews, ticket resolution) requires multi-step judgment, which is why we wrap LLMs with tools, control loops, and logic—i.e., agentic systems.
What is agentic AI and how does the agent loop work?Agentic AI augments an LLM with tools and autonomous reasoning so it can pursue goals. The LLM reasons about next steps, invokes tools as needed, observes results, and repeats until it decides the task is done—the core “agent loop.”
What’s the difference between an AI agent and an agentic workflow?AI agents let the LLM direct its own loop and decide when to stop. Agentic workflows follow developer-defined graphs (nodes/edges) with optional dynamic routing. In practice, most production systems are workflows with agentic elements: you keep predictable control of steps while using LLM intelligence within them.
What is an “augmented LLM” and how does it help me debug?An augmented LLM adds three capabilities: retrieval (bring in external knowledge), tools (take actions via APIs/files/DBs), and memory (maintain state across steps). When things go wrong, ask: did retrieval provide bad context, did a tool fail, or did the model lose state?
How do LLMs actually call tools (function calling)?Modern LLMs are trained to emit structured tool calls. Your app provides tool schemas; the LLM decides to call one and returns a function_call with arguments. Your code executes the tool and feeds its result back, and the LLM continues reasoning. The LLM never executes tools itself—it only requests them.
Which design patterns should I know for agentic applications?Common patterns include: prompt chaining (sequential steps with gates), routing (send inputs to specialized handlers), parallelization (run sections or voting in parallel), orchestrator-workers (an LLM decomposes work and delegates), and evaluator-optimizer (generator + critic loop). Real apps often mix these—choose the simplest combo that works.
What makes agentic apps hard to run in production?Five big challenges: errors compound across steps (e.g., 95% per step drops to ~60% over 10 steps), costs balloon (agents can use 5–20× tokens), evaluation is non-deterministic, human oversight is required for risky actions, and long contexts degrade model focus. Guiding principle: start simple—single call → augmented LLM → simple workflow → multi-agent only when needed.
What is CrewAI and what are its core building blocks?CrewAI is an open-source framework with composable primitives—agents, tasks, tools, crews, and flows—for turning goals into coordinated multi-step workflows. It balances ease-of-use with deep configurability and maps directly onto common agentic patterns like chaining, orchestration, and parallelization.
How do I design effective agents in CrewAI?Use the Role-Goal-Backstory pattern: a concise role (domain expertise), a clear goal (measurable outcome), and a backstory (consistent voice/decisions). Prefer small, focused agents with few tools; too many tools hurts performance (models degrade well before hard limits like 128, and environments like Cursor cap active tools around 40).
What are tasks, crews, flows, and MCP—and when do I use each?- Tasks: precise “tickets” that define success and outputs; use structured outputs (e.g., Pydantic). Follow the 80/20 rule: invest more in great tasks than agent prompts. - Crews: teams of agents executing tasks via sequential or hierarchical processes (maps to chaining and orchestrator-workers). - Flows: explicit, code-first workflows with conditionals, parallelism, error recovery, and state; embed agents/crews where autonomy helps. - MCP: an open standard to plug tools in/out; CrewAI can consume MCP servers’ tools and expose your crews via MCP to other AI clients.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Building Agentic Applications with CrewAI and MCP ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Building Agentic Applications with CrewAI and MCP ebook for free