An open API service indexing awesome lists of open source software.

https://github.com/lokahq/agentic-patterns-101

Agentic Patterns 101 with Loka & Strands-Agents (AWS)
https://github.com/lokahq/agentic-patterns-101

agentic-ai agentic-workflows agents ai aws bedrock genai machine-learning multi-agent-systems python

Last synced: 10 months ago
JSON representation

Agentic Patterns 101 with Loka & Strands-Agents (AWS)

Awesome Lists containing this project

README

          


Loka

×


Strands Agents


Agentic Patterns 101 with Loka & Strands-Agents (AWS)

Welcome to **Agentic Patterns 101** - a comprehensive collection of practical implementations demonstrating various agentic design patterns using [Strands-Agents](https://strandsagents.com).

Whether you're building content generation pipelines, document processing systems, or complex multi-step AI workflows, these patterns provide tested foundations for your agentic applications.




Agentic Patterns



Pattern
Description & Key Characteristics
Use Cases & Industries
When to Use / When Not to Use
File Paths




Sequential Workflow
(Prompt Chaining)
Tasks completed step-by-step where each agent's output becomes input for the next.

• Linear sequence
• Each step depends on previous
• Minimal branching
Document generation: outline → content → validation
Data processing: extract → transform → summarize
Research: collect → synthesize → format
Use: Discrete, ordered steps
Avoid: Need flexibility or parallel processing
sequential-workflow.py
sequential-workflow-tool.py


Parallel Workflow
Multiple agents execute tasks simultaneously, often from shared input or preceding step output.

• Concurrent execution
• Shared/partitioned inputs
• Result coordination needed
Content enrichment: draft + grammar check + fact-check in parallel
Multi-perspective analysis: financial report + risk analysis + market sentiment
Use: Independent subtasks
Avoid: Highly dependent outputs
parallel-workflow-tool.py


LLM Routing
Automatically directs queries to the most appropriate model based on complexity, domain expertise, or computational requirements.


• Dynamic model selection

• Centralized routing logic
Software development: syntax questions → lightweight models, architecture → reasoning models
Customer support: FAQ → fast models, troubleshooting → specialized models
Use: Query complexity varies significantly, cost optimization important
Avoid: Similar complexity levels across queries, routing overhead exceeds benefits
llm_routing.py


Reflection Pattern
Agent generates initial output, receives feedback from judge agent, then refines work through iterative improvement cycles.


• Iterative improvement through feedback loops<

• Quality enhancement through refinement
Creative content: draft → critique → refinement for scripts, marketing copy
Code review: generate → analyze → refactor based on feedback
Research: findings → critique → strengthen analysis
Use: Output quality critical, iterative improvement adds value
Avoid: Simple tasks, feedback overhead exceeds improvement value
reflection_pattern.py


Pure Tools

A single-agent pattern where tools handle specific domain logic while the agent orchestrates their usage through natural language interactions.



• Simple agent-tool architecture

• Natural language tool orchestration

• Model-powered tool intelligence

• Clean separation of concerns


E-commerce: Inventory management and order processing

Data Management: create → read → update → delete → query

HR systems: Employee onboarding and performance tracking


Use: Domain-specific applications with clear tool boundaries and shared state
Avoid: Complex multi-step workflows requiring multiple specialized agents
pure-tools.py



MCP Server Tools
Model Context Protocol enables standardized communication between agents and external tools/services via MCP servers.

• Standardized communication
• Model-agnostic
• External tool integration
• System interoperability
Enterprise data: ERP/CRM system access
Knowledge retrieval: Vector DB queries
Automation: Scheduling/ticketing APIs
Healthcare: EHR/medical ontology access
Use: Structured external tool access
Avoid: Self-contained tasks or simple API calls
mcp-server-tools.py


Agents as Tools

A multi-agent pattern where individual agents expose their capabilities as callable tools, enabling orchestration by a central agent or system.



• Agents encapsulate domain-specific intelligence

• Flexible agent composition

• Scalable, modular architecture


Customer Support: AI chatbots handling FAQs

Finance: Loan processing agents or fraud detection agents

Education: Adaptive learning agents or curriculum planning agents


Use: Scenarios requiring multiple specialized agents to collaborate
Avoid: Simple single-domain applications where one agent suffices
agents-as-tools.py



Swarm
Multiple specialized agents work together as autonomous peers through shared working memory and self-organizing coordination.

• Autonomous coordination without central control
• Shared working memory for all agents
• Dynamic task distribution based on discoveries
• Peer-to-peer handoffs
Viral content creation: trend analysts, creators, copywriters collaborating fluidly
Research investigation: specialists handing off based on emerging findings
Crisis response: dynamic collaboration as situations evolve
Use: Unpredictable outcomes, creative collaboration
Avoid: Clear hierarchies, central coordination preferred
swarm.py


Graph Multi-Agent Pattern

A deterministic DAG-based orchestration model where each node is an agent (or custom multi-agent), and edges represent execution dependencies.



• Deterministic execution order

• Clear dependency management

• Nested patterns and custom node types

• Conditional and multi-modal support


Financial analysis: fetch → analyze → summarize → report

Content creation: research → draft → edit → publish

IoT: monitor → diagnose → optimize → alert

Healthcare: collect → analyze → diagnose → recommend


Use: Complex workflows with clear agent dependencies
Avoid: Simple pipelines better suited for Workflow pattern
graph-multi-agent.py
graph-multi-agent-tool.py


## License

This project is licensed under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for details.

## Repository Structure

```
├── .github/ # GitHub Actions workflows
│ ├── workflows/ # GitHub Actions workflow files
│ │ └── uv-ci.yaml # uv (python) Continuous Integration workflow
│ └── dependabot.yaml # Configuration file for Dependabot
├── agentic-patterns/ # Implementation directory
│ ├── agents-as-tools.py # Agents as tools orchestration workflow
│ ├── graph-multi-agent-tool.py # Tool-based graph multi-agent implementation
│ ├── graph-multi-agent.py # Graph multi-agent implementation
| ├── llm_routing.py # LLM Routing Implementation
│ ├── mcp-server-tools.py # MCP server tools implementation
│ ├── parallel-workflow-tool.py # Tool-based parallel workflow implementation
│ ├── pure-tools.py # Pure tools implementation
| ├── reflection_pattern.py # Reflection Pattern implementation
│ ├── sequential-workflow-tool.py # Tool-based sequential workflow implementation
│ ├── sequential-workflow.py # Function-based sequential workflow implementation
│ └── swarm.py # Swarm pattern implementation
├── assets/ # Diagrams
│ └── strands_agents_pattern.drawio # Diagrams for strands agents pattern
├── .gitignore # Git ignore patterns
├── .pre-commit-config.yaml # Pre-commit hooks configuration
├── .python-version # Python version specification
├── LICENSE # Project license
├── pyproject.toml # Pyproject configuration file
├── README.md # Project documentation
└── uv.lock # uv lock file for dependencies
```