FastCode: Fast and Cost-Efficient Code Understanding and Reasoning
Organizations: The University of Hong Kong · Huawei Noah’s Ark Lab
Abstract
Repository-scale code reasoning is a cornerstone of modern AI-assisted software engineering, enabling Large Language Models (LLMs) to handle complex workflows from program comprehension to complex debugging. However, balancing accuracy with context cost remains a significant bottleneck, as existing agentic approaches often waste computational resources through inefficient, iterative full-text exploration. To address this, we introduce FastCode, a framework that decouples repository exploration from content consumption. FastCode utilizes a structural scouting mechanism to navigate a lightweight semantic-structural map of the codebase, allowing the system to trace dependencies and pinpoint relevant targets without the overhead of full-text ingestion. By leveraging structure-aware navigation tools regulated by a cost-aware policy, the framework constructs high-value contexts in a single, optimized step. Extensive evaluations on the SWE-QA, LongCodeQA, LOC-BENCH, and GitTaskBench benchmarks demonstrate that FastCode consistently outperforms state-of-the-art baselines in reasoning accuracy while significantly reducing token consumption, validating the efficiency of scouting-first strategies for large-scale code reasoning. Source code is available at https://github.com/HKUDS/FastCode.
Figures & tables
| Metric | Community Baselines | Commercial Tools | Ours | ||||||||
| Direct LLM | Func RAG | Sliding RAG | SWEQA-Agent | DeepWiki | CodeWiki | Gemini Code | Claude Code | Cursor | FastCode | ||
| Correctness | 7.36 | 7.96 | 8.06 | 8.36 | 8.02 | 7.89 | 8.03 | 8.31 | 8.30 | 8.44 | |
| Completeness | 3.71 | 5.75 | 5.99 | 6.94 | 5.90 | 6.49 | 6.09 | 7.25 | 8.13 | 7.94 | |
| Clarity | 7.38 | 8.97 | 9.01 | 9.10 | 8.73 | 8.75 | 8.97 | 8.76 | 8.71 | 8.84 | |
| Relevance | 8.94 | 9.56 | 9.65 | 9.72 | 9.36 | 9.21 | 9.68 | 9.56 | 9.39 | 9.35 | |
| Reasoning | 4.91 | 7.38 | 7.51 | 8.22 | 7.52 | 7.82 | 7.92 | 8.21 | 8.64 | 8.72 | |
| LongCodeQA | 32K | 64K | 128K | 256K | 512K | 1M |
| Jamba 1.5 - 400B Large | 69.0 | 69.7 | 72.8 | 54.2 | - | - |
| Llama 3.1 - 405B Ins. | 69.9 | 72.4 | 67.4 | - | - | - |
| Llama 4 Scout | 66.4 | 73.7 | 70.7 | 63.1 | 78.7 | 76.0 |
| GPT-4o | 65.5 | 76.3 | 74.3 | - | - | - |
| GPT-4.1 | 72.6 | 73.7 | 78.3 | 72.3 | 78.7 | 80.0 |
| Qwen2.5-14B Ins. | 61.9 | 65.8 | 68.5 | 63.1 | 70.2 | 40.0 |
Appendix figures & tables9 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | Provider | Price ($ / 1M) | |
| Input | Output | ||
| Gemini-3-Flash | Poe | 0.40 | 2.40 |
| Gemini-2.5-Pro | Poe | 0.87 | 7.00 |
| Claude 3.5 Sonnet | Poe | 2.60 | 13.00 |
| Claude 3.7 Sonnet | Poe | 2.60 | 13.00 |
| Qwen3-Coder-30B | OpenRouter | 0.07 | 0.27 |
| Method | Total Score | Cost |
| Claude Code | 42.08 | 0.057 |
| Cursor | 43.17 | 0.071 |
| FastCode | 43.28 | 0.032 |
| Improvement over Claude Code | +2.85% | -43.86% |
| Context Length | Accuracy (%) | Cost | Acc. Gain | ||
| Direct | +FastCode | Direct | +FastCode | ||
| 32K | 65.5 | 69.9 | 0.083 | 0.041 | +6.72% |
| 64K | 69.7 | 69.7 | 0.166 | 0.045 | +0.00% |
| 128K | 71.7 | 72.83 | 0.333 | 0.069 | +1.58% |
| 256K | 66.6 | 78.5 | 0.666 | 0.057 | +17.87% |
| 512K | - | 76.6 | 1.331 | 0.075 | - |
| Method | Acc@1 (%) | Acc@3 (%) | Acc@5 (%) | Cost |
| Existing Tools (Claude 3.5 Sonnet) | ||||
| MoatlessTools | 72.63 | 85.77 | 86.13 | 0.46 |
| SWE-agent | 77.37 | 87.23 | 90.15 | 0.67 |
| Openhands | 76.28 | 89.78 | 90.15 | 0.79 |
| LocAgent | 77.74 | 91.97 | 94.16 | 0.66 |
| LocAgent (Fine-tuned Qwen) | ||||
| Method | ECR (%) | TPR (%) | Cost | Cost Ratio |
| Aider (Claude 3.5) | 16.67 | 12.96 | 0.0304 | 1.00 |
| SWE-Agent (Claude 3.5) | 41.67 | 22.23 | 1.38 | 45.39 |
| SWE-Agent (Claude 3.7) | 64.81 | 42.59 | 1.67 | 54.93 |
| OpenHands (Claude 3.5) | 53.70 | 40.74 | 8.95 | 294.41 |
| OpenHands (Claude 3.7) | 72.22 | 48.15 | 29.8 | 980.26 |
| FastCode (Claude 3.5) | 61.11 | 46.30 | 0.0878 | 2.89 |
| Base Model | Direct LLM | SWEQA-Agent | FastCode |
| Ministral-3b | 27.39 | 33.45 | 36.13 |
| Deepseek-r1-8b | 30.11 | 34.46 | 38.56 |
| Qwen3-Coder-30b-A3b | 35.77 | 37.08 | 41.44 |
| Gemini-3-Flash | 32.65 | 42.47 | 43.44 |
| Repository | DeepSeek-R1-8B | Gemini-3-Flash | Ministral-3B | Qwen3-Coder-30B |
| astropy | 27.58 | 32.42 | 25.60 | 34.08 |
| sphinx | 28.54 | 32.67 | 24.60 | 34.44 |
| matplotlib | 31.52 | 33.88 | 28.38 | 37.48 |
| pylint | 28.46 | 32.79 | 27.33 | 35.56 |
| flask | 33.46 | 32.12 | 27.81 | 36.42 |
| pytest | 28.54 | 32.50 | 26.75 | 35.46 |
| Repository | DeepSeek-R1-8B | Gemini-3-Flash | Ministral-3B | Qwen3-Coder-30B |
| astropy | 31.44 | 41.32 | 35.15 | 36.21 |
| sphinx | 32.71 | 42.08 | 29.35 | 38.40 |
| matplotlib | 35.12 | 43.48 | 33.75 | 37.67 |
| pylint | 34.29 | 42.60 | 34.85 | 37.12 |
| flask | 35.71 | 42.15 | 38.67 | 37.60 |
| pytest | 33.25 | 42.92 | 27.44 | 39.77 |
| Repository | DeepSeek-R1-8B | Gemini-3-Flash | Ministral-3-3B | Qwen3-Coder-30B |
| astropy | 36.40 | 41.58 | 33.88 | 40.33 |
| sphinx | 37.81 | 44.10 | 35.96 | 41.75 |
| matplotlib | 40.56 | 43.44 | 38.73 | 41.79 |
| pylint | 37.98 | 43.42 | 34.06 | 40.65 |
| flask | 40.27 | 44.98 | 38.12 | 43.19 |
| pytest | 38.65 | 44.12 | 35.00 | 41.96 |
Efficient Language Model Reasoning
Efficient language model reasoning studies how to improve problem-solving accuracy while reducing inference, memory, latency, and training costs.
See all 370 papers