feat(ask): add LLM-based routing classification#4
Open
rafeegnash wants to merge 4 commits intocf-agentfrom
Open
feat(ask): add LLM-based routing classification#4rafeegnash wants to merge 4 commits intocf-agentfrom
rafeegnash wants to merge 4 commits intocf-agentfrom
Conversation
added 4 commits
January 26, 2026 21:50
Replace keyword-based routing with LLM classification for ambiguous queries. The LLM analyzes query context to determine which service (AWS, Cloudflare, K8s, GCP) the user is asking about. This prevents generic terms like "cache", "cdn", "worker" from incorrectly routing to Cloudflare when the user means AWS. LLM classification is triggered when: - Multiple services are detected by keyword matching - Cloudflare keywords are detected (to verify intent) Fallback: If LLM classification fails, keyword-based inference is used. Explicit flags (--cloudflare, --aws, --k8s) bypass LLM classification.
Add tests to verify: - Cloudflare only triggers on explicit mentions (cloudflare, wrangler, cloudflared) - Generic terms (cache, cdn, worker, waf, rate limit) do not trigger Cloudflare - AWS routing works for ec2, lambda, dns - K8s routing works for pods, kubernetes, kubectl
Move query routing classification logic from cmd/ask.go to internal/routing package for better testability and code organization. Changes: - Create internal/routing/routing.go with InferContext, ClassifyWithLLM, NeedsLLMClassification, ApplyLLMClassification, GetClassificationPrompt - Create internal/routing/routing_test.go with comprehensive tests - Update cmd/ask.go to use the routing package - Remove duplicate inferContext, classifyQueryWithLLM, and contains functions - Delete cmd/ask_routing_test.go (tests moved to internal/routing)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
getRoutingClassificationPrompt()function for LLM routing promptclassifyQueryWithLLM()function for LLM-based service classificationcloudflareKeywordsto prevent false positivesTest plan
make build)make test-short)