Building Complex Multi-Agent Systems Using Pattern Prompting: A guide to building robust and secure GenAI applications using software engineering best practices

Building Complex Multi-Agent Systems Using Pattern Prompting: A guide to building robust and secure GenAI applications using software engineering best practices

Building Complex Multi-Agent Systems Using Pattern Prompting: A guide to building robust and secure GenAI applications using software engineering best practices
Автор: O'Brien Tim
Дата выхода: 2026
Издательство: Packt Publishing Limited
Количество страниц: 310
Размер файла: 2,8 МБ
Тип файла: PDF
Добавил: codelibs

Building Complex Multi-Agent Systems Using Pattern Prompting....2

A guide to building robust and secure GenAI applications using software engineering best practices....2

Building Complex Multi-Agent Systems Using Pattern Prompting....3

Contributors....5

About the author....5

About the reviewers....6

Table of Contents....8

Preface....20

Who this book is for....21

What this book covers....21

To get the most out of this book....23

Download the example code files....25

Download the color images....25

Conventions used....25

Get in touch....26

Earn an Advanced Proof-Of-Knowledge Certificate from Quizitive....26

Free benefits with your book....27

How to Unlock....28

Share your thoughts....28

1....30

Introduction: Patterns, Abstractions, and the GenAI Landscape....30

A vocabulary bridge: GenAI terms and their IT equivalents....31

Studying GenAI....32

On the use of abstractions and patterns....34

How patterns are used in this book....35

Benefits of breaking down GenAI microarchitectures into their constituent patterns....36

What is an LLM?....37

LLM as a continuation of big data....38

LLM as a badly behaving RESTful endpoint....38

How do LLMs work?....39

What is agentic AI?....41

Summary....42

Get This Book's PDF Version and Exclusive Extras....43

2....44

Embeddings: The Language of AI....44

What are embeddings?....45

What do vectors look like?....46

What is affinity?....47

Calculating semantic similarity programmatically....50

Selecting an embedding model....51

Testing embeddings in your code....52

What are vector databases?....53

Chunking documents....55

Chunking decisions....56

Chunking strategies....57

Summary....59

Subscribe for a free eBook....60

3....62

Building with GenAI: Parameters, Tuning, and Project Phases....62

Tuning GenAI systems: principles and practices....63

Tuning the parameters of your GenAI project....64

1) Document Chunking....65

2) Chunking Retrieval....66

3) Retrieval Prompting....66

4) Model ContextTokens Prompts....66

5) Temperature ties to prompt behavior....66

Configuring a GenAI application to answer any question about the Harry Potter books....67

Chunking strategies....70

Temperature....72

Best practices for building a GenAI project....75

Project initiation....76

Intermediate goals....76

Crossing the finish line....77

Summary....78

Get This Book's PDF Version and Exclusive Extras....79

4....80

Building Your First RAG App....80

What does "production-grade" software mean?....81

Making technology choices: advantages of queues and topics....84

Why RabbitMQ for enterprise-grade GenAI systems....85

Quick tour of RabbitMQ....87

Building a production-class RAG application using RabbitMQ with integration patterns....92

Building the LLM client....96

Template Method....97

Adapter....98

Strategy....98

Generating code and deployment configuration....99

Deploying our solution....100

Summary....101

Subscribe for a free eBook....102

5....104

Starting Your Data Migration Project....104

Identifying documents to ingest into the vector database....105

Selecting the right ETL tool....106

Planning your data pipeline....109

Capacity planning and throughput....109

Handling change and continuous operations....110

Ensuring security, privacy, and compliance....111

Managing parallel pipelines and CICD....111

Testing and validation....113

Cost optimization and throttling....113

Evaluating retrieval quality....114

Knowledge structure and advanced retrieval (optional)....114

Hybrid search and the limits of pure vector retrieval....115

The importance of data cleaning in GenAI pipelines....116

Graph databases and the emergence of knowledge graphs....117

Toward integrated knowledge retrieval....118

Summary....119

Get This Book's PDF Version and Exclusive Extras....119

6....120

Ingesting Data Using Airbyte and Pinecone....120

Analysis of applicable patterns....121

Integration patterns implemented by ETL....122

Channel adapter....122

Strategy pattern....123

Strategy pattern (producer)....123

Strategy pattern (receiver)....124

Building our ETL pipeline....124

Installation of Pinecone and Airbyte....125

Analysis of documents....125

Options for configuring Airbyte....126

Configuring Airbyte using its no-code interface....127

Importing a YAML manifest....130

Summary....131

Subscribe for a free eBook....132

7....134

Tips and Best Practices....134

Tips and best practices to help make your GenAI project a success....135

Best practices for designing and operating GenAI systems....135

Have an R&D mindset....135

Don't be afraid to reason things out yourself....135

Discover your own agentic patterns....136

Lead with small POCs first – keep all POCs under 2 days....137

Set latency and throughput targets and load test frequently....137

Have a plan for managing drift....137

Don't use data produced by GenAI with your other IT systems....138

Validate your UX with extensive usability testing....138

