Skip to content

Commit f5ccb77

Browse files
committed
feat: Implement LLM Architecture Patterns - Building blocks (Augmented LLM), Workflows (Prompt Chaining, Routing, Parallelization, Orchestrator-Workers, Evaluator-Optimizer), and Agents (Autonomous, Domain-Specific) with examples and docs
1 parent d9b2261 commit f5ccb77

File tree

36 files changed

+4259
-57
lines changed

36 files changed

+4259
-57
lines changed

.cursorlogs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Cursor Development Logs
2+
3+
[2024-02-15 Initial Setup]
4+
PROBLEM: Need to track development progress - ACTION: Created .cursorlogs file - RESULT: Successfully created tracking file
5+
PROBLEM: Repository structure analysis - ACTION: Listed current files and directories - RESULT: Found basic structure with building-block/, workflows/, and agents/ directories
6+
PROBLEM: Project dependencies - ACTION: Created requirements.txt - RESULT: Added core dependencies for LLM implementations
7+
PROBLEM: Building-block analysis - ACTION: Inspected building-block/augmented-llm - RESULT: Found basic implementation with augmented.py and supporting files
8+
PROBLEM: Workflows analysis - ACTION: Inspected workflows directory - RESULT: Found empty directories for all workflow patterns
9+
PROBLEM: Agents analysis - ACTION: Inspected agents directory - RESULT: Found empty directory, needs complete implementation
10+
11+
[2024-02-15 Implementation Plan]
12+
13+
1. Complete building-block/augmented-llm implementation
14+
2. Implement workflow patterns:
15+
- prompt-chaining
16+
- routing
17+
- parallelization
18+
- orchestrator-workers
19+
- evaluator-optimizer
20+
3. Implement agent patterns:
21+
- autonomous-agent
22+
- domain-specific-agents
23+
24+
[2024-02-15 Building Block Implementation]
25+
PROBLEM: Augmented LLM tools needed - ACTION: Created basic_tools.py with WebSearch, Calculator, and Weather tools - RESULT: Successfully implemented tool classes
26+
PROBLEM: Example implementation needed - ACTION: Created basic_usage.py with complete example - RESULT: Successfully demonstrated tool and memory usage
27+
PROBLEM: Documentation needed - ACTION: Updated augmented-llm README.md - RESULT: Comprehensive documentation of implementation and usage
28+
29+
[2024-02-15 Workflow Implementation - Prompt Chaining]
30+
PROBLEM: Core prompt chaining implementation needed - ACTION: Created chain.py with ChainStep, PromptChain, and ChainBuilder classes - RESULT: Successfully implemented base functionality
31+
PROBLEM: Example implementation needed - ACTION: Created text_analysis.py demonstrating multi-step text analysis - RESULT: Successfully implemented three-step chain example
32+
PROBLEM: Documentation needed - ACTION: Created prompt-chaining README.md - RESULT: Comprehensive documentation of pattern and usage
33+
34+
[2024-02-15 Workflow Implementation - Routing]
35+
PROBLEM: Core routing implementation needed - ACTION: Created router.py with Route, Router, and RouterBuilder classes - RESULT: Successfully implemented base functionality
36+
PROBLEM: Example implementation needed - ACTION: Created support_routing.py demonstrating support ticket routing - RESULT: Successfully implemented support routing system
37+
PROBLEM: Documentation needed - ACTION: Created routing README.md - RESULT: Comprehensive documentation of pattern and usage
38+
39+
[2024-02-15 Workflow Implementation - Parallelization]
40+
PROBLEM: Core parallelization implementation needed - ACTION: Created parallel.py with ParallelTask, Parallelizer, and ParallelizerBuilder classes - RESULT: Successfully implemented base functionality
41+
PROBLEM: Example implementation needed - ACTION: Created content_moderation.py demonstrating parallel content moderation - RESULT: Successfully implemented moderation system with multiple checks
42+
PROBLEM: Documentation needed - ACTION: Created parallelization README.md - RESULT: Comprehensive documentation of pattern and usage
43+
44+
[2024-02-15 Workflow Implementation - Orchestrator-Workers]
45+
PROBLEM: Core orchestrator implementation needed - ACTION: Created orchestrator.py with Task, Worker, Orchestrator, and OrchestratorBuilder classes - RESULT: Successfully implemented base functionality
46+
PROBLEM: Example implementation needed - ACTION: Created document_processing.py demonstrating document analysis system - RESULT: Successfully implemented document processing with multiple workers
47+
PROBLEM: Documentation needed - ACTION: Created orchestrator-workers README.md - RESULT: Comprehensive documentation of pattern and usage
48+
49+
[2024-02-15 Workflow Implementation - Evaluator-Optimizer]
50+
PROBLEM: Core optimizer implementation needed - ACTION: Created optimizer.py with Candidate, Optimizer, and OptimizerBuilder classes - RESULT: Successfully implemented base functionality with multiple strategies
51+
PROBLEM: Example implementation needed - ACTION: Created code_optimization.py demonstrating code improvement system - RESULT: Successfully implemented code optimization with multiple strategies
52+
PROBLEM: Documentation needed - ACTION: Created evaluator-optimizer README.md - RESULT: Comprehensive documentation of pattern and usage
53+
54+
[2024-02-15 Agent Implementation - Autonomous Agent]
55+
PROBLEM: Core agent implementation needed - ACTION: Created agent.py with Action, Plan, Tool, Memory, and AutonomousAgent classes - RESULT: Successfully implemented base functionality with planning and execution capabilities
56+
PROBLEM: Example implementation needed - ACTION: Created research_assistant.py demonstrating autonomous research system - RESULT: Successfully implemented research assistant with multiple tools and adaptive planning
57+
PROBLEM: Documentation needed - ACTION: Created autonomous-agent README.md - RESULT: Comprehensive documentation of pattern and usage
58+
59+
[2024-02-15 Agent Implementation - Domain-Specific Agent]
60+
PROBLEM: Core domain-specific agent implementation needed - ACTION: Created domain-specific/agent.py with DomainConstraint, DomainKnowledge, DomainBehavior, and DomainSpecificAgent classes - RESULT: Successfully implemented base functionality with domain-specific capabilities
61+
PROBLEM: Example implementation needed - ACTION: Created medical_assistant.py demonstrating medical diagnosis system - RESULT: Successfully implemented medical assistant with domain knowledge, constraints, and behaviors
62+
PROBLEM: Documentation needed - ACTION: Created domain-specific README.md - RESULT: Comprehensive documentation of pattern and usage

