v3/implementation/adrs/ADR-001-AGENT-IMPLEMENTATION.md
This document describes the implementation of ADR-001: Adopt agentic-flow as Core Foundation for agent lifecycle management in Claude Flow v3.
Created two new core classes that bridge Claude Flow's DDD agent architecture with agentic-flow's optimized agent implementations:
agentic-flow-agent.ts)Purpose: Base class for all Claude Flow v3 agents with automatic delegation to agentic-flow
Key Features:
IAgent interface for DDD compliancePerformance Benefits:
Code Stats:
agent-adapter.ts)Purpose: Bidirectional adapter between Claude Flow and agentic-flow agent formats
Key Features:
Capabilities:
fromAgenticFlow(): Convert external agents to Claude Flow formattoAgenticFlow(): Export agents in agentic-flow formatcreateWithDelegation(): Create agents with automatic delegationCode Stats:
// Set agentic-flow reference for delegation
agent.setAgenticFlowReference(agenticFlowAgent);
// Operations automatically delegate when available
const result = await agent.executeTask(task);
// ↑ Delegates to agentic-flow.execute() if available
// ↓ Falls back to local implementation if not
// Create adapter
const adapter = await createAgentAdapter({
enableSync: true,
autoConvert: true,
fallbackOnError: true,
});
// Create agent with delegation
const agent = await adapter.createWithDelegation({
id: 'agent-1',
name: 'Coder Agent',
type: 'coder',
capabilities: ['code-generation'],
maxConcurrentTasks: 3,
priority: 5,
});
// Simple agent creation
const agent = await createAgenticFlowAgent({
id: 'agent-1',
name: 'Test Agent',
type: 'coder',
capabilities: ['code-generation'],
maxConcurrentTasks: 3,
priority: 5,
});
All types are self-contained in the integration module to avoid cross-module compilation issues:
AgentStatus: Agent lifecycle statesAgentType: Agent classificationsIAgentConfig: Agent configuration interfaceIAgent: Core agent entity interfaceTask: Task execution interfaceTaskResult: Execution result interfaceMessage: Inter-agent communicationAgentHealth: Health monitoringComprehensive test suites included:
agentic-flow-agent.test.ts)agent-adapter.test.ts)Test Coverage:
// From @claude-flow/integration
import {
// Agent classes
AgenticFlowAgent,
createAgenticFlowAgent,
AgentAdapter,
createAgentAdapter,
// Types
IAgent,
IAgentConfig,
AgentStatus,
AgentType,
Task,
TaskResult,
Message,
AgentHealth,
} from '@claude-flow/integration';
The implementation follows the same patterns as:
All adapters use:
setAgenticFlowReference() for delegationisDelegationEnabled() for status checksv3/@claude-flow/integration/src/
├── agentic-flow-agent.ts # 799 lines - Base agent class
├── agent-adapter.ts # 625 lines - Adapter class
├── __tests__/
│ ├── agentic-flow-agent.test.ts # Agent tests
│ └── agent-adapter.test.ts # Adapter tests
└── index.ts # Updated exports
Total: 1,424 lines of production code + 200 lines of tests
✅ Use agentic-flow's Agent base class for all agents
✅ Eliminate duplicate code
✅ Maintain backward compatibility
✅ Follow DDD architecture
✅ Performance targets
const agent = new AgenticFlowAgent({
id: 'coder-1',
name: 'Coder Agent',
type: 'coder',
capabilities: ['code-generation', 'refactoring'],
maxConcurrentTasks: 3,
priority: 5,
});
await agent.initialize();
const result = await agent.executeTask({
id: 'task-1',
type: 'code',
description: 'Implement authentication',
input: { spec: '...' },
});
console.log(result.success); // true
console.log(result.output); // Implementation result
const adapter = await createAgentAdapter();
const agent = await adapter.createWithDelegation({
id: 'agent-1',
name: 'Delegated Agent',
type: 'coder',
capabilities: ['code-generation'],
maxConcurrentTasks: 3,
priority: 5,
});
// Task execution automatically delegates to agentic-flow
const result = await agent.executeTask(task);
const health = agent.getHealth();
console.log(health.status); // 'healthy'
console.log(health.metrics.uptime); // Uptime in ms
console.log(health.metrics.tasksCompleted); // Task count
/v3/@claude-flow/integration/src/sona-adapter.ts/v3/@claude-flow/integration/src/attention-coordinator.ts/v3/@claude-flow/integration/src/agentic-flow-bridge.ts/v3/@claude-flow/shared/src/core/interfaces/agent.interface.tsImplementation Date: 2026-01-04 Status: ✅ Complete Version: 3.0.0-alpha.1