feat: add adaptive RAG prefetching#3167
Open
teerthsharma wants to merge 1 commit into
Open
Conversation
Signed-off-by: Teerth Sharma <teerths57@gmail.com>
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.
Closes #3164
How this solves the issue
Issue #3164 proposed an adaptive RAG prefetcher that borrows the useful ideas from Aether-Lang, without importing Aether itself: topology metadata, adaptive drift detection, and conservative pre-warming for likely follow-up retrievals.
This PR implements that proposal in docker-agent's existing RAG architecture:
results.prefetchconfiguration block so existing RAG behavior is unchanged by default.pkg/rag/prefetch, a bounded in-memory prefetch layer that tracks normalized query shape, result count, average similarity, and centroid drift.pkg/rag/manager.go, preserving the existing strategy, fusion, reranking, limit, full-content, and deduplication order.Issue acceptance criteria coverage
results.prefetch.enableddefaults tofalse.Manager.Querynow checks the exact-query cache, stores final successful results, observes topology, and schedules background prefetches after cache misses.examples/rag/adaptive_prefetch.yamlshow the new config.Validation
go test ./pkg/rag/prefetchgo test ./pkg/rag -run TestQueryUsesPrefetchCacheForRepeatedQuerygo test ./pkg/config -run "TestJsonSchemaWorksForExamples|TestSchemaMatchesGoTypes"go run ./lint .go mod tidy --diffgo build -v -o .\bin\docker-agent.exe .\main.goLocal note:
taskandgolangci-lintare not installed in this Windows environment, sotask lint,task test, andtask buildcould not run directly. Package-widego test ./...on Windows still hits existing path/default-agent environment-sensitive tests unrelated to this branch.