Query routing
When you runclanker ask, your question goes through a routing system that determines which agent(s) should handle it:
Extract question
If the prompt contains chat history, extract the last user turn:
cmd/ask.go:1274-1318
Keyword inference
Check for explicit provider/service keywords:
- AWS:
ec2,lambda,s3,rds,cloudwatch,ecs,eks - GCP:
gcloud,compute engine,cloud run,bigquery - Azure:
azure,app service,cosmos db - Cloudflare:
cloudflare,workers,waf,dns - Kubernetes:
kubectl,pod,deployment,namespace - Terraform:
terraform,tfstate,workspace
LLM classification (if ambiguous)
If multiple services are detected or Cloudflare is mentioned, use an LLM to make the final routing decision.See
internal/routing/classifier.go for the classification prompt.Semantic intent analysis
For AWS queries, Clanker performs semantic analysis to understand what you’re trying to do without calling external APIs.Intent classification
The semantic analyzer scores your query against these intent types:| Intent | Example keywords | Use case |
|---|---|---|
troubleshoot | error, fail, broken, issue, problem | Debug failing services |
monitor | status, health, running, uptime | Check service health |
analyze | performance, slow, bottleneck, optimize | Performance investigation |
deploy | deploy, launch, create, provision | Infrastructure changes |
security | access, permission, vulnerability, exposed | Security audits |
cost | cost, billing, spend, expensive | Cost optimization |
Urgency detection
Keywords are weighted to determine urgency:| Urgency | Score threshold | Keywords |
|---|---|---|
| Critical | ≥ 1.0 | down, outage, emergency, critical |
| High | 0.7 - 0.99 | error, fail, broken, urgent |
| Medium | 0.3 - 0.69 | slow, issue, problem, warning |
| Low | < 0.3 | (default) |
Timeframe inference
Certain keywords map to investigation timeframes:- now / current →
recent(last 1 hour) - today →
today(last 24 hours) - yesterday →
yesterday - week →
week(last 7 days) - month →
month(last 30 days)
Service identification
The analyzer maintains a mapping of keywords to AWS services:lambda,function→lambdaec2,instance,server→ec2s3,bucket→s3rds,database,postgres,mysql→rdscloudwatch,logs,metrics→cloudwatch
Query examples
Here’s how different questions are interpreted:- Troubleshooting
- Monitoring
- Performance
- Security
Question: “Why is my Lambda function timing out?”Agents spawned: Log agent, Metrics agent, Infrastructure agent
Provider-specific routing
Cloudflare queries
Cloudflare questions are routed to specialized sub-agents:- WAF agent (
internal/cloudflare/waf/): Firewall rules, rate limiting, DDoS protection - Workers agent (
internal/cloudflare/workers/): Workers, KV, D1, R2, Durable Objects - Analytics agent (
internal/cloudflare/analytics/): Traffic, bandwidth, performance metrics - Zero Trust agent (
internal/cloudflare/zerotrust/): Tunnels, Access apps, policies - DNS agent (
internal/cloudflare/dns/): DNS records, zones
Kubernetes queries
K8s questions are detected by keywords likekubectl, pod, deployment, namespace:
internal/k8s/) handles cluster inspection, resource queries, and health checks.
IAM queries
IAM/security questions are routed to the IAM agent:internal/iam/) performs security analysis on roles, policies, and permissions.
Testing routing decisions
Use--route-only to see how your question would be routed without executing:
Next steps
AI agents
Learn about the multi-agent architecture
Maker mode
Generate infrastructure plans from natural language