agents/autonomous-agent/README.md

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
# Autonomous Agent Pattern
2+
3+
This pattern demonstrates how to implement self-directed agents that can plan, execute, and adapt their behavior to achieve goals.
4+
5+
## Overview
6+
7+
The autonomous agent pattern is useful when:
8+
9+
- Tasks require complex planning and execution
10+
- Goals can be broken down into discrete actions
11+
- Adaptation to results is needed
12+
- Long-running tasks need monitoring
13+
14+
## Components
15+
16+
### Core Classes
17+
18+
1. **Action**
19+
20+
- Represents a discrete task
21+
- Tracks execution status
22+
- Stores results
23+
- Manages parameters
24+
25+
2. **Plan**
26+
27+
- Sequences of actions
28+
- Goal definition
29+
- Context information
30+
- Execution status
31+
32+
3. **Tool**
33+
34+
- Specific capabilities
35+
- Parameter definitions
36+
- Execution handlers
37+
- Error handling
38+
39+
4. **Memory**
40+
41+
- Action history
42+
- Plan history
43+
- Context storage
44+
- State management
45+
46+
5. **AutonomousAgent**
47+
- Plan creation
48+
- Action execution
49+
- Progress evaluation
50+
- Plan adjustment
51+
52+
## Example Implementation
53+
54+
The `examples/research_assistant.py` demonstrates autonomous research:
55+
56+
1. Research Tools:
57+
58+
- Web Search
59+
- Webpage Reading
60+
- Text Summarization
61+
- Fact Extraction
62+
- Note Taking
63+
64+
2. Features:
65+
- Goal decomposition
66+
- Adaptive planning
67+
- Progress tracking
68+
- Result aggregation
69+
70+
## Usage
71+
72+
1. Set up environment:
73+
74+
```bash
75+
pip install -r requirements.txt
76+
```
77+
78+
2. Configure API keys:
79+
80+
```bash
81+
export ANTHROPIC_API_KEY=your_key_here
82+
# or
83+
export OPENAI_API_KEY=your_key_here
84+
```
85+
86+
3. Run the example:
87+
88+
```bash
89+
python -m examples.research_assistant
90+
```
91+
92+
## Implementation Details
93+
94+
### Tool Definition
95+
96+
```python
97+
Tool(
98+
name="tool_name",
99+
description="tool description",
100+
parameters={"param": "type"},
101+
handler=async_handler_function
102+
)
103+
```
104+
105+
### Agent Building
106+
107+
```python
108+
agent = (
109+
AgentBuilder()
110+
.add_tool(...)
111+
.add_tool(...)
112+
.with_memory(memory)
113+
.build(llm_caller)
114+
)
115+
```
116+
117+
### Goal Execution
118+
119+
```python
120+
actions = await agent.execute(
121+
goal="goal description",
122+
context={}
123+
)
124+
```
125+
126+
## Agent Capabilities
127+
128+
1. **Planning**
129+
130+
- Goal analysis
131+
- Task decomposition
132+
- Action sequencing
133+
- Dependency management
134+
135+
2. **Execution**
136+
137+
- Tool selection
138+
- Parameter preparation
139+
- Result handling
140+
- Error recovery
141+
142+
3. **Monitoring**
143+
144+
- Progress tracking
145+
- Goal evaluation
146+
- Plan adjustment
147+
- Performance analysis
148+
149+
4. **Learning**
150+
- Action history
151+
- Success patterns
152+
- Failure analysis
153+
- Strategy adaptation
154+
155+
## Best Practices
156+
157+
1. **Goal Design**
158+
159+
- Clear objectives
160+
- Measurable outcomes
161+
- Reasonable scope
162+
- Success criteria
163+
164+
2. **Tool Implementation**
165+
166+
- Focused functionality
167+
- Clear interfaces
168+
- Robust error handling
169+
- Performance optimization
170+
171+
3. **Memory Management**
172+
173+
- Relevant history
174+
- Context preservation
175+
- State cleanup
176+
- Storage efficiency
177+
178+
4. **Error Handling**
179+
- Graceful degradation
180+
- Recovery strategies
181+
- Feedback loops
182+
- Logging and monitoring
183+
184+
## Extensions
185+
186+
Consider extending this pattern with:
187+
188+
1. **Advanced Planning**
189+
190+
- Multi-goal handling
191+
- Priority management
192+
- Resource allocation
193+
- Constraint satisfaction
194+
195+
2. **Learning Capabilities**
196+
197+
- Strategy optimization
198+
- Pattern recognition
199+
- Performance tuning
200+
- Knowledge base
201+
202+
3. **Collaboration**
203+
204+
- Agent communication
205+
- Task delegation
206+
- Resource sharing
207+
- Conflict resolution
208+
209+
4. **Safety**
210+
211+
- Action validation
212+
- Resource limits
213+
- Security checks
214+
- Ethical constraints
215+
216+
5. **Integration**
217+
- External services
218+
- Data sources
219+
- Monitoring systems
220+
- Reporting tools

0 commit comments

Comments
 (0)