π The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
π Checkpoint: Edit /workspaces/claude-code-flow/benchmark/test_optimization_fix.py
rUv2fae24667826
diff --git a/benchmark/.claude/checkpoints/1754448003.json b/benchmark/.claude/checkpoints/1754448003.jsonnew file mode 100644index 0000000000..b9c9acbf31--- /dev/null+++ b/benchmark/.claude/checkpoints/1754448003.json@@ -0,0 +1 @@+{"branch": "checkpoint/pre-edit-20250806-024003", "file": "/workspaces/claude-code-flow/benchmark/examples/advanced/optimization_suite.py", "timestamp": "2025-08-06T02:40:03Z", "type": "pre-edit", "original_branch": "alpha-88"}diff --git a/benchmark/.claude/checkpoints/1754448005.json b/benchmark/.claude/checkpoints/1754448005.jsonnew file mode 100644index 0000000000..2d099c9623--- /dev/null+++ b/benchmark/.claude/checkpoints/1754448005.json@@ -0,0 +1 @@+{"tag": "checkpoint-20250806-024005", "file": "/workspaces/claude-code-flow/benchmark/examples/advanced/optimization_suite.py", "timestamp": "2025-08-06T02:40:05Z", "type": "post-edit", "branch": "alpha-88", "diff_summary": " .claude-flow/metrics/system-metrics.json | 132 ++++++ benchmark/.claude-flow/metrics/performance.json | 2 +- benchmark/.claude-flow/metrics/task-metrics.json | 6 +- benchmark/.claude/checkpoints/1754447986.json | 1 + benchmark/.claude/checkpoints/1754447988.json | 1 + benchmark/examples/advanced/optimization_suite.py | 508 +++++++++++++++++++++ .../optimized_benchmark_engine.cpython-312.pyc | Bin 15770 -> 15428 bytes .../__pycache__/engine.cpython-312.pyc | Bin 32449 -> 33620 bytes claude-flow-wiki | 0 9 files changed, 646 insertions(+), 4 deletions(-) "}diff --git a/benchmark/test_optimization_fix.py b/benchmark/test_optimization_fix.pynew file mode 100644index 0000000000..e74ae79426--- /dev/null+++ b/benchmark/test_optimization_fix.py@@ -0,0 +1,167 @@+#!/usr/bin/env python3+"""+Test script to verify that the optimization warning has been fixed+and the optimization engine is working properly.+"""++import asyncio+import sys+import os++# Add the src directory to Python path+sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))++from swarm_benchmark.core.optimized_benchmark_engine import OptimizedBenchmarkEngine, OPTIMIZATIONS_AVAILABLE+from swarm_benchmark.core.models import BenchmarkConfig, StrategyType, CoordinationMode+from swarm_benchmark.optimization import OptimizedExecutor, CircularBuffer, TTLMap, AsyncFileManager+++async def test_optimization_components():+ """Test individual optimization components."""+ print("π§ͺ Testing optimization components...")++ # Test CircularBuffer+ print(" β Testing CircularBuffer...")+ buffer = CircularBuffer(5)+ for i in range(10):+ buffer.push(f"item_{i}")++ recent = buffer.get_recent(3)+ print(f" Recent items: {len(recent)}")+ print(f" Total written: {buffer.getTotalItemsWritten()}")++ # Test TTLMap+ print(" β Testing TTLMap...")+ ttl_map = TTLMap({'defaultTTL': 1000, 'maxSize': 100})+ ttl_map.set('test_key', 'test_value')++ value = ttl_map.get('test_key')+ stats = ttl_map.getStats()+ print(f" Cache hit rate: {stats['hit_rate']:.2f}")++ # Test AsyncFileManager+ print(" β Testing AsyncFileManager...")+ file_manager = AsyncFileManager()++ test_data = {'message': 'Hello optimization!', 'timestamp': '2025-01-01'}+ await file_manager.writeJSON('/tmp/test_optimization.json', test_data, pretty=True)++ read_data = await file_manager.readJSON('/tmp/test_optimization.json')+ print(f" File I/O test: {'β PASS' if read_data['message'] == test_data['message'] else 'β FAIL'}")++ # Test OptimizedExecutor+ print(" β Testing OptimizedExecutor...")+ executor = OptimizedExecutor({+ 'connectionPool': {'min': 2, 'max': 5},+ 'concurrency': 3+ })++ # Create mock tasks+ mock_tasks = [+ type('Task', (), {'id': f'task_{i}', 'objective': f'Test task {i}'})()+ for i in range(3)+ ]++ results = await executor.execute_parallel(mock_tasks)+ metrics = executor.getMetrics()++ print(f" Executed {len(results)} tasks")+ print(f" Average execution time: {metrics['average_execution_time']:.3f}s")++ await executor.shutdown()++ # Cleanup+ ttl_map.destroy()+ await file_manager.waitForPendingOperations()++ print("β All optimization components tested successfully!")+++async def test_optimized_benchmark_engine():+ """Test the OptimizedBenchmarkEngine."""+ print("\nποΈ Testing OptimizedBenchmarkEngine...")++ config = BenchmarkConfig(+ name="optimization_test",+ description="Test optimization functionality",+ strategy=StrategyType.DEVELOPMENT,+ mode=CoordinationMode.MESH,+ max_agents=3,+ task_timeout=30,+ max_retries=2+ )++ engine = OptimizedBenchmarkEngine(config, enable_optimizations=True)++ print(f" Optimizations available: {OPTIMIZATIONS_AVAILABLE}")+ print(f" Optimizations enabled: {engine.optimizations_enabled}")++ if engine.optimizations_enabled:+ print(" β Optimization engine initialized successfully")++ # Test a simple benchmark+ result = await engine.run_benchmark("Test optimization engine functionality")++ print(f" β Benchmark completed: {result['status']}")+ print(f" β Duration: {result.get('duration', 'N/A')}s")+ print(f" β Optimized: {result.get('optimized', False)}")++ # Test performance metrics+ if 'performance_metrics' in result:+ metrics = result['performance_metrics']+ print(f" β Performance metrics available: {len(metrics)} categories")++ await engine.shutdown()+ print("β OptimizedBenchmarkEngine tested successfully!")+ else:+ print("β οΈ Optimizations not enabled, but engine still functional")+++def test_import_fix():+ """Test that the import issue has been resolved."""+ print("π§ Testing import fix...")++ try:+ from swarm_benchmark.optimization import (+ OptimizedExecutor, CircularBuffer, TTLMap, AsyncFileManager+ )+ print(" β Direct optimization imports successful")++ from swarm_benchmark.core.optimized_benchmark_engine import OPTIMIZATIONS_AVAILABLE+ print(f" β OPTIMIZATIONS_AVAILABLE: {OPTIMIZATIONS_AVAILABLE}")++ if OPTIMIZATIONS_AVAILABLE:+ print("β Import fix successful - no more warnings!")+ return True+ else:+ print("β οΈ Optimizations not available, but no import errors")+ return False++ except ImportError as e:+ print(f"β Import failed: {e}")+ return False+++async def main():+ """Run all tests."""+ print("π Testing optimization engine fix...\n")++ # Test 1: Import fix+ import_success = test_import_fix()++ if import_success:+ # Test 2: Individual components+ await test_optimization_components()++ # Test 3: Full engine+ await test_optimized_benchmark_engine()++ print("\nπ All tests completed successfully!")+ print("The optimization warning has been fixed and the engine is fully functional.")+ else:+ print("\nβ οΈ Tests completed with some limitations.")+ print("The optimization engine provides fallback functionality.")+++if __name__ == "__main__":+ asyncio.run(main())\ No newline at end of filediff --git a/benchmark/tests/__pycache__/test_cli.cpython-312-pytest-8.4.0.pyc b/benchmark/tests/__pycache__/test_cli.cpython-312-pytest-8.4.0.pycnew file mode 100644index 0000000000..23208867b1Binary files /dev/null and b/benchmark/tests/__pycache__/test_cli.cpython-312-pytest-8.4.0.pyc differ