Agent Patterns Documentation

Welcome to the Agent Patterns documentation! This library provides 9 battle-tested AI agent workflow patterns implemented with LangGraph and LangChain.

Breaking Change in v0.2.0

This version is a complete rewrite from the ground up. The previous 0.1.x version used asyncio extensively, which caused significant reliability issues. Version 0.2.0+ uses a synchronous-only architecture for better reliability and easier debugging.

What is Agent Patterns?

Agent Patterns is a Python library that implements proven AI agent architectures as reusable, composable patterns. Each pattern represents a different approach to building intelligent agents that can reason, plan, reflect, and execute tasks.

Key Features

  • 9 Production-Ready Patterns: ReAct, Reflection, Self-Discovery, STORM, and more

  • Enterprise-Grade Prompts: 150-300+ line comprehensive system prompts following industry best practices from Anthropic and OpenAI

  • Synchronous Design: Simple, debuggable code without async complexity

  • Flexible Customization: Multiple ways to customize prompts and behavior

  • Type-Safe: Full type hints throughout

  • Multi-Provider: Works with OpenAI, Anthropic, and other LLM providers

What Makes Agent Patterns Different?

Enterprise-Grade Prompt Engineering

Version 0.2.0 introduces a comprehensive prompt redesign that sets Agent Patterns apart:

9.4x More Detailed System Prompts

  • System prompts expanded from ~32 lines to 150-300+ lines

  • Each prompt includes 9 structured sections for maximum clarity and reliability

Comprehensive 9-Section Structure Every system prompt now includes:

  1. Role and Identity: Clear definition of the agent’s purpose and capabilities

  2. Core Capabilities: Explicit CAN/CANNOT boundaries to prevent hallucination

  3. Process: Step-by-step workflow guidance for consistent execution

  4. Output Format: Precise specifications for structured responses

  5. Decision-Making Guidelines: Context-specific rules and best practices

  6. Quality Standards: Clear criteria for excellent vs. poor outputs

  7. Edge Cases: Built-in error handling and special situation guidance

  8. Examples: 2-3 concrete examples demonstrating expected behavior

  9. Critical Reminders: Key points emphasized for reliability

Benefits

  • Increased Reliability: Comprehensive guidance reduces errors and inconsistencies

  • Better Transparency: Clear role definitions and boundaries make agent behavior predictable

  • Improved Robustness: Edge case handling and quality standards prevent common failures

  • Professional Output: Industry best practices ensure production-ready results

  • Maintainability: Consistent structure across all patterns simplifies debugging and updates

Backward Compatible All improvements are transparent to existing code—no changes required. Your agents automatically benefit from enhanced prompts while maintaining the same simple API.

Quick Start

pip install agent-patterns
from agent_patterns.patterns import ReflectionAgent

agent = ReflectionAgent(
    llm_configs={
        "documentation": {"provider": "openai", "model": "gpt-4"},
        "reflection": {"provider": "openai", "model": "gpt-4"}
    }
)

result = agent.run("Write a blog post about AI agents")
print(result)
# Now benefits from enterprise-grade prompts automatically!

Your Learning Journey

1. Start Here: Understanding Patterns

Begin by understanding what agent patterns are and how they differ:

2. Learn Individual Patterns

Dive deep into each pattern with theory, examples, and use cases:

Foundational Patterns (Start Here)

Planning & Execution

Advanced Reasoning

Research & Synthesis

3. Customize Your Agents

Learn how to tailor patterns to your specific needs:

4. Build Production Systems

Ready to deploy? Learn best practices:

Pattern Overview

Quick reference for all patterns:

Pattern

Best For

Complexity

When to Use

ReAct

Tool-using tasks

Low

Need to interact with external tools/APIs

Reflection

High-quality content

Low

Want iterative refinement of outputs

Plan & Solve

Structured problems

Medium

Clear decomposable tasks

Self-Discovery

Complex reasoning

Medium

Need adaptive reasoning strategies

Reflexion

Trial-and-error

Medium

Learning from failures is important

REWOO

Efficient planning

Medium

Cost-conscious tool usage

LATS

Exploration tasks

High

Need to explore multiple solution paths

LLM Compiler

Parallel execution

High

Independent subtasks that can run concurrently

STORM

Research synthesis

High

Multi-perspective research reports

Use Case Quick Finder

Find the right pattern for your use case:

Content Generation

Problem Solving

Task Execution

Research & Analysis

See the full comparison matrix for detailed use case analysis.

Core Concepts

Agent Patterns

Support & Community

License

Agent Patterns is licensed under the MIT License. See LICENSE for details.