Efficient project management....138

Security and data privacy....140

Prompt injection attacks....140

Data leakage through context windows....141

Handling PII in prompts....141

Output validation and harmful content filtering....142

Compliance considerations by industry....142

Building a security-first culture....143

Cost management and token budgeting....143

Building a cost model early....144

Choosing the right model for each task....145

Fine-tuning as a cost optimization strategy....146

Setting cost alerts, budgets, and governance....146

Vendor lock-in and model portability....147

Prompt versioning and governance....147

Treat prompts as code....148

Adopt a versioning strategy....148

Establish review and approval workflows....148

Enable prompt rollback....148

Define ownership and accountability....148

Evaluation and testing frameworks....149

Building your evaluation dataset....149

Automating evaluation pipelines....149

Red-teaming your application....149

Handling non-determinism in tests....150

Testing for drift....150

Summary....150

Get This Book's PDF Version and Exclusive Extras....151

8....152

Pattern-Guided Coding: Using Patterns as the Design Vocabulary for GenAI Systems Built on RabbitMQ....152

The need for pattern-guided coding....154

Reason 1: Communication breaks down without a shared vocabulary....155

Reason 2: Design decisions become invisible....155

Reason 3: GenAI systems fail at the integration layer....155

How pattern-guided coding works....156

Building your app in a four-step Topologos process....158

Phase 1: Clarification before design....158

Phase 2: Pattern analysis across four lenses....159

Phase 3: Iterative approval one decision at a time....160

Phase 4: Final topology output....161

Building producers and consumers with GoF patterns....164

The Strategy pattern for producer routing....164

The Command pattern for agent task messages....165

The Template Method pattern for consumer pipelines....166

The Channel Adapter pattern for external integration....166

Consumer acknowledgment and the manual ACK rule....167

The multi-tier dead-letter queue strategy....167

Generating any known GenAI pattern with a single command....169

Getting ready to deploy....169

The iterative approval loop....171

Auditing an existing system....171

Customizing your GenAI application....172

Case study: extending a single-LLM RAG to a dual-LLM Scatter-Gather....172

The before topology: single LLM....172

The Topologos session: proposing the change....173

The new queue topology: dual LLM with Scatter-Gather....175

What changed and what stayed the same....175

The Aggregator's correlation window....177

Summary....180

Subscribe for a free eBook....180

9....182

Implementing the ReAct Pattern Over RabbitMQ....182

Understanding the ReAct pattern....183

Setting up the RabbitMQ topology....184

Building the ReAct agent....194

Message schemas....194

The LLM call (_think)....194

Tool dispatch (_dispatch_tool)....195

The loop and ACK strategy....195

Implementing tool workers....206

Error handling in tool workers....207

Scaling....207

Sending commands to the agent....214

Running the system end to end....216

Setting up....216

Start the workers....217

Send a question....217

Observing the dead letter queue....218

Preparing the system for production....220

Summary....221

Get This Book's PDF Version and Exclusive Extras....222

10....224

The Future and Limitations of LLMs....224

LLMs actually do: a precise description....225

The stochastic parrot: fluency without understanding....226

Chomsky and the limits of statistical learning....227

Searle's Chinese room: syntax is not semantics....227

Penrose, Gdel, and the mathematical limits of computation....228

The reasoning gap: what LLMs cannot reliably do....229

Systematic mathematical reasoning....229

Maintain logical consistency over long contexts....229

Provide calibrated confidence in their responses....229

Produce novel insights....230

The symbol grounding problem....230

What the hype gets wrong: a taxonomy of overclaiming....230

Why hype is harmful: the engineering costs....232

What LLMs are genuinely good at....232

Thinking about the future with clear eyes....233

Practical guidance: working productively with known limitations....234

Summary....235

Subscribe for a free eBook....235

Appendix A....236

Pattern Reference: GoF, Enterprise Integration, Reliability, and GenAI Microarchitecture Patterns....236

Pattern index....237

Part 1 GoF Design Patterns....238

A.1 Strategy....238

GoF Behavioral Chapters 4, 6....238

A.2 Adapter....239

GoF Structural Chapters 4, 6....239

A.3 Template Method....239

GoF Behavioral Chapter 4....239

Part 2 Enterprise Integration Patterns....240

A.4 Message Channel....240

EIP Messaging Infrastructure Chapters 4, 6....240

A.5 Channel Adapter....241

EIP Messaging Infrastructure Chapters 4, 6....241

A.6 Publish–Subscribe Channel....241

EIP Messaging Chapter 4....241

A.7 Content Enricher....242

EIP Message Transformation Chapters 3, 4....242

A.8 Request–Reply....243

EIP Messaging Chapter 4....243

A.9 Correlation Identifier....244

EIP Messaging Chapter 4....244

A.10 Scatter–Gather....244

EIP Message Routing Chapter 4....244

A.11 Dead Letter Channel....245

EIP Messaging Chapter 4....245

A.12 Message History....246

EIP System Management Chapter 4....246

A.13 Content-Based Router....246

