[go: up one dir, main page]

0% found this document useful (0 votes)
35 views55 pages

2025 04 GIDS OptimizingWorkflows EventDrivenMultiAgentic

The document discusses optimizing complex workflows using an event-driven multi-agentic approach, led by Mary Grygleski, who emphasizes the role of generative AI and agentic architecture. It covers the integration of retrieval-augmented generation (RAG) models, the benefits and challenges of event-driven systems, and the application of multi-agent systems in various contexts. Key concepts include agentic orchestration, autonomous decision-making, and the importance of standardization through protocols like Model Context Protocol (MCP) and Agent2Agent Protocol (A2A).

Uploaded by

Nick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views55 pages

2025 04 GIDS OptimizingWorkflows EventDrivenMultiAgentic

The document discusses optimizing complex workflows using an event-driven multi-agentic approach, led by Mary Grygleski, who emphasizes the role of generative AI and agentic architecture. It covers the integration of retrieval-augmented generation (RAG) models, the benefits and challenges of event-driven systems, and the application of multi-agent systems in various contexts. Key concepts include agentic orchestration, autonomous decision-making, and the importance of standardization through protocols like Model Context Protocol (MCP) and Agent2Agent Protocol (A2A).

Uploaded by

Nick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Optimizing Complex Workflows with

Event-Driven Multi-Agentic Approach

Mary Grygleski
Director of Emerging Technologies
@mgrygles April 2025
● Who’s Mary?

● GenAI and Agentic Architecture

● The Event-Driven World and AI ?

Agenda
● Applying Event Approach to: RAG

● Applying Event Approach to Agents and Workflows

● Challenges of GenAI

● Resources

2
01
Who is Mary?

3
mgrygles
Mary Grygleski
mary-grygleski
Java Champion
Passionate mgrygles
Advocate

mgrygles

Chicago Java
Users Group
President

➢ Generative AI
GenAI Collective - Chicago
➢ Streaming
Chapter Organizer ➢ Distributed Systems
➢ Reactive Systems
Director of Emerging Technologies ➢ IoT/MQTT
➢ Real-Time AI/ML
02
Generative AI and
Agentic Architecture

5
DATA
Generative Models
b l e
i ni Sta usion
m f
Ge
e mma Dif
G

GPT-3.5 BERT (
?)
GPT-4.0 Dall
ex o ini
Mid
Jo Cod - 4
T o-m ini -E
urne
y
P
G 4
PT- o1-m
G & ral
o1 Mist
er
LL
op
ic Whisp Co
he

aM 3
LL
r re
th )
aM
An udepus, Hai C
ku

