liveBook · Manning

Chapter 12: Employing agents

What you will learn in chapter 12 of Spring AI in Action

Introduces generative AI agents as goal-oriented actors while noting that their precise definition is debated.

After this chapter you will be able to

What it builds on

Section by section

Introduction

Introduces generative AI agents as goal-oriented actors while noting that their precise definition is debated.

Key terms: generative AI agents, autonomous, agentic workflow, goal

12.1 Understanding agents

The section explains augmented LLMs, common agentic workflow patterns, and the book’s broad use of the term “agent.”

Key terms: augmented LLM, retrieval, tools, memory, ChatClient, agentic workflows, prompt chaining, routing, parallelization, orchestrator-workers

12.2 Implementing agentic workflows and patterns

This introduction previews prompt chaining, routing, and parallelization as workflow patterns to be implemented with Spring AI and ChatClient.

12.2.1 Chaining prompts

Builds a linear Spring Boot workflow that chains two actions to fetch a board game’s rules and identify its mechanics.

Key terms: Action, act(), Chain, AgentWorkflowAskController, RuleFetcherAction, ChatClient, TikaDocumentReader, boardgame.rules.path, MechanicsDeterminerAction, system message

12.2.2 Routing tasks

This section shows how to keep agentic actions focused and use an LLM-powered router to send each question to the appropriate workflow chain.

Key terms: Single Responsibility Principle, PlayerCountAction, MechanicsDeterminerAction, prompt template, Router, ChatClient, Chain, Chain bean’s ID, AgentWorkflowAskController

12.2.3 Applying parallelization

This section shows how to run game-question actions in parallel, combine and summarize their answers, and connect them in an explicitly configured workflow.

Key terms: parallelization, ParallelizerAction, worker actions, CompletableFuture, act(), AgentWorkflowConfig, Chain, RuleFetcherAction, SummarizerAction, LLM

12.3 Creating self-planning agentic solutions

Introduces Embabel as a Spring AI–based JVM framework that plans paths through agent actions without requiring developers to define workflows explicitly.

Key terms: actions, pre- and postconditions, Goal-Oriented Action Planning (GOAP), agentic planning, Embabel, Spring AI

12.3.1 Initializing an Embabel project

This section sets up a Java Spring Boot project for an Embabel agent and adds the build configuration needed to use Embabel.

Key terms: Spring Initializr, Spring Web, Java, Embabel’s project creator, uvx, build file, Embabel’s repository, Maven Central, Embabel agent starter

12.3.2 Defining the agent class

This section defines an Embabel agent class and two goal-achieving actions that use game rules to determine game mechanics and player counts.

Key terms: GameInfoAgent, @Agent, @Action, @AchievesGoal, determineGameMechanics(), determinePlayerCount(), GameRules, Resource, promptResourceToString(), StringTemplate

12.3.3 Defining an action to get game rules

This section explains how Embabel uses action-method types to derive a workflow and defines an action that loads and returns game rules.

Key terms: Embabel, @Action, type safety, workflow, getGameRules(), @AchievesGoal, end state, TikaDocumentReader, rulesFilePath, RulesFile

12.3.4 Defining an action to get the rules filename

This subsection explains how an intermediate action obtains the rules filename needed by the game-rules action.

Key terms: getGameRulesFilename(), RulesFile, GameTitle, prompt template, goal-achieving action method

12.3.5 Defining an action to get the game title

Defines the agent’s first action, which extracts a game title from user input, and explains where that input comes from.

Key terms: extractGameTitle(), GameTitle, PromptRunner, prompt template, UserInput, Embabel

12.3.6 Running the agent via Embabel’s shell

This section shows how to use Embabel’s development shell to run the game agent and inspect how it chooses actions and reports results.

Key terms: agent shell, @EnableAgentShell, shell, SPRING_PROFILES_ACTIVE, execute, actions, goals, determinePlayerCount(), determineGameMechanics(), blackboard

12.3.7 Accessing the agent via MCP

This subsection shows how to run an Embabel agent as an MCP Server, export its goal-achieving actions as tools, and try those tools with MCP Inspector.

Key terms: @EnableAgentShell, shell, MCP Server, @AchievesGoal, export, @Export, UserInput, MCP tool, MCP Inspector, server.port

12.4 Summary

Concepts explained in this chapter

← Chapter 11: Applying generative AI patterns

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.