agentic 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.agentic.yml +2 -0
- data/.architecture/decisions/ArchitecturalFeatureBuilder.md +136 -0
- data/.architecture/decisions/ArchitectureConsiderations.md +200 -0
- data/.architecture/decisions/adr_001_observer_pattern_implementation.md +196 -0
- data/.architecture/decisions/adr_002_plan_orchestrator.md +320 -0
- data/.architecture/decisions/adr_003_plan_orchestrator_interface.md +179 -0
- data/.architecture/decisions/adrs/ADR-001-dependency-management.md +147 -0
- data/.architecture/decisions/adrs/ADR-002-system-boundaries.md +162 -0
- data/.architecture/decisions/adrs/ADR-003-content-safety.md +158 -0
- data/.architecture/decisions/adrs/ADR-004-agent-permissions.md +161 -0
- data/.architecture/decisions/adrs/ADR-005-adaptation-engine.md +127 -0
- data/.architecture/decisions/adrs/ADR-006-extension-system.md +273 -0
- data/.architecture/decisions/adrs/ADR-007-learning-system.md +156 -0
- data/.architecture/decisions/adrs/ADR-008-prompt-generation.md +325 -0
- data/.architecture/decisions/adrs/ADR-009-task-failure-handling.md +353 -0
- data/.architecture/decisions/adrs/ADR-010-task-input-handling.md +251 -0
- data/.architecture/decisions/adrs/ADR-011-task-observable-pattern.md +391 -0
- data/.architecture/decisions/adrs/ADR-012-task-output-handling.md +205 -0
- data/.architecture/decisions/adrs/ADR-013-architecture-alignment.md +211 -0
- data/.architecture/decisions/adrs/ADR-014-agent-capability-registry.md +80 -0
- data/.architecture/decisions/adrs/ADR-015-persistent-agent-store.md +100 -0
- data/.architecture/decisions/adrs/ADR-016-agent-assembly-engine.md +117 -0
- data/.architecture/decisions/adrs/ADR-017-streaming-observability.md +171 -0
- data/.architecture/decisions/capability_tools_distinction.md +150 -0
- data/.architecture/decisions/cli_command_structure.md +61 -0
- data/.architecture/implementation/agent_self_assembly_implementation.md +267 -0
- data/.architecture/implementation/agent_self_assembly_summary.md +138 -0
- data/.architecture/members.yml +187 -0
- data/.architecture/planning/self_implementation_exercise.md +295 -0
- data/.architecture/planning/session_compaction_rule.md +43 -0
- data/.architecture/planning/streaming_observability_feature.md +223 -0
- data/.architecture/principles.md +151 -0
- data/.architecture/recalibration/0-2-0.md +92 -0
- data/.architecture/recalibration/agent_self_assembly.md +238 -0
- data/.architecture/recalibration/cli_command_structure.md +91 -0
- data/.architecture/recalibration/implementation_roadmap_0-2-0.md +301 -0
- data/.architecture/recalibration/progress_tracking_0-2-0.md +114 -0
- data/.architecture/recalibration_process.md +127 -0
- data/.architecture/reviews/0-2-0.md +181 -0
- data/.architecture/reviews/cli_command_duplication.md +98 -0
- data/.architecture/templates/adr.md +105 -0
- data/.architecture/templates/implementation_roadmap.md +125 -0
- data/.architecture/templates/progress_tracking.md +89 -0
- data/.architecture/templates/recalibration_plan.md +70 -0
- data/.architecture/templates/version_comparison.md +124 -0
- data/.claude/settings.local.json +13 -0
- data/.claude-sessions/001-task-class-architecture-implementation.md +129 -0
- data/.claude-sessions/002-plan-orchestrator-interface-review.md +105 -0
- data/.claude-sessions/architecture-governance-implementation.md +37 -0
- data/.claude-sessions/architecture-review-session.md +27 -0
- data/ArchitecturalFeatureBuilder.md +136 -0
- data/ArchitectureConsiderations.md +229 -0
- data/CHANGELOG.md +57 -2
- data/CLAUDE.md +111 -0
- data/CONTRIBUTING.md +286 -0
- data/MAINTAINING.md +301 -0
- data/README.md +582 -28
- data/docs/agent_capabilities_api.md +259 -0
- data/docs/artifact_extension_points.md +757 -0
- data/docs/artifact_generation_architecture.md +323 -0
- data/docs/artifact_implementation_plan.md +596 -0
- data/docs/artifact_integration_points.md +345 -0
- data/docs/artifact_verification_strategies.md +581 -0
- data/docs/streaming_observability_architecture.md +510 -0
- data/exe/agentic +6 -1
- data/lefthook.yml +5 -0
- data/lib/agentic/adaptation_engine.rb +124 -0
- data/lib/agentic/agent.rb +181 -4
- data/lib/agentic/agent_assembly_engine.rb +442 -0
- data/lib/agentic/agent_capability_registry.rb +260 -0
- data/lib/agentic/agent_config.rb +63 -0
- data/lib/agentic/agent_specification.rb +46 -0
- data/lib/agentic/capabilities/examples.rb +530 -0
- data/lib/agentic/capabilities.rb +14 -0
- data/lib/agentic/capability_provider.rb +146 -0
- data/lib/agentic/capability_specification.rb +118 -0
- data/lib/agentic/cli/agent.rb +31 -0
- data/lib/agentic/cli/capabilities.rb +191 -0
- data/lib/agentic/cli/config.rb +134 -0
- data/lib/agentic/cli/execution_observer.rb +796 -0
- data/lib/agentic/cli.rb +1068 -0
- data/lib/agentic/default_agent_provider.rb +35 -0
- data/lib/agentic/errors/llm_error.rb +184 -0
- data/lib/agentic/execution_plan.rb +53 -0
- data/lib/agentic/execution_result.rb +91 -0
- data/lib/agentic/expected_answer_format.rb +46 -0
- data/lib/agentic/extension/domain_adapter.rb +109 -0
- data/lib/agentic/extension/plugin_manager.rb +163 -0
- data/lib/agentic/extension/protocol_handler.rb +116 -0
- data/lib/agentic/extension.rb +45 -0
- data/lib/agentic/factory_methods.rb +9 -1
- data/lib/agentic/generation_stats.rb +61 -0
- data/lib/agentic/learning/README.md +84 -0
- data/lib/agentic/learning/capability_optimizer.rb +613 -0
- data/lib/agentic/learning/execution_history_store.rb +251 -0
- data/lib/agentic/learning/pattern_recognizer.rb +500 -0
- data/lib/agentic/learning/strategy_optimizer.rb +706 -0
- data/lib/agentic/learning.rb +131 -0
- data/lib/agentic/llm_assisted_composition_strategy.rb +188 -0
- data/lib/agentic/llm_client.rb +215 -15
- data/lib/agentic/llm_config.rb +65 -1
- data/lib/agentic/llm_response.rb +163 -0
- data/lib/agentic/logger.rb +1 -1
- data/lib/agentic/observable.rb +51 -0
- data/lib/agentic/persistent_agent_store.rb +385 -0
- data/lib/agentic/plan_execution_result.rb +129 -0
- data/lib/agentic/plan_orchestrator.rb +464 -0
- data/lib/agentic/plan_orchestrator_config.rb +57 -0
- data/lib/agentic/retry_config.rb +63 -0
- data/lib/agentic/retry_handler.rb +125 -0
- data/lib/agentic/structured_outputs.rb +1 -1
- data/lib/agentic/task.rb +193 -0
- data/lib/agentic/task_definition.rb +39 -0
- data/lib/agentic/task_execution_result.rb +92 -0
- data/lib/agentic/task_failure.rb +66 -0
- data/lib/agentic/task_output_schemas.rb +112 -0
- data/lib/agentic/task_planner.rb +54 -19
- data/lib/agentic/task_result.rb +48 -0
- data/lib/agentic/ui.rb +244 -0
- data/lib/agentic/verification/critic_framework.rb +116 -0
- data/lib/agentic/verification/llm_verification_strategy.rb +60 -0
- data/lib/agentic/verification/schema_verification_strategy.rb +47 -0
- data/lib/agentic/verification/verification_hub.rb +62 -0
- data/lib/agentic/verification/verification_result.rb +50 -0
- data/lib/agentic/verification/verification_strategy.rb +26 -0
- data/lib/agentic/version.rb +1 -1
- data/lib/agentic.rb +74 -2
- data/plugins/README.md +41 -0
- metadata +245 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebc5c754277ba41da6444fb8888e94cefc789c1616948c9f046fefeb585d0294
|
4
|
+
data.tar.gz: f01668889c945d6d21e7fe8df1906a5cf20ad4ece46c3c92823059dd822c43da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ba78360d0df76c6cbb7c3e69139a4257fa23fdfd38da32a256e128d187f48b6de327c79730b9573381e53cf50cf99773478725b81ff56afda1c9bd2af7e4ce1
|
7
|
+
data.tar.gz: e91cb20c369383161d617e82326e515d818f8c683636f763a3bedbb95126c366742813948cbdf61f6448192c430935af4ffe18ff2a9921b4b210582233989d76
|
data/.agentic.yml
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
# Architectural Feature Builder Guide
|
2
|
+
|
3
|
+
This document consolidates the architectural design approach for the Agentic framework, providing a streamlined guide for feature implementation.
|
4
|
+
|
5
|
+
## Architectural Philosophy
|
6
|
+
|
7
|
+
Agentic is designed as a domain-agnostic, self-improving framework for AI agent orchestration following these principles:
|
8
|
+
- Extensibility through well-defined interfaces
|
9
|
+
- Progressive automation with human oversight
|
10
|
+
- Learning capability through execution history
|
11
|
+
- Separation of concerns with clearly defined responsibilities
|
12
|
+
|
13
|
+
## Feature Implementation Process
|
14
|
+
|
15
|
+
### 1. Design Phase
|
16
|
+
|
17
|
+
When designing a new feature:
|
18
|
+
|
19
|
+
1. **Reference Architecture**: Consult ArchitectureConsiderations.md for overall system design
|
20
|
+
2. **Component Placement**: Identify which layer(s) the feature belongs to
|
21
|
+
3. **Interface Definition**: Define clear interfaces before implementation
|
22
|
+
4. **Dependency Management**: Minimize dependencies between components
|
23
|
+
5. **Extension Points**: Identify where the feature should support extension
|
24
|
+
|
25
|
+
### 2. Implementation Phase
|
26
|
+
|
27
|
+
When implementing a feature:
|
28
|
+
|
29
|
+
1. **Class Structure**:
|
30
|
+
- Define attributes with clear visibility (public/private)
|
31
|
+
- Implement lifecycle methods (initialization, execution, completion)
|
32
|
+
- Add observability hooks (logging, metrics)
|
33
|
+
- Include verification points
|
34
|
+
|
35
|
+
2. **Communication Patterns**:
|
36
|
+
- Use event-driven communication where appropriate
|
37
|
+
- Implement clear state transitions
|
38
|
+
- Maintain immutability where possible
|
39
|
+
- Include support for serialization/deserialization
|
40
|
+
|
41
|
+
3. **Service Integration**:
|
42
|
+
- Define clear boundaries between services
|
43
|
+
- Implement retry and error handling
|
44
|
+
- Support for asynchronous operation
|
45
|
+
- Include metrics collection
|
46
|
+
|
47
|
+
### 3. Verification Phase
|
48
|
+
|
49
|
+
When verifying a feature:
|
50
|
+
|
51
|
+
1. **Automated Testing**:
|
52
|
+
- Unit tests for individual components
|
53
|
+
- Integration tests for component interaction
|
54
|
+
- System tests for end-to-end workflows
|
55
|
+
|
56
|
+
2. **Manual Verification**:
|
57
|
+
- Identify human intervention points
|
58
|
+
- Verify error handling and recovery
|
59
|
+
- Assess performance characteristics
|
60
|
+
- Confirm extensibility
|
61
|
+
|
62
|
+
## Task Class Design Example
|
63
|
+
|
64
|
+
The Task class exemplifies the architectural approach:
|
65
|
+
|
66
|
+
### Core Requirements
|
67
|
+
|
68
|
+
1. **Functionality**:
|
69
|
+
- Represent a unit of work in the system
|
70
|
+
- Support execution by an agent
|
71
|
+
- Enable verification of results
|
72
|
+
- Track execution state and history
|
73
|
+
|
74
|
+
2. **Communication**:
|
75
|
+
- Interface with agents for execution
|
76
|
+
- Communicate with verification systems
|
77
|
+
- Support dependency resolution
|
78
|
+
- Provide metrics for observability
|
79
|
+
|
80
|
+
3. **Extensibility**:
|
81
|
+
- Support custom execution strategies
|
82
|
+
- Allow plugin-based verification
|
83
|
+
- Enable domain-specific behaviors
|
84
|
+
- Support various input/output formats
|
85
|
+
|
86
|
+
### Implementation Considerations
|
87
|
+
|
88
|
+
1. **State Management**:
|
89
|
+
- Maintain clear task lifecycle (pending, in_progress, completed, failed)
|
90
|
+
- Track timestamps for performance analysis
|
91
|
+
- Support retries with history
|
92
|
+
- Record verification results and confidence scores
|
93
|
+
|
94
|
+
2. **Integration Points**:
|
95
|
+
- Agent execution interface
|
96
|
+
- Verification hub integration
|
97
|
+
- Metrics collection system
|
98
|
+
- Human intervention portal
|
99
|
+
|
100
|
+
3. **Separation of Concerns**:
|
101
|
+
- Task should focus on state and lifecycle
|
102
|
+
- Execution details belong in agents
|
103
|
+
- Verification logic belongs in verifiers
|
104
|
+
- Dependency resolution in specialized resolvers
|
105
|
+
|
106
|
+
## Feature Implementation Checklist
|
107
|
+
|
108
|
+
For each new feature:
|
109
|
+
|
110
|
+
- [ ] Design aligns with overall architecture
|
111
|
+
- [ ] Clear separation of concerns
|
112
|
+
- [ ] Well-defined interfaces
|
113
|
+
- [ ] Appropriate error handling
|
114
|
+
- [ ] Metrics and observability
|
115
|
+
- [ ] Extension points identified
|
116
|
+
- [ ] Human intervention points defined
|
117
|
+
- [ ] Testing strategy established
|
118
|
+
- [ ] Documentation prepared
|
119
|
+
|
120
|
+
## Iteration Approach
|
121
|
+
|
122
|
+
1. Start with a minimal implementation focused on core functionality
|
123
|
+
2. Add verification and observability
|
124
|
+
3. Enhance with extension points
|
125
|
+
4. Refine based on testing and feedback
|
126
|
+
5. Document thoroughly
|
127
|
+
|
128
|
+
When iterating on architectural design:
|
129
|
+
1. Update ArchitectureConsiderations.md with any changes
|
130
|
+
2. Ensure backward compatibility or provide migration path
|
131
|
+
3. Communicate changes to all stakeholders
|
132
|
+
4. Update relevant tests and documentation
|
133
|
+
|
134
|
+
## Conclusion
|
135
|
+
|
136
|
+
This guide provides a structured approach to feature development within the Agentic framework. By following these guidelines, contributors can ensure their implementations align with the overall architectural vision while maintaining quality, extensibility, and consistency across the system.
|
@@ -0,0 +1,200 @@
|
|
1
|
+
# Architecture Considerations for Agentic
|
2
|
+
|
3
|
+
## Core Architecture Vision
|
4
|
+
|
5
|
+
Agentic aims to be a domain-agnostic, self-improving framework for AI agent orchestration using a plan-and-execute paradigm. This document outlines the architectural considerations for creating a robust, extensible system.
|
6
|
+
|
7
|
+
## System Layers
|
8
|
+
|
9
|
+
### 1. Foundation Layer
|
10
|
+
|
11
|
+
**Purpose**: Provides core abstractions and fundamental capabilities.
|
12
|
+
|
13
|
+
**Components**:
|
14
|
+
- **AgentRegistry**: Central registry for managing different agent types
|
15
|
+
- **CapabilityManager**: Handles extensible agent abilities and tools
|
16
|
+
- **MetaLearningSystem**: Enables cross-execution improvements and adaptation
|
17
|
+
|
18
|
+
**Design Principles**:
|
19
|
+
- Dependency injection for all components
|
20
|
+
- Registry pattern for plugin management
|
21
|
+
- Abstract interfaces for all core functionalities
|
22
|
+
|
23
|
+
### 2. Runtime Layer
|
24
|
+
|
25
|
+
**Purpose**: Manages the execution of tasks and plans.
|
26
|
+
|
27
|
+
**Components**:
|
28
|
+
- **TaskFactory**: Creates task instances from specifications
|
29
|
+
- **PlanOrchestrator**: Manages workflow execution
|
30
|
+
- **ExecutionContext**: Maintains state during execution
|
31
|
+
- **Task**: Represents individual units of work
|
32
|
+
- Properties: id, description, agent_spec, input, output, status
|
33
|
+
- Behaviors: initialization, performance, verification
|
34
|
+
- **TaskResult**: Encapsulates the outcome of task execution
|
35
|
+
- Properties: task_id, success, output, failure
|
36
|
+
- Behaviors: result inspection, serialization
|
37
|
+
- **TaskFailure**: Captures detailed failure information
|
38
|
+
- Properties: message, type, timestamp, context
|
39
|
+
- Behaviors: error contextualization, serialization
|
40
|
+
|
41
|
+
**Design Principles**:
|
42
|
+
- State management through immutable objects
|
43
|
+
- Event-driven communication between components
|
44
|
+
- Transaction-like semantics for task execution
|
45
|
+
- Observable pattern for task state notification
|
46
|
+
- Result-oriented failure handling
|
47
|
+
|
48
|
+
### 3. Verification Layer
|
49
|
+
|
50
|
+
**Purpose**: Ensures quality and correctness of execution.
|
51
|
+
|
52
|
+
**Components**:
|
53
|
+
- **VerificationHub**: Coordinates verification strategies
|
54
|
+
- **CriticFramework**: Provides multi-perspective evaluation
|
55
|
+
- **AdaptationEngine**: Implements feedback-driven adjustments
|
56
|
+
- **Verification Strategies**:
|
57
|
+
- Schema validation
|
58
|
+
- LLM-based evaluation
|
59
|
+
- Quantitative metrics analysis
|
60
|
+
- Goal alignment checking
|
61
|
+
|
62
|
+
**Design Principles**:
|
63
|
+
- Strategy pattern for verification methods
|
64
|
+
- Observer pattern for reporting and monitoring
|
65
|
+
- Progressive verification with escalation paths
|
66
|
+
|
67
|
+
### 4. Extension System
|
68
|
+
|
69
|
+
**Purpose**: Enables adaptation to different domains and use cases.
|
70
|
+
|
71
|
+
**Components**:
|
72
|
+
- **PluginManager**: Handles third-party extensions, registration, and lifecycle
|
73
|
+
- Plugin discovery and auto-loading
|
74
|
+
- Enable/disable functionality
|
75
|
+
- Metadata tracking for version management
|
76
|
+
- Event hooks for plugin lifecycle events
|
77
|
+
- **DomainAdapter**: Integrates domain-specific knowledge
|
78
|
+
- Context-aware adaptation of prompts, tasks, and verification
|
79
|
+
- Domain knowledge repository
|
80
|
+
- Custom adapters for different components
|
81
|
+
- Pluggable adaptation strategies
|
82
|
+
- **ProtocolHandler**: Standardizes external system connections
|
83
|
+
- Uniform interface for different communication protocols
|
84
|
+
- Configuration management
|
85
|
+
- Request/response standardization
|
86
|
+
- Error handling and logging
|
87
|
+
|
88
|
+
**Design Principles**:
|
89
|
+
- Interface-based contracts for extensions
|
90
|
+
- Composition over inheritance
|
91
|
+
- Versioned APIs for stability
|
92
|
+
- Progressive enhancement of functionality
|
93
|
+
- Defensive programming with graceful degradation
|
94
|
+
- Standardized logging and error reporting
|
95
|
+
|
96
|
+
## Learning System
|
97
|
+
|
98
|
+
**Purpose**: Enables the system to improve over time.
|
99
|
+
|
100
|
+
**Components**:
|
101
|
+
- **ExecutionHistoryStore**: Captures performance data
|
102
|
+
- **PatternRecognizer**: Identifies optimization opportunities
|
103
|
+
- **StrategyOptimizer**: Improves execution strategies
|
104
|
+
|
105
|
+
**Design Principles**:
|
106
|
+
- Anonymized telemetry collection
|
107
|
+
- Incremental learning with stability guarantees
|
108
|
+
- Performance benchmarking against baselines
|
109
|
+
|
110
|
+
## Human Interface
|
111
|
+
|
112
|
+
**Purpose**: Facilitates human oversight and intervention.
|
113
|
+
|
114
|
+
**Components**:
|
115
|
+
- **InterventionPortal**: Manages human input requests/responses
|
116
|
+
- **ExplanationEngine**: Provides transparency into system decisions
|
117
|
+
- **ConfigurationInterface**: Enables system customization
|
118
|
+
|
119
|
+
**Design Principles**:
|
120
|
+
- Progressive automation of common interventions
|
121
|
+
- Clear explanation of system reasoning
|
122
|
+
- Configurable confidence thresholds
|
123
|
+
|
124
|
+
## Critical Human Intervention Points
|
125
|
+
|
126
|
+
1. **Ethical Boundaries**: Human approval for ethically sensitive tasks
|
127
|
+
2. **Domain Expertise Gaps**: Specialized knowledge provision
|
128
|
+
3. **Novel Situation Handling**: Guidance for unprecedented scenarios
|
129
|
+
4. **Success Criteria Definition**: Establishing nuanced evaluation metrics
|
130
|
+
5. **Error Recovery**: Intervention when automatic recovery fails
|
131
|
+
6. **Agent Selection Validation**: Confirming appropriate agent assignments
|
132
|
+
7. **Resource Authorization**: Approving access to restricted resources
|
133
|
+
8. **Strategic Direction**: High-level course correction
|
134
|
+
9. **Confidence Thresholds**: Proceeding despite uncertainty
|
135
|
+
10. **Final Output Validation**: Approving complete solutions
|
136
|
+
|
137
|
+
## Implementation Strategy
|
138
|
+
|
139
|
+
1. **Layered Development**:
|
140
|
+
- Start with core execution components
|
141
|
+
- Add verification layer
|
142
|
+
- Implement learning capabilities
|
143
|
+
- Enhance human interface
|
144
|
+
|
145
|
+
2. **Progressive Automation**:
|
146
|
+
- Begin with high human oversight
|
147
|
+
- Track intervention patterns
|
148
|
+
- Gradually automate common interventions
|
149
|
+
- Build intervention knowledge base
|
150
|
+
|
151
|
+
3. **Extensibility First**:
|
152
|
+
- Define clear extension points
|
153
|
+
- Create minimal implementations
|
154
|
+
- Document interfaces thoroughly
|
155
|
+
- Provide example extensions
|
156
|
+
|
157
|
+
4. **Continuous Verification**:
|
158
|
+
- Implement metrics collection early
|
159
|
+
- Establish performance baselines
|
160
|
+
- Create automated verification
|
161
|
+
- Build regression test suite
|
162
|
+
|
163
|
+
## Data Flow
|
164
|
+
|
165
|
+
```
|
166
|
+
Goal → TaskPlanner → Tasks → PlanOrchestrator
|
167
|
+
↓
|
168
|
+
Agent Selection → Task Execution → Verification
|
169
|
+
↓
|
170
|
+
Feedback Loop → Task Adaptation → Final Output
|
171
|
+
```
|
172
|
+
|
173
|
+
With verification points at each transition and potential human intervention based on confidence thresholds.
|
174
|
+
|
175
|
+
## Next Steps
|
176
|
+
|
177
|
+
1. ✅ Implement the Task class with result-oriented failure handling
|
178
|
+
2. ✅ Implement TaskResult and TaskFailure supporting classes
|
179
|
+
3. ✅ Add Observable pattern for task state notification
|
180
|
+
4. ✅ Create PlanOrchestrator for task execution with Async
|
181
|
+
5. ✅ Implement verification hub and basic verification strategies
|
182
|
+
6. ✅ Implement AdaptationEngine for feedback-driven adjustments
|
183
|
+
7. ✅ Implement Extension System components (PluginManager, DomainAdapter, ProtocolHandler)
|
184
|
+
8. ✅ Implement Learning System components (ExecutionHistoryStore, PatternRecognizer, StrategyOptimizer)
|
185
|
+
9. ✅ Implement metrics collection
|
186
|
+
10. Add human intervention portal
|
187
|
+
|
188
|
+
For detailed design documentation on specific architectural decisions, see the `.architecture-review` directory, which contains in-depth analysis of:
|
189
|
+
- Task Input Handling
|
190
|
+
- Task Output Handling
|
191
|
+
- Task Failure Handling
|
192
|
+
- Prompt Generation
|
193
|
+
- Task Observable Pattern
|
194
|
+
- Adaptation Engine
|
195
|
+
- Extension System
|
196
|
+
- Learning System
|
197
|
+
|
198
|
+
## Conclusion
|
199
|
+
|
200
|
+
This architecture provides a flexible, extensible framework for AI agent orchestration that can adapt to different domains while maintaining quality through verification and human oversight. The system is designed to improve over time through learning from execution history and human feedback.
|
@@ -0,0 +1,196 @@
|
|
1
|
+
# ADR 001: Observer Pattern Implementation
|
2
|
+
|
3
|
+
## Status
|
4
|
+
|
5
|
+
Proposed
|
6
|
+
|
7
|
+
## Context
|
8
|
+
|
9
|
+
The Agentic framework requires an event notification system to enable components to react to changes in Task state. We've designed the architecture to use the Observer pattern, initially intending to use Ruby's built-in `Observable` module from the standard library.
|
10
|
+
|
11
|
+
However, as of Ruby 3.0, the `Observable` module has been extracted from the standard library into a separate gem: [observer](https://github.com/ruby/observer). This change necessitates a decision on how to implement the Observer pattern in our framework.
|
12
|
+
|
13
|
+
## Decision Drivers
|
14
|
+
|
15
|
+
1. **Dependency Management**: Minimizing unnecessary external dependencies
|
16
|
+
2. **API Stability**: Ensuring a stable interface for observers
|
17
|
+
3. **Performance**: Efficient notification for potentially large numbers of observers
|
18
|
+
4. **Thread Safety**: Support for concurrent task execution
|
19
|
+
5. **Maintainability**: Ease of understanding and maintaining the code
|
20
|
+
6. **Flexibility**: Ability to extend or customize behavior as needed
|
21
|
+
|
22
|
+
## Options Considered
|
23
|
+
|
24
|
+
### 1. Use the 'observer' gem
|
25
|
+
|
26
|
+
**Description**:
|
27
|
+
- Add the 'observer' gem as a dependency
|
28
|
+
- Continue using the `Observable` module as originally planned
|
29
|
+
|
30
|
+
**Pros**:
|
31
|
+
- Maintains compatibility with standard Ruby practices
|
32
|
+
- Minimal implementation effort
|
33
|
+
- Well-understood behavior
|
34
|
+
- Maintained by the Ruby core team
|
35
|
+
|
36
|
+
**Cons**:
|
37
|
+
- Adds an external dependency to the project
|
38
|
+
- Limited control over implementation details
|
39
|
+
- Not thread-safe by default
|
40
|
+
- Slightly less performance than a custom solution
|
41
|
+
|
42
|
+
### 2. Implement a minimal custom observer pattern
|
43
|
+
|
44
|
+
**Description**:
|
45
|
+
- Create our own simple observer implementation within the framework
|
46
|
+
- Focus on just the functionality we need
|
47
|
+
|
48
|
+
**Pros**:
|
49
|
+
- No external dependency
|
50
|
+
- Complete control over implementation
|
51
|
+
- Can be optimized for our specific use case
|
52
|
+
- Can be made thread-safe from the start
|
53
|
+
|
54
|
+
**Cons**:
|
55
|
+
- Requires maintaining custom code
|
56
|
+
- Need to ensure compatibility with standard observer patterns
|
57
|
+
- Potential for bugs in our implementation
|
58
|
+
|
59
|
+
### 3. Use the Wisper gem
|
60
|
+
|
61
|
+
**Description**:
|
62
|
+
- Add the 'wisper' gem as a dependency
|
63
|
+
- Use its pub/sub implementation for event notifications
|
64
|
+
|
65
|
+
**Pros**:
|
66
|
+
- More modern pub/sub implementation
|
67
|
+
- Additional features like global listeners, temporary subscriptions
|
68
|
+
- Well maintained and widely used
|
69
|
+
- Better separation between publishers and subscribers
|
70
|
+
|
71
|
+
**Cons**:
|
72
|
+
- More complex API than basic Observer pattern
|
73
|
+
- Adds an external dependency
|
74
|
+
- Potentially more than we need for our use case
|
75
|
+
|
76
|
+
### 4. Event-driven architecture with custom dispatcher
|
77
|
+
|
78
|
+
**Description**:
|
79
|
+
- Implement a centralized event dispatcher system
|
80
|
+
- Components register callbacks for specific event types
|
81
|
+
|
82
|
+
**Pros**:
|
83
|
+
- More flexible than traditional Observer pattern
|
84
|
+
- Can support multiple event types and filtering
|
85
|
+
- Centralized control over event propagation
|
86
|
+
- Potentially better performance for many observers
|
87
|
+
|
88
|
+
**Cons**:
|
89
|
+
- More complex implementation
|
90
|
+
- Different mental model than traditional Observer pattern
|
91
|
+
- Requires more coordination between components
|
92
|
+
|
93
|
+
## Decision
|
94
|
+
|
95
|
+
We will implement a minimal custom observer pattern (Option 2) that closely mirrors the API of Ruby's Observable module. This decision balances our need to minimize dependencies while maintaining a familiar and straightforward API.
|
96
|
+
|
97
|
+
The implementation will:
|
98
|
+
|
99
|
+
1. Be thread-safe by default
|
100
|
+
2. Support the familiar add_observer/delete_observer methods
|
101
|
+
3. Use a more explicit notification mechanism with event types
|
102
|
+
4. Include only what we need, no unnecessary features
|
103
|
+
|
104
|
+
### Implementation
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
module Agentic
|
108
|
+
module Observable
|
109
|
+
# Add an observer to this object
|
110
|
+
# @param observer [Object] The observer object
|
111
|
+
# @return [void]
|
112
|
+
def add_observer(observer)
|
113
|
+
@_observers ||= []
|
114
|
+
@_observers << observer unless @_observers.include?(observer)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Remove an observer from this object
|
118
|
+
# @param observer [Object] The observer object
|
119
|
+
# @return [void]
|
120
|
+
def delete_observer(observer)
|
121
|
+
@_observers&.delete(observer)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Remove all observers from this object
|
125
|
+
# @return [void]
|
126
|
+
def delete_observers
|
127
|
+
@_observers = []
|
128
|
+
end
|
129
|
+
|
130
|
+
# Return the number of observers
|
131
|
+
# @return [Integer] The number of observers
|
132
|
+
def count_observers
|
133
|
+
@_observers ? @_observers.size : 0
|
134
|
+
end
|
135
|
+
|
136
|
+
# Notify all observers of an event
|
137
|
+
# @param event_type [Symbol] The type of event
|
138
|
+
# @param *args Arguments to pass to the observers
|
139
|
+
# @return [void]
|
140
|
+
def notify_observers(event_type, *args)
|
141
|
+
return unless @_observers
|
142
|
+
|
143
|
+
# Make a thread-safe copy of the observers array
|
144
|
+
observers = @_observers.dup
|
145
|
+
|
146
|
+
observers.each do |observer|
|
147
|
+
if observer.respond_to?(:update)
|
148
|
+
observer.update(event_type, self, *args)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
```
|
155
|
+
|
156
|
+
## Consequences
|
157
|
+
|
158
|
+
### Positive
|
159
|
+
|
160
|
+
1. **No External Dependencies**: The framework will not require the 'observer' gem or any other external dependency for event notification.
|
161
|
+
2. **Thread Safety**: The implementation will be thread-safe by default, better supporting concurrent task execution.
|
162
|
+
3. **Explicit Event Types**: Using explicit event types in notifications provides more clarity than the generic notification in the standard Observable.
|
163
|
+
4. **Familiar API**: Developers familiar with Ruby's Observable will find our API intuitive and easy to use.
|
164
|
+
5. **Custom Control**: We have complete control over the implementation and can optimize or extend it as needed.
|
165
|
+
|
166
|
+
### Negative
|
167
|
+
|
168
|
+
1. **Custom Code Maintenance**: We'll need to maintain our own implementation, including testing and bug fixes.
|
169
|
+
2. **Slight Deviation**: Our API will slightly deviate from the standard Observable module (explicit event types).
|
170
|
+
3. **Potential Future Changes**: If Ruby's Observer gem becomes significantly more advanced, we might miss out on those improvements.
|
171
|
+
|
172
|
+
### Neutral
|
173
|
+
|
174
|
+
1. **Migration Path**: If needed, we can easily migrate to using the observer gem or another solution in the future with minimal changes to client code.
|
175
|
+
2. **Documentation**: We'll need to clearly document our Observable module, but this is standard practice regardless of implementation choice.
|
176
|
+
|
177
|
+
## Implementation Notes
|
178
|
+
|
179
|
+
1. The Observable module should be included in the Agentic namespace to avoid conflicts.
|
180
|
+
2. Thread safety is achieved by creating a copy of the observers array before iteration.
|
181
|
+
3. The implementation should be tested for both single-threaded and multi-threaded scenarios.
|
182
|
+
4. Documentation should clarify the slight differences from Ruby's standard Observable.
|
183
|
+
|
184
|
+
## Alternative Paths
|
185
|
+
|
186
|
+
If this implementation proves problematic in the future, we can:
|
187
|
+
|
188
|
+
1. Switch to using the 'observer' gem with minimal code changes
|
189
|
+
2. Adopt Wisper or another pub/sub gem if we need more advanced features
|
190
|
+
3. Develop a more comprehensive event system if our needs become more complex
|
191
|
+
|
192
|
+
## References
|
193
|
+
|
194
|
+
- [Ruby Observer gem](https://github.com/ruby/observer)
|
195
|
+
- [Wisper gem](https://github.com/krisleech/wisper)
|
196
|
+
- [Observer Pattern on Wikipedia](https://en.wikipedia.org/wiki/Observer_pattern)
|