diff --git a/.windsurf/workflows/OPENCLAW_MASTER_INDEX.md b/.windsurf/workflows/OPENCLAW_MASTER_INDEX.md new file mode 100644 index 00000000..e5830059 --- /dev/null +++ b/.windsurf/workflows/OPENCLAW_MASTER_INDEX.md @@ -0,0 +1,286 @@ +--- +description: Master index for OpenClaw workflows - links to all modules and provides navigation +title: OpenClaw Workflows - Master Index +version: 1.0 +--- + +# OpenClaw Workflows - Master Index + +This master index provides navigation to all OpenClaw agent workflows and documentation. Each workflow focuses on specific aspects of OpenClaw agent training, coordination, and testing. + +## πŸ“š Module Overview + +### πŸŽ“ Agent Training Modules + +#### Cross-Node Communication Training +**File**: `openclaw-cross-node-communication.md` +**Purpose**: Specialized training for agent-to-agent cross-node communication via AITBC blockchain +**Audience**: OpenClaw agents learning multi-node coordination +**Prerequisites**: Stage 2 of Mastery Plan, both nodes synchronized + +**Key Topics**: +- Agent registration on multiple blockchain nodes +- Peer discovery across blockchain state +- Cross-node messaging via blockchain transactions +- Distributed task execution +- Event monitoring and message parsing + +**Quick Start**: +```bash +cd /opt/aitbc/scripts/training +./openclaw_cross_node_comm.sh +``` + +--- + +### πŸ§ͺ Agent Testing Modules + +#### Ollama GPU Provider Test (OpenClaw) +**File**: `ollama-gpu-test-openclaw.md` +**Purpose**: Complete end-to-end test for Ollama GPU inference jobs using OpenClaw agents +**Audience**: QA engineers, OpenClaw developers +**Prerequisites**: OpenClaw 2026.3.24+, all services running, enhanced CLI + +**Key Topics**: +- Environment validation with OpenClaw agents +- Wallet setup and management +- Service health verification +- GPU test execution and monitoring +- Payment processing and validation +- Blockchain transaction recording +- Comprehensive test reporting + +**Quick Start**: +```bash +SESSION_ID="ollama-gpu-test-$(date +%s)" +openclaw agent --agent test-coordinator --session-id $SESSION_ID \ + --message "Initialize complete Ollama GPU test workflow" \ + --thinking high +``` + +--- + +### πŸ€– Agent Coordination Modules + +#### Agent Coordination Plan Enhancement +**File**: `agent-coordination-enhancement.md` +**Purpose**: Advanced multi-agent communication patterns, distributed decision making, and scalable architectures +**Audience**: OpenClaw developers, system architects +**Prerequisites**: Advanced AI Teaching Plan completed + +**Key Topics**: +- Hierarchical, peer-to-peer, and broadcast communication patterns +- Consensus-based and weighted decision making +- Microservices, load balancing, and federated architectures +- Multi-agent task orchestration +- Performance metrics and monitoring +- Implementation guidelines + +**Quick Start**: +```bash +SESSION_ID="coordination-$(date +%s)" +openclaw agent --agent CoordinatorAgent --session-id $SESSION_ID \ + --message "BROADCAST: System-wide resource optimization initiated" \ + --thinking high +``` + +--- + +## πŸ—ΊοΈ Module Dependencies + +``` +Cross-Node Communication Training (Foundation) +β”œβ”€β”€ Ollama GPU Provider Test (Testing) +└── Agent Coordination Enhancement (Advanced) +``` + +## πŸš€ Recommended Learning Path + +### For New OpenClaw Users +1. **Cross-Node Communication Training** - Learn basic multi-node messaging +2. **Ollama GPU Provider Test** - Practice agent-based testing +3. **Agent Coordination Enhancement** - Master advanced coordination + +### For OpenClaw Developers +1. **Cross-Node Communication Training** - Understand multi-node architecture +2. **Agent Coordination Enhancement** - Master coordination patterns +3. **Ollama GPU Provider Test** - Learn testing methodology + +### For System Architects +1. **Cross-Node Communication Training** - Understand distributed messaging +2. **Agent Coordination Enhancement** - Design scalable architectures +3. **Ollama GPU Provider Test** - Learn testing patterns + +## 🎯 Quick Navigation + +### By Task + +| Task | Recommended Module | +|---|---| +| **Multi-Node Messaging** | Cross-Node Communication Training | +| **Agent-Based Testing** | Ollama GPU Provider Test | +| **Advanced Coordination** | Agent Coordination Enhancement | +| **Distributed Decision Making** | Agent Coordination Enhancement | +| **Performance Monitoring** | Agent Coordination Enhancement | + +### By Role + +| Role | Essential Modules | +|---|---| +| **OpenClaw Developer** | Cross-Node Communication Training, Agent Coordination Enhancement | +| **QA Engineer** | Ollama GPU Provider Test, Cross-Node Communication Training | +| **System Architect** | Agent Coordination Enhancement, Cross-Node Communication Training | +| **DevOps Engineer** | Ollama GPU Provider Test, Agent Coordination Enhancement | + +### By Complexity + +| Level | Modules | +|---|---| +| **Beginner** | Cross-Node Communication Training | +| **Intermediate** | Ollama GPU Provider Test | +| **Advanced** | Agent Coordination Enhancement | +| **Expert** | All modules | + +## πŸ” Quick Reference Commands + +### Cross-Node Communication +```bash +# Register agent on genesis node +NODE_URL=http://10.1.223.40:8006 ./aitbc-cli agent create \ + --name "openclaw-genesis-commander" \ + --description "Primary coordinator agent" \ + --verification full + +# Send cross-node message +NODE_URL=http://10.1.223.40:8006 ./aitbc-cli agent message \ + --to $FOLLOWER_AGENT_ID \ + --content "{\"cmd\":\"STATUS_REPORT\",\"priority\":\"high\"}" +``` + +### Ollama GPU Testing +```bash +# Initialize test coordinator +SESSION_ID="ollama-test-$(date +%s)" +openclaw agent --agent test-coordinator --session-id $SESSION_ID \ + --message "Initialize Ollama GPU provider test workflow" \ + --thinking high + +# Submit inference job +openclaw agent --agent client-agent --session-id $SESSION_ID \ + --message "Submit Ollama GPU inference job" \ + --parameters "prompt:What is the capital of France?,model:llama3.2:latest" +``` + +### Agent Coordination +```bash +# Hierarchical communication +SESSION_ID="hierarchy-$(date +%s)" +openclaw agent --agent CoordinatorAgent --session-id $SESSION_ID \ + --message "Broadcast: Execute distributed AI workflow" \ + --thinking high + +# Consensus voting +openclaw agent --agent GenesisAgent --session-id $SESSION_ID \ + --message "VOTE $PROPOSAL_ID: YES - Dynamic allocation optimizes AI performance" \ + --thinking medium +``` + +## πŸ“Š System Overview + +### OpenClaw Architecture +``` +OpenClaw Agent Ecosystem: +β”œβ”€β”€ Genesis Node (aitbc) - Primary development server +β”œβ”€β”€ Follower Node (aitbc1) - Secondary node +β”œβ”€β”€ Agent Gateway - OpenClaw communication layer +β”œβ”€β”€ Blockchain Messaging - Transaction-based agent communication +β”œβ”€β”€ Smart Contracts - Agent messaging and governance +β”œβ”€β”€ GPU Services - Ollama inference and resource management +└── Monitoring - Agent performance and coordination metrics +``` + +### Key Components +- **Agent Gateway**: OpenClaw communication and coordination +- **Blockchain Messaging**: Transaction-based cross-node communication +- **Smart Contracts**: Agent messaging, reputation, and governance +- **GPU Services**: Ollama inference, resource allocation +- **Monitoring**: Agent performance, communication metrics + +## 🎯 Success Metrics + +### Training Success +- [ ] Agents registered on multiple nodes +- [ ] Cross-node messaging functional +- [ ] Distributed task execution working +- [ ] Event monitoring operational + +### Testing Success +- [ ] Environment validation passing +- [ ] GPU test execution successful +- [ ] Payment processing validated +- [ ] Blockchain recording verified + +### Coordination Success +- [ ] Communication latency <100ms +- [ ] Decision accuracy >95% +- [ ] Scalability: 10+ concurrent agents +- [ ] Fault tolerance >99% availability + +## πŸ”§ Troubleshooting Quick Reference + +### Common Issues +| Issue | Module | Solution | +|---|---|---| +| Agent registration fails | Cross-Node Communication Training | Check node sync, verify wallet | +| Cross-node messages not delivered | Cross-Node Communication Training | Verify agent IDs, check blockchain sync | +| GPU test fails | Ollama GPU Provider Test | Check Ollama service, GPU availability | +| Coordination timeout | Agent Coordination Enhancement | Check agent gateway, session management | + +### Emergency Procedures +1. **Agent Recovery**: Restart OpenClaw gateway, check agent status +2. **Network Recovery**: Check node connectivity, restart P2P service +3. **Blockchain Recovery**: Check node sync, verify transaction pool +4. **Service Recovery**: Restart coordinator, Ollama, GPU miner + +## πŸ“š Additional Resources + +### Documentation Files +- **OpenClaw Agent Capabilities**: `docs/openclaw/OPENCLAW_AGENT_CAPABILITIES_ADVANCED.md` +- **Agent Communication Guide**: `docs/openclaw/guides/openclaw_agent_fix_summary.md` +- **Messaging Implementation**: `docs/openclaw/guides/openclaw_messaging_implementation_guide.md` +- **Cross-Node Communication**: `docs/openclaw/guides/openclaw_cross_node_communication.md` + +### Workflow Scripts +- **Cross-Node Training**: `/opt/aitbc/scripts/training/openclaw_cross_node_comm.sh` +- **Ollama GPU Test**: `ollama_gpu_test_openclaw.sh` +- **Agent Communication Fix**: `/opt/aitbc/scripts/workflow-openclaw/fix_agent_communication.sh` + +## πŸ”„ Version History + +### v1.0 (Current) +- Created master index for OpenClaw workflows +- Organized workflows by training, testing, and coordination +- Added navigation and learning paths +- Included quick reference commands and troubleshooting + +## 🀝 Contributing + +### Updating Documentation +1. Update specific module files +2. Update this master index if needed +3. Update cross-references between modules +4. Test all links and commands +5. Commit changes with descriptive message + +### Module Creation +1. Follow established template structure +2. Include prerequisites and dependencies +3. Add quick start commands +4. Include troubleshooting section +5. Update this master index + +--- + +**Note**: This master index is your starting point for all OpenClaw workflow operations. Choose the appropriate module based on your current task and expertise level. + +For immediate help, see the **Cross-Node Communication Training** module for foundational knowledge, or the **Agent Coordination Enhancement** module for advanced patterns. diff --git a/scripts/training/openclaw_coordination_demo.sh b/scripts/training/openclaw_coordination_demo.sh new file mode 100755 index 00000000..a18b5349 --- /dev/null +++ b/scripts/training/openclaw_coordination_demo.sh @@ -0,0 +1,310 @@ +#!/bin/bash +# OpenClaw Agent Coordination Demo Script +# Demonstrates multi-agent communication patterns, distributed decision making, and scalable architectures + +set -e + +SESSION_ID="coordination-demo-$(date +%s)" +echo "OpenClaw Agent Coordination Demo" +echo "Session ID: $SESSION_ID" +echo "" + +# Color codes for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +log_info() { + echo -e "${BLUE}[INFO]${NC} $1" +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $1" +} + +log_warning() { + echo -e "${YELLOW}[WARNING]${NC} $1" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +# Check if OpenClaw is available +if ! command -v openclaw &> /dev/null; then + log_error "OpenClaw not found. Please install OpenClaw 2026.3.24+" + exit 1 +fi + +log_info "OpenClaw version: $(openclaw --version)" + +# ============================================================================ +# Pattern 1: Hierarchical Communication +# ============================================================================ +log_info "=== Pattern 1: Hierarchical Communication ===" + +log_info "Coordinator broadcasts to Level 2 agents..." +openclaw agent --agent CoordinatorAgent --session-id $SESSION_ID \ + --message "BROADCAST: Execute distributed AI workflow across all Level 2 agents" \ + --thinking high \ + --parameters "broadcast_type:hierarchical,target_level:2" + +sleep 2 + +log_info "Level 2 agents respond to coordinator..." +openclaw agent --agent GenesisAgent --session-id $SESSION_ID \ + --message "Response to Coordinator: Ready for AI workflow execution with resource optimization" \ + --thinking medium + +openclaw agent --agent FollowerAgent --session-id $SESSION_ID \ + --message "Response to Coordinator: Ready for distributed task participation" \ + --thinking medium + +openclaw agent --agent AIResourceAgent --session-id $SESSION_ID \ + --message "Response to Coordinator: Ready for resource allocation management" \ + --thinking medium + +log_success "Hierarchical communication pattern demonstrated" + +# ============================================================================ +# Pattern 2: Peer-to-Peer Communication +# ============================================================================ +log_info "" +log_info "=== Pattern 2: Peer-to-Peer Communication ===" + +log_info "Direct agent-to-agent communication..." +openclaw agent --agent GenesisAgent --session-id $SESSION_ID \ + --message "P2P to FollowerAgent: Coordinate resource allocation for AI job batch" \ + --thinking medium + +sleep 2 + +openclaw agent --agent FollowerAgent --session-id $SESSION_ID \ + --message "P2P to GenesisAgent: Confirm resource availability and scheduling" \ + --thinking medium + +log_success "Peer-to-peer communication pattern demonstrated" + +# ============================================================================ +# Pattern 3: Consensus-Based Decision Making +# ============================================================================ +log_info "" +log_info "=== Pattern 3: Consensus-Based Decision Making ===" + +PROPOSAL_ID="resource-strategy-$(date +%s)" + +log_info "Coordinator presents proposal..." +openclaw agent --agent CoordinatorAgent --session-id $SESSION_ID \ + --message "VOTE PROPOSAL $PROPOSAL_ID: Implement dynamic GPU allocation with 70% utilization target" \ + --thinking high + +sleep 2 + +log_info "Agents vote on proposal..." +openclaw agent --agent GenesisAgent --session-id $SESSION_ID \ + --message "VOTE $PROPOSAL_ID: YES - Dynamic allocation optimizes AI performance" \ + --thinking medium + +openclaw agent --agent FollowerAgent --session-id $SESSION_ID \ + --message "VOTE $PROPOSAL_ID: YES - Improves resource utilization" \ + --thinking medium + +openclaw agent --agent AIResourceAgent --session-id $SESSION_ID \ + --message "VOTE $PROPOSAL_ID: YES - Aligns with optimization goals" \ + --thinking medium + +sleep 2 + +log_info "Coordinator announces decision..." +openclaw agent --agent CoordinatorAgent --session-id $SESSION_ID \ + --message "DECISION: Proposal $PROPOSAL_ID APPROVED (3/3 votes) - Implementing dynamic GPU allocation" \ + --thinking high + +log_success "Consensus-based decision making demonstrated" + +# ============================================================================ +# Pattern 4: Weighted Decision Making +# ============================================================================ +log_info "" +log_info "=== Pattern 4: Weighted Decision Making ===" + +log_info "Coordinator requests weighted recommendations..." +openclaw agent --agent CoordinatorAgent --session-id $SESSION_ID \ + --message "WEIGHTED DECISION: Select optimal AI model for medical diagnosis pipeline" \ + --thinking high + +sleep 2 + +log_info "Agents provide weighted recommendations..." +openclaw agent --agent GenesisAgent --session-id $SESSION_ID \ + --message "RECOMMENDATION: ensemble_model (confidence: 0.9, weight: 3) - Best for accuracy" \ + --thinking high + +openclaw agent --agent MultiModalAgent --session-id $SESSION_ID \ + --message "RECOMMENDATION: multimodal_model (confidence: 0.8, weight: 2) - Handles multiple data types" \ + --thinking high + +openclaw agent --agent AIResourceAgent --session-id $SESSION_ID \ + --message "RECOMMENDATION: efficient_model (confidence: 0.7, weight: 1) - Best resource utilization" \ + --thinking medium + +sleep 2 + +log_info "Coordinator calculates weighted decision..." +openclaw agent --agent CoordinatorAgent --session-id $SESSION_ID \ + --message "WEIGHTED DECISION: ensemble_model selected (weighted score: 2.7) - Highest confidence-weighted combination" \ + --thinking high + +log_success "Weighted decision making demonstrated" + +# ============================================================================ +# Pattern 5: Microservices Architecture +# ============================================================================ +log_info "" +log_info "=== Pattern 5: Microservices Architecture ===" + +log_info "Specialized agents with specific responsibilities..." +openclaw agent --agent GenesisAgent --session-id $SESSION_ID \ + --message "SERVICE: Processing AI job queue with 5 concurrent jobs" \ + --thinking medium + +openclaw agent --agent AIResourceAgent --session-id $SESSION_ID \ + --message "SERVICE: Allocating GPU resources with 85% utilization target" \ + --thinking medium + +openclaw agent --agent FollowerAgent --session-id $SESSION_ID \ + --message "SERVICE: Monitoring system health with 99.9% uptime target" \ + --thinking low + +openclaw agent --agent MultiModalAgent --session-id $SESSION_ID \ + --message "SERVICE: Analyzing performance metrics and optimization opportunities" \ + --thinking medium + +sleep 2 + +log_info "Service orchestration..." +openclaw agent --agent CoordinatorAgent --session-id $SESSION_ID \ + --message "ORCHESTRATION: Coordinating 4 microservices for optimal system performance" \ + --thinking high + +log_success "Microservices architecture demonstrated" + +# ============================================================================ +# Pattern 6: Load Balancing +# ============================================================================ +log_info "" +log_info "=== Pattern 6: Load Balancing Architecture ===" + +log_info "Coordinator monitors agent loads..." +openclaw agent --agent CoordinatorAgent --session-id $SESSION_ID \ + --message "LOAD BALANCE: Monitoring agent loads and redistributing tasks" \ + --thinking high + +sleep 2 + +log_info "Agents report current load..." +openclaw agent --agent GenesisAgent --session-id $SESSION_ID \ + --message "LOAD REPORT: Current load 75% - capacity for 5 more AI jobs" \ + --thinking low + +openclaw agent --agent FollowerAgent --session-id $SESSION_ID \ + --message "LOAD REPORT: Current load 45% - capacity for 10 more tasks" \ + --thinking low + +openclaw agent --agent AIResourceAgent --session-id $SESSION_ID \ + --message "LOAD REPORT: Current load 60% - capacity for resource optimization tasks" \ + --thinking low + +sleep 2 + +log_info "Coordinator redistributes load..." +openclaw agent --agent CoordinatorAgent --session-id $SESSION_ID \ + --message "REDISTRIBUTION: Routing new tasks to FollowerAgent (45% load) for optimal balance" \ + --thinking high + +log_success "Load balancing architecture demonstrated" + +# ============================================================================ +# Pattern 7: Multi-Agent Task Orchestration +# ============================================================================ +log_info "" +log_info "=== Pattern 7: Multi-Agent Task Orchestration ===" + +log_info "Step 1: Task decomposition..." +openclaw agent --agent CoordinatorAgent --session-id $SESSION_ID \ + --message "ORCHESTRATION: Decomposing complex AI pipeline into 5 subtasks for agent allocation" \ + --thinking high + +sleep 2 + +log_info "Step 2: Task assignment..." +openclaw agent --agent CoordinatorAgent --session-id $SESSION_ID \ + --message "ASSIGNMENT: Task 1->GenesisAgent, Task 2->MultiModalAgent, Task 3->AIResourceAgent, Task 4->FollowerAgent, Task 5->CoordinatorAgent" \ + --thinking high + +sleep 2 + +log_info "Step 3: Parallel execution..." +openclaw agent --agent GenesisAgent --session-id $SESSION_ID \ + --message "EXECUTION: Starting assigned task with parallel processing" \ + --thinking medium + +openclaw agent --agent MultiModalAgent --session-id $SESSION_ID \ + --message "EXECUTION: Starting assigned task with parallel processing" \ + --thinking medium + +openclaw agent --agent AIResourceAgent --session-id $SESSION_ID \ + --message "EXECUTION: Starting assigned task with parallel processing" \ + --thinking medium + +openclaw agent --agent FollowerAgent --session-id $SESSION_ID \ + --message "EXECUTION: Starting assigned task with parallel processing" \ + --thinking medium + +sleep 2 + +log_info "Step 4: Result aggregation..." +openclaw agent --agent CoordinatorAgent --session-id $SESSION_ID \ + --message "AGGREGATION: Collecting results from all agents for final synthesis" \ + --thinking high + +log_success "Multi-agent task orchestration demonstrated" + +# ============================================================================ +# Performance Metrics +# ============================================================================ +log_info "" +log_info "=== Performance Metrics ===" + +log_info "Measuring communication latency..." +start_time=$(date +%s.%N) +openclaw agent --agent GenesisAgent --session-id $SESSION_ID \ + --message "LATENCY TEST: Measuring communication performance" \ + --thinking low +end_time=$(date +%s.%N) +latency=$(echo "$end_time - $start_time" | bc) +log_info "Message latency: ${latency}s" + +log_success "Performance metrics collected" + +# ============================================================================ +# Summary +# ============================================================================ +log_info "" +log_info "=== Demo Summary ===" +log_success "All coordination patterns demonstrated successfully:" +log_success " 1. Hierarchical Communication" +log_success " 2. Peer-to-Peer Communication" +log_success " 3. Consensus-Based Decision Making" +log_success " 4. Weighted Decision Making" +log_success " 5. Microservices Architecture" +log_success " 6. Load Balancing Architecture" +log_success " 7. Multi-Agent Task Orchestration" +log_success " 8. Performance Metrics" +log_info "" +log_info "Session ID: $SESSION_ID" +log_info "For detailed patterns and implementation guidelines, see:" +log_info " .windsurf/workflows/agent-coordination-enhancement.md" +log_info " .windsurf/workflows/OPENCLAW_MASTER_INDEX.md"