An intelligent verification cluster router that routes verification jobs to specialized sub-agents based on job requirements and agent capabilities.
WachAI-Router is the main orchestration agent for the Verification Cluster in the WachAI ecosystem. It acts as a smart router that receives verification job requests through the ACP (Agent Communication Protocol) and intelligently routes them to specialized sub-agents within its cluster. The router selects agents that deliver the highest quality for each specific job type and match the job criteria.
- Intelligent Job Classification: verification categories help determine the appropriate service type
- Automatic Routing: Routes jobs to specialized sub-agents based on service requirements
- Job State Management: Tracks job progress through all phases using Redis persistence
- Dual Role Operation: Functions as both provider (receiving jobs) and consumer (routing to sub-agents)
- High Performance: Parallel job processing with optimized agent caching
┌─────────────────┐
│ Client Job │
│ Request │
└────────┬────────┘
│
v
┌─────────────────────────┐
│ WachAI-Router Agent │
│ (Verification Cluster │
│ Main Agent) │
└──────────┬──────────────┘
│
│
│
├─── Job Routing
│
v
┌──────┴──────┐
│ │
v v
┌─────────┐ ┌──────────────┐
│ Sentry │ │ TokenSense │
│ Agent │ │ Agent │
│ (Audit) │ │ (Verify) │
└─────────┘ └──────────────┘
WachAI router can support multiple sub agents for each job category. Currently, the router manages connections to the following specialized agents:
- Sentry:wachAI - Smart contract verification
- TokenSense:wachAI - Token verification
- Job Reception: Router receives a job request via ACP with service requirements
- Classification: AI analyzes the request and classifies it.
- Routing: Job is routed to the appropriate sub-agent in the cluster
- Tracking: Router tracks both the original job and routed job through all phases
- Delivery: Once sub-agent completes work, router delivers results back to original client
The router handles jobs through all ACP phases:
| Phase | Router as Provider | Router as Consumer |
|---|---|---|
| REQUEST | Classify job & route to sub-agent | - |
| NEGOTIATION | - | Accept job on behalf of cluster |
| TRANSACTION | Pay sub-agent & wait for completion | - |
| EVALUATION | - | Forward deliverable to client |
| COMPLETED | Deliver results to client | Evaluate sub-agent work |
- Language: TypeScript
- ACP Protocol:
@virtuals-protocol/acp-nodefor agent communication - AI Classification: OpenAI GPT-4 for intelligent job routing
- State Management: Redis (ioredis) for job tracking and persistence
- Runtime: Node.js
# Clone the repository
git clone <repository-url>
cd WachAI-Router
# Install dependencies
npm install
# Build the project
npm run buildCreate a .env file in the root directory with the following variables:
# Agent Configuration
PRIVATE_KEY=your_private_key_without_0x_prefix
ENTITY_ID=your_entity_id
AGENT_WALLET_ADDRESS=0xyour_agent_wallet_address
# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key
# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
# Polling Configuration
POLLING_INTERVAL=60000 # milliseconds (default: 60 seconds)npm run devRuns the agent in development mode with auto-restart on file changes.
# Build the project
npm run build
# Start the agent
npm start# Run all tests
npm test
# Run specific tests
npm run test:acp # ACP integration tests
npm run test:acp-buyer # Buyer role tests
npm run test:hybrid # Hybrid agent tests{
original_job_id: number;
routed_job_id: number;
routed_to_agent: string;
target_agent_name: string;
target_agent_address: string;
job_phase: "ROUTED" | "ACCEPTED" | "PAID" | "COMPLETED" | "REJECTED";
responded_to_request: boolean;
delivered_work: boolean;
}Classifies job requests using AI.
Returns:
{
offering: "verify_contract" | "audit_contract" | null,
message: string
}Handles job classification and routing in the REQUEST phase.
Accepts jobs on behalf of the verification cluster.
Manages payment to sub-agents and monitors completion.
Forwards deliverables and evaluates sub-agent work.
- Agent Caching: Sub-agents are cached on initialization to avoid repeated lookups
- Parallel Processing: Multiple active jobs are processed concurrently
- Redis Persistence: Job mappings survive restarts
- Error Recovery: Automatic restart with 30-second delay on critical failures
The router includes comprehensive error handling:
- Invalid Jobs: Jobs without service requirements are logged and skipped
- Missing Agents: Jobs are rejected if target sub-agent is unavailable
- Routing Failures: Failed routing attempts are logged and job is rejected
- Connection Issues: Auto-restart mechanism for critical failures
The router provides detailed console logging for:
- Job reception and classification
- Routing decisions and target agents
- Phase transitions
- Payment processing
- Deliverable forwarding
- Error conditions
WachAI-Router/
├── src/
│ ├── agent.ts # Main agent logic
│ └── helpers/
│ ├── agent.ts # AI classification
│ └── redis.ts # State management
├── test/
│ ├── router-agent.test.ts # Router functionality tests
│ ├── acp.test.ts # ACP integration tests
│ └── hybrid-agent.test.ts # Hybrid mode tests
├── dist/ # Compiled JavaScript
├── package.json
├── tsconfig.json
└── .env
# Clean build artifacts
npm run clean
# Compile TypeScript
npm run build
# Output in dist/ directoryWhen contributing to WachAI-Router:
- Maintain TypeScript strict mode compliance
- Add tests for new routing logic
- Update Redis schema documentation for new state fields
- Follow existing error handling patterns
- Add console logging for debugging
ISC
QuillAI-Network
For issues, questions, or contributions, please refer to the project's issue tracker or contact the QuillAI-Network team.
- Dynamic sub-agent discovery
- Quality-based agent selection
- Multi-agent consensus routing
- Advanced job prioritization
- Performance metrics and analytics
- WebSocket-based real-time updates