Skip to content

unionai-oss/agentic-design-patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Agentic Design Patterns on Flyte V2

This repo implements code examples from Antonio Gulli's Agentic Design Patterns book with Flyte V2.

The repo ships with the configuration so you can run all examples in the Flyte Devbox.

Built on Flyte's agentic primitives

Where it makes the pattern clearer, the notebooks use Flyte v2's first-class agent toolkit (flyte.ai.agents) instead of a hand-rolled @flyte.trace tool loop:

  • Agent — a batteries-included LLM ↔ tool loop with declarative @tools, MCP servers, optional MemoryStore, HITL approval, and a typed AgentResult. Sync agent.run(...); async await agent.run.aio(...). Used in routing (2), tool-use (5), planning (6), multi-agent (7), RAG (14), inter-agent (15), prioritization (20); subclassed to wrap the loop in goal-setting (11), reasoning (17), and guardrails (18).
  • MemoryStore — a session-keyed transcript + path-addressed artifacts backed by flyte.io.Dir, with optimistic concurrency (expected_sha). Memory management (8).
  • MCPServerSpec — connect a real MCP server over stdio/HTTP and surface its tools transparently. Model Context Protocol (10).
  • @tool(requires_approval=True) — a human-in-the-loop approval gate via flyteplugins-hitl. Human-in-the-loop (13), guardrails (18).
  • CodeModeAgent + flyte.sandbox.create / orchestrate_local — run LLM-generated code in fresh, isolated sandboxes. Learning and adaptation (9).

The remaining patterns (prompt chaining, parallelization, reflection, exception handling, resource-aware optimization, evaluation, exploration) stay on plain @env.task composition — each notebook ends with a short note on why the harness isn't a win there.

Part One: Core Patterns

# Pattern Description
1 Prompt Chaining Chain multiple LLM calls where each output feeds the next
2 Routing Classify inputs and direct them to specialized handlers
3 Parallelization Run independent tasks concurrently and aggregate results
4 Reflection Producer-Critic loop for iterative self-improvement
5 Tool Use Autonomous function calling against external APIs and services
6 Planning Decompose complex goals into structured, executable steps
7 Multi-Agent Collaboration Cooperative ensemble of specialized agents

Part Two: Memory & Adaptation

# Pattern Description
8 Memory Management Short- and long-term memory across interactions
9 Learning and Adaptation Evolutionary evaluate → select → mutate loop
10 Model Context Protocol (MCP) Standardized tool discovery and invocation for LLMs
11 Goal Setting and Monitoring Generate → evaluate → refine loop toward a defined objective

Part Three: Reliability

# Pattern Description
12 Exception Handling and Recovery Layered resilience against tool failures and invalid responses
13 Human-in-the-Loop Strategic human judgment injection for high-risk decisions
14 Knowledge Retrieval (RAG) Retrieval-Augmented Generation for grounded, up-to-date responses

Part Four: Advanced Patterns

# Pattern Description
15 Inter-Agent Communication (A2A) Agent-to-agent delegation and collaboration across frameworks
16 Resource-Aware Optimization Dynamic model/tool routing by cost and complexity
17 Reasoning Techniques (Deep Research) Generate → research → reflect → finalize research loop
18 Guardrails / Safety Patterns Policy-compliance screening before primary AI processing
19 Evaluation and Monitoring Token tracking, latency monitoring, and output quality metrics
20 Prioritization Multi-criteria task ranking for autonomous next-action selection
21 Exploration and Discovery Multi-agent scientific research with specialized phase agents

About

This repo implements Agentic Design Patterns code from Antonio Giulli's book with Flyte V2

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors