Built for realistic developer debugging workflows using hybrid retrieval + intelligent routing.
Focus areas:
Hybrid Retrieval โข Agentic Routing โข Grounded Debugging โข RAG Systems โข Semantic Search
StackFix is a hybrid AI debugging agent that combines local retrieval, reranking, intelligent routing, and live internet reasoning to solve real-world software engineering issues with grounded and source-aware responses.
Instead of relying entirely on live web search or raw LLM generation, StackFix intelligently decides whether a query can be solved using a locally indexed StackOverflow-style knowledge base or whether it should switch to live internet reasoning for newer ecosystem issues.
The system combines:
- Semantic Retrieval (FAISS)
- BM25 Lexical Search
- Cross-Encoder Reranking
- Query Refinement Agent
- Confidence & Routing Agents
- Live Internet Fallback
- Source-Aware Response Generation
to provide grounded, practical, and developer-focused debugging assistance.
- ๐ Overview
- โก Quick Start
- ๐ก Why StackFix?
- โจ Features
- ๐ค Agentic Pipeline
- ๐ป System Requirements
- ๐ Performance Characteristics
- ๐๏ธ Architecture
- ๐ Flowchart
- ๐ Retrieval Pipeline
- ๐ Retrieval Quality Snapshot
- ๐ Repository Structure
- ๐ฅ Demo Videos
- ๐ฅ๏ธ UI Walkthrough
- โก Preloading Models
- โ๏ธ Configuration Guide
- ๐งฎ Offload Mode
- ๐ SSL Verification Toggle
- ๐ Dataset
- ๐ค Prebuilt Retrieval Indexes and Full Dataset
- โก Performance Notes
- ๐ท๏ธ Source Attribution
- ๐งช Example Queries
- ๐งฐ Tech Stack
โถ๏ธ Running Locally- ๐ง Key Insights
- โ๏ธ Limitations
- ๐ฎ Future Work
- ๐ค Contributing
- ๐ License
- โญ Support the Project
- ๐ Acknowledgements
Modern debugging assistants often struggle with:
- hallucinated fixes
- outdated package information
- slow web reasoning
- lack of source grounding
- noisy retrieval results
StackFix addresses this by introducing a hybrid multi-agent debugging pipeline.
The system first attempts to solve queries using local retrieval over a curated debugging knowledge base. If retrieval confidence is insufficient, StackFix dynamically switches to live internet reasoning.
This enables:
- โก fast responses for known issues
- ๐ internet fallback for emerging ecosystem problems
- ๐ฏ grounded retrieval-based debugging
- ๐ง intelligent query routing
- ๐ source-aware answers
StackFix is designed around realistic debugging workflows:
- traceback-heavy issues
- dependency conflicts
- framework migration errors
- CUDA/runtime failures
- evolving package ecosystems
- developer search behavior
git clone https://github.com/Korunil/stackfix.git
cd stackfix
pip install -r requirements.txtDownload FAISS + BM25 indexes from:
Place them inside:
./model_cache/
chainlit run app.pyMost AI debugging assistants rely entirely on:
- static retrieval
- pure LLM generation
- or expensive live web search
StackFix introduces an intelligent hybrid approach:
| Problem | StackFix Solution |
|---|---|
| Hallucinated fixes | Grounded retrieval |
| Slow web debugging | Fast local retrieval |
| Outdated package info | Internet fallback |
| Weak ranking quality | Cross-encoder reranking |
| Poor routing decisions | Confidence + Routing Agents |
The result is a debugging assistant that is:
- faster
- cheaper
- more grounded
- and more adaptive to modern software ecosystems.
Note: The reranker evaluates not only document content, but also titles, tags, and extracted code snippets to improve debugging relevance.
- ๐ Intelligent routing between LOCAL and INTERNET modes
- ๐ง Hybrid retrieval using FAISS + BM25
- ๐ฏ Cross-encoder reranking
- โก Fast local debugging
- ๐ Live internet fallback
- ๐ Intelligent GitHub + web retrieval fallback
- ๐ Source attribution
- ๐งฉ Query refinement pipeline
- ๐ฅ๏ธ Interactive Chainlit UI
- ๐ GPU acceleration support
- ๐งฎ Offload mode for lower VRAM systems
- ๐ง SSL verification toggle support
- ๐ฆ Prebuilt FAISS/BM25 index support
StackFix uses lightweight specialized agents internally to improve debugging quality. The agents are intentionally lightweight and modular, allowing StackFix to separate query understanding, confidence estimation, routing, and response generation into specialized responsibilities.
Expands and enriches debugging queries before retrieval.
Example:
Original Query:
ModuleNotFoundError: No module named 'langchain_huggingface'
Refined Query:
ModuleNotFoundError langchain_huggingface import issue package installation dependency fix
Benefits:
- better retrieval recall
- improved semantic matching
- stronger reranking quality
Calculates how confidently the local knowledge base can answer a query.
Used for:
- local retrieval confidence scoring
- routing decisions
- internet fallback triggering
Example:
Local Match: 0.96
Determines whether the query should use:
- LOCAL retrieval OR
- INTERNET reasoning
based on:
- retrieval quality
- rerank confidence
- semantic relevance
This prevents:
- unnecessary web search
- hallucinated local answers
- poor retrieval grounding
Example:
Route: LOCAL
Local Match: 0.96
or
Route: INTERNET
Local Match: 0.42
Recommended:
- Python 3.11
- CUDA-enabled GPU
- 32GB+ RAM
- 10GB+ free storage for indexes
โ ๏ธ Loading full retrieval indexes may require substantial RAM depending on FAISS configuration and BM25 size.
Minimum:
- CPU-only supported via OFFLOAD_MODE
- Lower RAM systems may experience slower retrieval/reranking
| Mode | Typical Latency |
|---|---|
| LOCAL Retrieval | Low latency |
| INTERNET Mode | Higher latency |
| Preloaded Models | Faster warm inference |
| Offload Mode | Reduced VRAM, slower responses |
Performance depends on:
- hardware
- GPU availability
- dataset size
- reranker configuration
StackFix intentionally separates retrieval confidence estimation from final response generation.
This allows routing decisions to remain lightweight, interpretable, and modular while preventing expensive internet reasoning for queries that can already be solved locally with high confidence.
Key architectural goals:
- minimize unnecessary internet reasoning
- improve debugging grounding quality
- balance semantic and lexical retrieval
- reduce hallucinated fixes
- optimize retrieval latency for known issues
flowchart TD
A[User Query]
--> B[Query Refinement Agent]
B --> C[Confidence + Routing Agents]
C -->|LOCAL| D[Hybrid Retriever]
D --> E[BM25 Retrieval]
D --> F[Vector Retrieval]
E --> G[Cross-Encoder Reranker]
F --> G
G --> H[Context Builder]
H --> I[LLM Generator]
C -->|INTERNET| J[Live Web Search]
J --> K[Web Context Builder]
K --> I
I --> L[Grounded Response + Sources]
- User submits debugging query
- Query Refinement Agent expands the query
- Confidence Agent estimates retrieval confidence
- Routing Agent selects LOCAL mode
- Hybrid retrieval fetches:
- semantic results (FAISS)
- lexical results (BM25)
- Results are deduplicated
- Cross-encoder reranks documents
- Top documents are converted into structured context
- LLM generates grounded debugging response
- Source attribution is attached
| Retrieval Strategy | Strength |
|---|---|
| FAISS Only | Strong semantic similarity matching |
| BM25 Only | Strong exact traceback and keyword matching |
| Hybrid Retrieval | Better overall debugging recall |
| Hybrid + Reranking | Highest contextual relevance and grounding quality |
This hybrid retrieval design helps StackFix balance:
- semantic understanding
- exact error matching
- contextual relevance
- grounded debugging responses
Activated when:
- local confidence is insufficient
- issue is too recent
- framework/library is evolving
- retrieval quality is weak
Pipeline:
- Query refinement
- Routing to internet mode
- Live web search
- Context extraction
- LLM reasoning
- Structured debugging response
When LOCAL retrieval confidence is low, StackFix performs structured external retrieval using:
- GitHub issue search
- trusted technical web sources
- signal-aware query construction
- heuristic scoring and ranking
The external retrieval pipeline prioritizes:
- framework/package relevance
- traceback overlap
- exact dependency matches
- trusted engineering domains
This helps improve:
- grounding quality
- debugging relevance
- retrieval precision
- modern ecosystem issue handling
stackfix/
โ
โโโ app.py
โโโ config.py
โโโ cache_store.py
โโโ preload.py
โโโ requirements.txt
โ
โโโ core/
โ โโโ citation_builder.py
โ โโโ query_parser.py
โ โโโ query_builder.py
โ โโโ query_expander.py
โ โโโ query_fallback.py
โ โโโ github_search.py
โ โโโ web_search.py
โ
โโโ agents/
โ โโโ refinement_agent.py
โ โโโ confidence_agent.py
โ โโโ routing_agent.py
โ
โโโ rag/
โ โโโ ingestion.py
โ โโโ embedding.py
โ โโโ vector_store.py
โ โโโ bm25_store.py
โ โโโ hybrid_retriever.py
โ โโโ reranker.py
โ
โโโ pipeline/
โ โโโ debug_pipeline.py
โ
โโโ prompts/
โ โโโ debug_prompt.py
โ โโโ fallback_prompt.py
โ โโโ system_prompt.py
โ โโโ system_prompt_detailed.py
โ
โโโ llm/
โ โโโ llm.py
โ โโโ generator.py
โ
โโโ memory/
โ โโโ memory.py
โ
โโโ model_cache/
โ โโโ faiss_index/
โ โโโ bm25_index.pkl
โ
โโโ datasets/
โ โโโ raw/
โ โ โโโ instructions.txt
โ โโโ processed/
โ โโโ sample_stackoverflow.jsonl
โ
โโโ scripts/
โ โโโ preprocess_dataset.py
โ โโโ generate_report.py
โ
โโโ assets/
โโโ public/
โ
โโโ LICENSE
โโโ chainlit_en-US.md
โโโ README.md
Edited showcase version with:
- annotations
- walkthrough
- transitions
- music
- faster pacing
๐น Watch Quick Demo
Complete unedited walkthrough showing:
- LOCAL retrieval
- INTERNET fallback
- CUDA OOM debugging
๐น Watch Full Demo
Known debugging issue solved using local retrieval pipeline.
Recent ecosystem issue automatically routed to internet reasoning.
GPU memory issue solved using intelligent fallback and debugging reasoning.
StackFix supports preloading:
- embedding models
- rerankers
- vector indexes
This significantly reduces runtime latency.
Example:
preload_retriever()Benefits:
- faster query responses
- avoids cold starts
- smoother demos
Main configurable parameters inside config.py:
| Parameter | Description |
|---|---|
K |
Initial retrieval count |
TOP_K |
Final reranked documents |
FETCH_K |
Documents fetched before reranking |
BATCH_SIZE |
Cross-encoder batch size |
BM25_WEIGHT |
Lexical retrieval weight |
VECTOR_WEIGHT |
Semantic retrieval weight |
ROUTING_THRESHOLD |
Local vs internet routing threshold |
DEVICE_RERANKER |
CPU/GPU reranker device |
OFFLOAD_MODE |
Enables low VRAM loading |
SSL_VERIFY |
Toggle SSL verification |
For lower VRAM systems:
OFFLOAD_MODE = TrueBenefits:
- reduced GPU memory usage
- CPU offloading support
- smaller GPU compatibility
Tradeoff:
- slower inference
Useful for restricted enterprise/corporate environments.
SSL_VERIFY = FalseStackFix uses the public StackSample dataset from Kaggle containing:
- programming questions
- accepted answers
- code snippets
- tags
- metadata
Included:
- lightweight sample dataset
Excluded:
- full production-scale dataset due to repository size constraints
- Total Documents:
1,102,568Q&A Pairs - Quality Threshold: Only the highest-scored answer per question was retained.
- Global Average SO Score:
3.31 - Top 10 Tags/Languages:
javascript,java,c#,php,android,jquery,python,html,c++,ios
- Model:
BAAI/bge-base-en-v1.5 - Dimensions: 768
- Normalization: True (Cosine Similarity optimized)
- Context Strategy: Questions, answers, and code blocks are merged into a single text block (
retrieval_text).
- Download the Kaggle StackSample dataset from link:Kaggle StackSample Dataset.
- Place the csv files inside your
./datasets/raw/directory. - Run
./scripts/preprocess_dataset.pyto start generation ofstackoverflow.jsonl. chainlit run app.py. The system will automatically detect the files.
To avoid regenerating embeddings and indexes locally, StackFix provides prebuilt retrieval artifacts hosted on Hugging Face.
Due to GitHub file size limitations, the full StackFix retrieval artifacts are hosted on Hugging Face.
Hugging Face Repository:
Included:
- FAISS vector indexes
- BM25 retrieval index
- Processed StackOverflow retrieval dataset
These prebuilt indexes allow StackFix to start instantly without requiring multi-hour embedding generation.
| File | Description |
|---|---|
faiss_index/ |
Prebuilt FAISS vector indexes |
bm25_index.pkl |
Serialized BM25 retrieval index |
stackoverflow.jsonl |
Processed retrieval dataset |
Place the downloaded files inside:
./model_cache/Then launch StackFix normally:
chainlit run app.pyThe system will automatically detect and load the indexes.
- Prebuilt FAISS and BM25 indexes dramatically reduce startup time.
- Initial indexing over 1M+ StackOverflow entries can take significant time and storage.
- GPU acceleration is recommended for embedding generation and reranking.
- Offload mode enables operation on lower VRAM systems.
Responses include source grounding and attribution.
Example:
๐ Sources:
[1] TypeError: Can't convert 'int' object to str implicitly
Benefits:
- transparency
- trustworthiness
- grounded debugging
I am getting TypeError: can only concatenate str (not "int") to str when trying to print a user's age with a string. How do I fix this?
I just upgraded my pipeline and I am getting ModuleNotFoundError: No module named 'langchain_huggingface'. How do I fix this?
I am getting RuntimeError: CUDA out of memory while training my PyTorch model. How do I reduce GPU memory usage?
| Component | Technology |
|---|---|
| UI | Chainlit |
| Framework | LangChain |
| Vector Search | FAISS |
| Lexical Search | BM25 |
| Reranking | SentenceTransformers |
| Embeddings | HuggingFace |
| Language | Python |
| Inference | PyTorch |
git clone https://github.com/Korunil/stackfix.git
cd stackfixpip install -r requirements.txtDownload prebuilt FAISS + BM25 indexes from:
Place the downloaded files inside:
./model_cache/Structure example:
model_cache/
โโโ faiss_index/
โโโ bm25_index.pkl
This avoids regenerating embeddings locally and dramatically reduces setup time.
If you want to build the indexes yourself:
Download from:
Move the downloaded CSV files into:
./datasets/raw/
python ./scripts/preprocess_dataset.pychainlit run app.pyThe system will automatically:
- generate embeddings
- build FAISS indexes
- build BM25 indexes
- cache retrieval artifacts
Semantic search alone may:
- miss exact error strings
- struggle with tracebacks
BM25 alone may:
- miss conceptual similarity
Combining both improves:
- recall
- robustness
- debugging quality
Initial retrieval often contains noisy candidates.
Cross-encoder reranking significantly improves:
- contextual relevance
- grounding quality
- response precision
Not every debugging problem should use live internet reasoning.
Local retrieval provides:
- speed
- determinism
- reduced hallucination risk
Internet fallback handles:
- evolving frameworks
- recent package changes
- new ecosystem issues
- Internet mode depends on external web quality
- Retrieval quality depends on dataset coverage
- Very recent ecosystem issues may lack grounding
- Large-scale indexing requires significant storage
- Some fixes may still require manual verification
- VSCode extension
- Docker deployment
- Better traceback parsing
- Multi-hop debugging
- Dependency conflict detection
- Agentic debugging workflows
- Query expansion improvements
Contributions, ideas, and feedback are welcome!
Suggested areas:
- retrieval improvements
- reranking optimization
- dataset quality
- UI enhancements
- evaluation benchmarks
- routing logic
Licensed under the Apache 2.0 License.
If you found this project useful:
- Star the repository
- Open issues
- Suggest improvements
- Share feedback
https://github.com/Korunil/stackfix.git
Built using open-source tooling from:
- LangChain
- Chainlit
- FAISS
- Sentence Transformers
- Hugging Face
- PyTorch




