Loading...
Loading...
Expert knowledge of agentic AI design patterns for autonomous agent development
npx skill4agent add aradotso/ai-agent-skills awesome-agentic-patterns-catalogSkill by ara.so — AI Agent Skills collection.
# Visit the interactive pattern explorer
open https://agentic-patterns.comgit clone https://github.com/nibzard/awesome-agentic-patterns.git
cd awesome-agentic-patternsawesome-agentic-patterns/
├── patterns/ # Individual pattern markdown files
│ ├── context-window-auto-compaction.md
│ ├── reflection.md
│ ├── plan-then-execute-pattern.md
│ └── ...
├── apps/
│ └── web/ # Astro-based website source
├── README.md # Main catalog listing
└── LICENSE1. Generate initial solution
2. Critique: "Does this handle edge case X?"
3. Revise based on critique
4. Validate against requirementswhile not tests_pass:
run_tests()
if failures:
agent.analyze_failures(test_output)
agent.generate_fix()
commit_and_retry()# Conceptual implementation
def plan_then_execute(task):
plan = planner_llm.generate_plan(task)
results = []
for step in plan.steps:
result = executor.execute(step)
if result.needs_replanning:
plan = planner_llm.replan(task, results, step)
results.append(result)
return synthesize(results)Tool Selection Guide:
- search_code(query): When user asks "where is X defined"
- run_tests(path): After code changes, before commit
- read_file(path): When context about specific file needed
- edit_file(path, instructions): To modify existing codeclass AgentCircuitBreaker:
def __init__(self, failure_threshold=5):
self.failures = 0
self.threshold = failure_threshold
self.state = "closed" # closed, open, half-open
def call(self, agent_fn, *args):
if self.state == "open":
raise CircuitOpenError("Too many failures")
try:
result = agent_fn(*args)
self.on_success()
return result
except Exception as e:
self.on_failure()
raise
def on_failure(self):
self.failures += 1
if self.failures >= self.threshold:
self.state = "open"# Combining multiple patterns
from typing import List, Dict
class CodeReviewAgent:
"""
Combines:
- Curated Code Context Window (Context & Memory)
- Reflection Loop (Feedback)
- Tool Selection Guide (Tool Use)
"""
def __init__(self, llm, code_retriever):
self.llm = llm
self.retriever = code_retriever
self.tool_guide = self._load_tool_guide()
def review_pr(self, pr_diff: str) -> Dict:
# 1. Curated Context: Fetch relevant files
context_files = self.retriever.get_relevant_context(
pr_diff,
max_files=10
)
# 2. Initial review with tool guide
initial_review = self.llm.generate(
prompt=f"""
{self.tool_guide}
Review this PR diff:
{pr_diff}
Context files:
{context_files}
Use available tools to verify claims.
""",
tools=["run_tests", "search_similar_code", "check_style"]
)
# 3. Reflection loop: Self-critique
critique = self.llm.generate(
prompt=f"""
Review this code review for:
- Are all concerns valid?
- Any false positives?
- Missing critical issues?
Review: {initial_review}
"""
)
# 4. Final review incorporating critique
final_review = self.llm.generate(
prompt=f"""
Original review: {initial_review}
Self-critique: {critique}
Produce final review addressing critique points.
"""
)
return {
"review": final_review,
"context_used": context_files,
"critique": critique
}
def _load_tool_guide(self) -> str:
return """
Tool Selection for Code Review:
- run_tests(test_path): If PR touches test files or claims fix
- search_similar_code(pattern): To find similar patterns/bugs
- check_style(file_path): For style/lint violations
- get_git_history(file): For understanding change context
"""# Implementing Planner-Worker Separation + Sub-Agent Spawning
class ResearchOrchestrator:
"""
Patterns:
- Planner-Worker Separation
- Sub-Agent Spawning
- Plan-Then-Execute
"""
def __init__(self, planner_llm, worker_llm):
self.planner = planner_llm
self.worker = worker_llm
async def research(self, query: str) -> Dict:
# 1. Planner creates research plan
plan = self.planner.generate(
prompt=f"""
Create research plan for: {query}
Output as JSON with steps:
[
{{"type": "search", "query": "...", "sources": [...]}},
{{"type": "analyze", "focus": "..."}},
{{"type": "synthesize", "format": "..."}}
]
"""
)
# 2. Spawn sub-agents for parallel search
search_tasks = [
step for step in plan if step["type"] == "search"
]
search_results = await asyncio.gather(*[
self._spawn_search_agent(task)
for task in search_tasks
])
# 3. Worker agent analyzes results
analysis = self.worker.generate(
prompt=f"""
Analyze these search results for: {query}
Results: {search_results}
Focus: {[s['focus'] for s in plan if s['type'] == 'analyze']}
"""
)
# 4. Synthesize final report
report = self.worker.generate(
prompt=f"""
Synthesize research report:
Query: {query}
Analysis: {analysis}
Format: {plan[-1]['format']}
"""
)
return {
"report": report,
"sources": search_results,
"plan_used": plan
}
async def _spawn_search_agent(self, task: Dict):
"""Dedicated sub-agent for single search task"""
agent = SearchAgent(self.worker, sources=task["sources"])
return await agent.search(task["query"])1. Curated Code Context Window (manage context size)
2. Plan-Then-Execute (break down complex changes)
3. Coding Agent CI Feedback Loop (validate changes)
4. Reflection Loop (self-review before commit)
5. Agent Circuit Breaker (prevent infinite loops)1. Filesystem-Based Agent State (persist state)
2. Working Memory via TodoWrite (track progress)
3. Planner-Worker Separation (long-term planning)
4. Signal-Driven Agent Activation (efficient wake-up)
5. LLM Observability (monitor over time)1. Declarative Multi-Agent Topology (define structure)
2. Economic Value Signaling (coordinate via incentives)
3. Sub-Agent Spawning (dynamic creation)
4. Opponent Processor (debate for quality)
5. Cross-Cycle Consensus Relay (agreement protocol)patterns/your-pattern-name.md# Pattern Name
## Problem
What challenge does this solve?
## Solution
How does the pattern work?
## Implementation
Code examples, architecture diagrams
## References
- [Source 1](url)
- [Source 2](url)| Your Challenge | Primary Pattern | Supporting Patterns |
|---|---|---|
| Exceeding context limits | Curated Code Context Window | Prompt Caching, Progressive Disclosure |
| Low quality outputs | Reflection Loop | Self-Critique Evaluator, CriticGPT |
| Complex multi-step tasks | Plan-Then-Execute | Sub-Agent Spawning, Tree-of-Thought |
| Unreliable behavior | Agent Circuit Breaker | LLM Observability, Failover Fallback |
| Tool confusion | Tool Selection Guide | Tool Compartmentalization |
| Multi-agent coordination | Declarative Topology | Economic Value Signaling |