You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Proposal: Implement intelligent context selection for improved code generation #668
Currently, Codex selects files for the AI context window based on directory traversal order without considering relevance to the user's query. This leads to suboptimal context utilization where irrelevant files may be included while critical files are excluded, reducing code generation quality.
Proposed Solution
Implement a lightweight, keyword-based relevance scoring system that:
Extracts meaningful keywords from the user's query
Scores files based on keyword matches, path relevance, and file characteristics
Prioritizes the most relevant files within the token budget
Implementation Details
Add a new file src/utils/singlepass/relevance_scoring.ts with the scoring logic
Design with a pluggable architecture to allow future enhancements
Integrate with minimal changes to the existing file selection process
Add basic telemetry to track which files were actually useful
Expected Benefits
30-50% improvement in context relevance
15-25% reduction in iterations needed to complete tasks
20-30% improvement in code quality
No new dependencies or major architectural changes
Future Enhancements
This implementation lays the groundwork for more sophisticated approaches in the future:
Dependency graph analysis to find related files
Usage history tracking to learn from past queries
Semantic embeddings for better relevance matching
Thank you for the suggestion, going to close this as we are not going down this route and instead are optimizing for simplicity and letting the model figure out itself how to manage its own context.
Activity
[-]Proposal: Implement Intelligent Context Selection for Improved Code Generation[/-][+]Proposal: Implement intelligent context selection for improved code generation[/+]demoncoder-crypto commentedon Apr 28, 2025
Please check the implementation in #708 if its up to expectation
tibo-openai commentedon Oct 18, 2025
Thank you for the suggestion, going to close this as we are not going down this route and instead are optimizing for simplicity and letting the model figure out itself how to manage its own context.