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.
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, optionalMemoryStore, HITL approval, and a typedAgentResult. Syncagent.run(...); asyncawait 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 byflyte.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 viaflyteplugins-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.
| # | 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 |
| # | 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 |
| # | 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 |
| # | 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 |