š§ Intelligent Routing
/docs/development-tools/intelligent-routing
The Route system uses Q-Learning to automatically assign tasks to the best agent based on learned performance patterns.
How Routing Works
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā INTELLIGENT ROUTING ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā⤠ā ā ā Task: "Fix authentication bug" ā ā ā ā ā ā¼ ā ā āāāāāāāāāāāāāāāāāāā ā ā ā Analyze Task ā ā Complexity, domain, keywords ā ā āāāāāāāāāā¬āāāāāāāāā ā ā ā ā ā ā¼ ā ā āāāāāāāāāāāāāāāāāāā ā ā ā Q-Learning ā ā Historical success rates per agent ā ā ā Lookup ā ā ā āāāāāāāāāā¬āāāāāāāāā ā ā ā ā ā ā¼ ā ā āāāāāāāāāāāāāāāāāāā ā ā ā Recommend: ā ā ā ā security-arch ā ā 94% confidence (auth domain expert) ā ā āāāāāāāāāāāāāāāāāāā ā ā ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Route Commands
| Command | What It Does | Example |
|---|---|---|
route task | Get agent recommendation | npx ruflo@latest route task "implement OAuth2" |
route explain | Understand routing decision | npx ruflo@latest route explain "task" |
route coverage | Route based on test coverage | npx ruflo@latest route coverage |
Example: Route a Task
bashnpx ruflo@latest route task "refactor authentication to use JWT" # Output: # āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā # ā ROUTING RECOMMENDATION ā # ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā⣠# ā Task: "refactor authentication to use JWT" ā # ā ā # ā Recommended Agent: security-architect ā # ā Confidence: 94% ā # ā ā # ā Why this agent? ā # ā ⢠Domain match: authentication, security ā # ā ⢠Historical success: 12/13 similar tasks (92%) ā # ā ⢠Expertise: JWT, OAuth, session management ā # ā ā # ā Alternative agents: ā # ā ⢠coder (78% confidence) - general implementation ā # ā ⢠backend-dev (71% confidence) - API expertise ā # āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Coverage-Aware Routing
Routes tasks to agents based on test coverage gaps:
bashnpx ruflo@latest route coverage # Finds untested code and routes to tester agent: # ⢠src/auth/jwt.ts - 23% coverage ā tester # ⢠src/api/users.ts - 45% coverage ā tester # ⢠src/utils/crypto.ts - 0% coverage ā security-architect + tester
Routing Hooks
bash# Route via hooks (preferred) npx ruflo@latest hooks route "implement caching layer" --include-explanation # Record outcome for learning npx ruflo@latest hooks post-task --task-id "task-123" --success true --agent coder
How Q-Learning Improves Over Time
| Iteration | Action | Result |
|---|---|---|
| 1 | Route "auth task" ā coder | ā Failed (missing security context) |
| 2 | Route "auth task" ā security-architect | ā Success |
| 3 | Route "auth task" ā security-architect | ā Success |
| N | Route "auth task" ā security-architect | 94% confidence (learned) |
The system remembers what works and applies it to future similar tasks.