a2
om
Clanet, O m
a
n an
Grok
(S
o
d R
Stepping Things Up - Beyond the Hype

● LLMs’ limitations
○ No memory
○ Probabilistic results
○ Opague - can’t add attribution to its answers
○ Outrageous cost
● The hype: “one-shot” usages (or zero-shot)
● More will be required to make it ready for prime time:
○ Scalability
○ Complex task (e.g. workflows)
○ Memory - remembering the state (particularly for enterprise-level usages)
Agentic Architecture
● Structure and Design of AI Systems that leverages on AI agents to perform tasks:
○ Autonomous execution
○ Tool integration
○ Seamless scalability
○ Resilience and recoverability

9
Agentic Architecture - Key Concepts
● Vertical Architecture - One agent leading
● Horizontal Architecture - Multiple agents collaborating
● Agentic Orchestration
● Complex Task Execution
● Autonomous Decision-making
○ Reasoning and planning
● Continuous Learning

10
AI: Infusing into All Fabrics of our Lives

CONSUMER (e.g. PRODUCER (e.g. Developers


Developers using GitHub building AI applications,
Copilot) training models…etc)

11
A fascinating
look at the
GenAI “era”

12
Generative Apps

ear n
eyL
M onk n A I
ChatGPT tio
N o

Wor

Gi -Pil
dtun

tH o t
Co
SEO A e

ub
rd I
Ba i
Gemin

c e AI
r
Sa lesfo g A I
Bi n
Expanding Modality / Multi-Modal

Text Image Code

Audio Video 3D
Generative Pre-Trained Transformer (GPT)

● Takes simple prompts (in natural human language) as input


● Pattern matching (also commonly being called as “search”)
● Answers questions for the prompts
● Produce contents such as: a new essay, a blog post, a new computer
program

15
What is Natural Language Processing
(NLP)?
● An interdisciplinary sub-field of linguistics of computer science
● Primary concern is to process natural language datasets (as such text
corpora or speech corpora)
● Uses rule-based or probabilistic machine learning approaches
● Enables computer to learn from contents, including the contextual
nuances of the language itself
● Ideally to draw insights from the documents

16
Large Language Models (LLMs)

● A type of Machine Learning or Deep-Learning Model


● Foundation type of model trained on a broad range of data providing
general-purpose usages
● Typically the pre-training consumes a humongous amount of time and
resources: $$$$$$$ GPUs
○ Language processing (utilizing NLP)
○ Visual comprehension
○ Code generation
○ Human-centered engagement
■ Answers questions (prompts) just like a human: analyze
sentiments, chatbot conversations, etc.
17
How do LLMs fit into the AI/ML picture?

18
03
The Event-Driven World and
AI ?

19
At the Heart
of AI:

DATA and the


*FLOW* of Data in
many directions

20
Working with Data

● Architecture level: Event-Driven Architecture


● Handling Data in different States:
○ At Rest
○ In Transit
○ In Use
● Techniques:
○ Event Streaming
○ Event Messaging
○ Event Sourcing & CQRS

21
Generative AI Streaming usages
● GenAI App Input
○ Prompts
■ Command-line
■ Browser (different devices)
■ Mobile App
● GenAI Intermediary steps:
○ During RAG operations:
■ different sources (DB, filesystem, socket?, message queue, Kafka
topic…)
■ Sending requests to LLMs
● GenAI App Output
○ Responses sent from LLMs

22
Benefits of the Event-Driven Approach
● Handles the dynamic nature of data and its flow patterns
● Communicates asynchronously via event streams
● Enables scalability and flexibility (independent scaling of loosely-coupled
components)
● Facilitates integration of diverse AI models and services
● BUT, be aware of the challenges:
○ More difficult to debug
○ Harder to track the flow of calls and the data they carry
○ Observability needs more work

23
04
Applying Event Approach to
-Retrieval-Augmented
Generation (RAG)

24
What is RAG?

● A hybrid framework that integrates the 2 components of the RAG models:


○ Retrieval model
○ Generative model
● The purpose is to produce text that is not only contextually accurate but also
information-rich

25
Source: Vectorize.io [https://docs.vectorize.io/core-concepts/retrieval-augmented-generation]
Role of the Retrieval Model

● In a nutshell, the retrieval model acts as a specialized 'librarian’, pulling in relevant


information from a database or a corpus of documents.
● This information is then fed to the generative model, which acts as a 'writer,' crafting
coherent and informative text based on the retrieved data. The two work in tandem to
provide answers that are not only accurate but also contextually rich.

27
Role of the Generative Model
● Act as creative writers, synthesizing the retrieved information into coherent and contextually relevant
text.
● Usually built upon Large Language Models (LLMs), generative models have the capability to create
text that is grammatically correct, semantically meaningful, and aligned with the initial query or prompt.
● They take the raw data selected by the retrieval models and give it a narrative structure, making the
information easily digestible and actionable.
● In the RAG framework, generative models serve as the final piece of the puzzle, providing the textual
output we interact with.

28
05
Applying Event Approach to
- Agents and Workflows

29
Fundamentals: Agents and Agentic
● Agents
○ one who is authorized to act for or in the place of another
○ a computer application designed to automate certain tasks

● Agentic
○ Agentic refers to someone or something capable of achieving outcomes
independently (“functioning like an agent”) or possessing such ability, means, or
power (“having agency").
○ It is especially used with a type of artificial intelligence (AI), often referred to as
an AI agent, designed to execute complex tasks autonomously or with little
human involvement

30
Gen AI Agents (within the software context)
● Software entities
○ Orchestrate complex workflows
○ Coordinate the activities of multiple agents
○ Process logic
○ Evaluate answers

31
Multi-Agentic Systems
● Multiple autonomous agents working together
● Each agent specializes in different task(s)
● Emergent intelligence from agent interactions
○ Divide complex tasks into manageable subtasks
○ Leverage strengths of different AI models
○ Increased robustness and fault tolerance

32
Fundamental Building Blocks
● Within the Java context, and leveraging on Langchain4j’s approach:
○ AIServices
■ More flexible than the old “Chains” concept in Langchain
■ Declarative interface to the desired API underneath via
and object (proxy)

33
Towards Standardization?
Model Context Protocol (MCP)
● Originated by Anthropic
● MCP is an open protocol that standardizes how applications provide context to LLMs.
● MCP helps you build agents and complex workflows on top of LLMs. LLMs frequently
need to integrate with data and tools
● https://modelcontextprotocol.io/

● MCP Provides:
● A growing list of pre-built integrations that your LLM can directly plug into
● The flexibility to switch between LLM providers and vendors
● Best practices for securing your data within your infrastructure

34
Towards Standardization - More !!
Agent2Agent Protocol (A2A)
● From Google:
● TLDR; Agentic applications need both A2A and MCP. We recommend MCP for tools and
A2A for agents.
● https://google.github.io/A2A/

● Complementary to MCP:
● https://google.github.io/A2A/#/topics/a2a_and_mcp?id=a2a-%e2%9d%a4%ef%b8%8f-mcp

35
Intersection of A2A and MCP

36
● Use events to Key Components:
Combining coordinate agent ● Event Bus: Manage event
EDA and activities

streams
API Gateway: Handles
Multi-Agent ● Event streams enable external events
asynchronous agent ● Agents: Autonomous
for GenAI communications
components w/ specific
capabilities
● Event-driven workflow ● AI Models: Underlying
generative models (e.g.
orchestrate multi-step
GPT, DALL-E, Mistral…)
generation

37
Event Types: Agent Types:
Event Types ● UserRequest: Initial ● Coordinator: Decomposes
generation request
and ● SubtaskAssigned: Agent ●
tasks, assigns to agents
Generator: Produces
Agent Types ●
given a special subtask
ResultGenerated:
content using AI models
● Evaluator: Assesses
Output from an
agent/model quality/relevance of
● FinalResponse: generated content
Completed result for ● Refiner: Improves/iterates
user on initial outputs

38
An AutoGen Example with Different Types of
LLM Agents, including Humans in the Loop
S

AutoGen: Enabling Next Gen LLM Apps via Multi-Agent Conversations (https://arxiv.org/abs/2308.08155)

39
Agentic Design Patterns
● Reflection
● Tool Use
● Planning
● Multi-Agent Collaboration

40
Reflection

https://www.deeplearning.ai/the-batch/agentic-design-patterns-part-2-reflection
41
Tool Use

https://www.deeplearning.ai/the-batch/agentic-design-patterns-part-3-tool-use
42
Tool Use (Illustrated, from CrewAI)

Source: https://github.com/crewAIInc/crewAI/blob/main/docs/crewAI-mindmap.png
43
Planning

https://www.deeplearning.ai/the-batch/agentic-design-patterns-part-4-planning
44
Multi-Agentic Collaboration

https://www.deeplearning.ai/the-batch/agentic-design-patterns-part-5-multi-agent-collaboration/
45
Examples of a Few Multi-Agentic Libraries

● AutoGen
● CrewAI
● LangGraph
● And on the Java side: Quarkus-LangChain4j (CDI)
○ https://docs.quarkiverse.io/quarkus-langchain4j/dev/agent-and-tools.html

46
Examples from CrewAI
● https://docs.crewai.com/examples/example
● GitHub: https://github.com/mgrygles-lab/crewAI-examples/tree/main

47
Agentic Use Cases

● Government project bidding / request-for-proposal (RFP) process


● Sales Team client research project
● Auto-Mechanics customer intake and operations
● https://bit.ly/3CFaSjd (Article written for the Java Advent Calendar 2024)

48
06
Challenges

49
Be aware of the following issues (partial list)

● Complex system design and coordination

● Ensure consistency across distributed agents

● Handling failures and partial results

● Optimizing for latency and resource usage

● Sustainability issues

○ Energy-intensive / energy hog

○ Eco-unfriendly

● Hallucinations in GenAI with the LLMs

● Ethical concerns / Potential misuse

○ Currently no one is there to oversee its usages

● Prompt Injection

50
Resources
This slide deck can be accessed here:
https://bit.ly/4iusuNx
Information
● arxiv.org Paper (AutoGen: Enabling Next-Gen LLM Apps via Multi Agent
Conversations):

https://arxiv.org/abs/2308.08155
● OSS Insight Collection (GenAI Agentic Libraries):
https://ossinsight.io/analyze/microsoft/autogen
https://ossinsight.io/analyze/langchain-ai/langgraph
https://ossinsight.io/analyze/crewAIInc/crewAI
● Mary’s Article on Java Advent Calendar (December 2024):
https://bit.ly/3CFaSjd

53
Follow Mary’s Stream
&
The Elusive AI Podcast
[Different topics: GenAI/ChatGPT, AI/ML, Java, Python, JS/TS, Open Source, Distributed Messaging, Event-Streaming,
Cloud, DevOps, etc]

Wed|Thurs|Fri-afternoon-US/Central

https://twitch.tv/mgrygles
https://youtube.com/@marygrygleski9271
Thank You
Mary Grygleski
Chicago Java Users Group: https://www.linkedin.com/in/mary-grygleski/
https://cjug.org

The GenAI Collective


@mgrygles
https://www.genaicollective.ai/
https://discord.gg/RMU4Juw
https://aicamp.ai

You might also like