EIP Message Routing Chapter 4....246

A.14 Pipes and Filters....247

EIP Message Routing Chapters 5, 6....247

Part 3 Reliability Patterns....247

A.15 Circuit Breaker....247

Reliability Pattern Chapter 4....247

A.16 Retry with Exponential Backoff....248

Reliability Pattern Chapters 4, 7....248

Part 4 Microarchitecture Patterns....249

A.17 Orchestration....249

Microarchitecture Pattern Chapters 1, 4, 7....249

A.18 Choreography....249

Microarchitecture Pattern Chapters 1, 7....249

A.19 RAG Microarchitecture....250

GenAI Microarchitecture Chapters 2, 3, 4, 5....250

Hybrid retrieval....251

Chunking strategies....252

Embedding flow....252

Production query flow....253

Appendix B....254

Topologos User Manual....254

Quick start....255

Loading the prompt....255

Starting a session....255

Conversational....255

Pattern-first....255

Topology first....256

Approve decisions one at a time....256

Get your deployable artifact....256

When to use Topologos....256

Core concepts....257

The two layers – pattern versus topology....257

Cross-layer example....258

The four-phase protocol....258

Example Phase 1 acknowledgment (fast path)....259

Example Phase 3 decision....259

Command reference....260

All commands at a glance....260

Session commands....262

Example status output....262

Pattern layer commands....263

Topology layer commands....263

Definition commands....263

Operational commands....264

Example validate output....264

Example simulate tool-timeout output....264

Example cost output....265

Diagram commands....265

Modifiers....266

Auto-derived templates....267

Generating the deployable artifact....268

End-to-end workflow....268

The seven Phase 4 artifacts....268

Running deploy....269

Targets....269

Modifiers....270

Examples....270

Rendering diagrams to PNG....271

Mermaid (default)....271

Graphviz DOT....271

SVG....271

PlantUML....271

Applying the manifest to a real broker....271

Route 1 – rabbitmqadmin (CLI)....271

Route 2 – Management HTTP API....272

Route 3 – Terraform (recommended for production)....272

Generating it inline – a typical full session....272

Worked examples....273

Example A – Generating ReAct conversationally....273

Phase 2 (excerpt)....274

Phase 3 – eight decisions (selected highlights)....274

Phase 4 manifest excerpt....275

Example B – Composed pattern (ReAct Tool Use)....276

Invocation....276

What changes vs. canonical ReAct?....276

Why compose rather than extend....276

Example C – Extending a canonical pattern (critic gate)....276

Invocation....277

Phase 1 acknowledgment....277

Additional Phase 3 decisions....277

Chaining multiple extensions....277

Example D – Defining a new pattern (Debate-and-Adjudicate)....278

Step 1 – invoke define....278

Step 2 – Topologos validates and echoes a synthetic reference card....278

Step 3 – compose, extend, persist....279

When to define vs. extend vs. compose....279

Example E – Defining an organization-wide topology archetype....279

Scenario....280

Step 1 – define the queue archetype....280

Step 2 – define the DLQ topology....280

Step 3 – define the security baseline....281

Step 4 – bundle them as a topology archetype....281

Step 5 – use it and lay a pattern on top....281

Step 6 – persist across sessions....281

The payoff....282

Recipes....282

Tips and best practices....284

Troubleshooting....284

FAQs....286

Glossary....288

Canonical pattern reference....290

ReAct....290

Plan-and-Execute....290

Reflection....291

Tool Use....291

Multi-Agent Collaboration....291

RAG....291

Memory....292

Orchestrator-Subagent....292

Human-in-the-Loop....292

Tree of Thoughts....293

Topology-layer canonical primitives....293

Appendix C....296

Unlock Your Exclusive Benefits....296

Unlock this Book's Free Benefits in 3 Easy Steps....297

Step 1....297

Step 2....297

Step 3....298

Need Help....298

Why subscribe?....300

Other Books You May Enjoy....301

Packt is searching for authors like you....303

Share your thoughts....303

Index....304

Learn how to build GenAI applications using proven software engineering patterns instead of rapidly changing frameworks. This book helps engineers build secure, scalable agentic systems with familiar tools and practical, engineer-to-engineer architectural guidance.

You will connect GenAI concepts such as agentic workflows, embeddings, and vector databases to enterprise patterns, including components, adapters, and microarchitectures. Established GoF and enterprise design patterns help explain agentic behavior and system design, enabling you to reason about architecture rather than memorize tools. The book also shows you how to generate multi-agent and GenAI patterns as RabbitMQ configurations for scalable orchestration and communication.

Using language-agnostic examples and widely used messaging, orchestration, and data technologies, you will build production-ready systems that integrate with existing infrastructure without unnecessary complexity. You will also use our Topologos prompt to build, modify, and test deploy-ready multi-agent systems quickly while improving robustness and maintainability.

By the end of this book, you will be able to design reliable GenAI systems, make informed architectural decisions, and adapt confidently as tools and frameworks evolve.


Похожее:

Список отзывов:

Нет отзывов к книге.