LLM & RAG · 2026
ASTGraph-Gemma: Budgeted Code Maps for Local Agents
A tree-sitter-powered Python repository map that ranks compact symbol signatures against an issue and packs them into a hard token budget for local Gemma 4 agents. On 150 SWE-bench Lite issues, the signature-only map reached 0.527 file Acc@1 at 2,048 tokens.
Architecture
- Python repository
- AST symbol extraction
- Issue-aware ranking
- Budgeted map
- Local coding agent
Model
- Gemma 4 E4B Instruct (google/gemma-4-E4B-it), 4-bit NF4 with fp16 compute on one NVIDIA T4
- Default map: symbol signatures ranked with a hybrid BM25M + personalized PageRank score
- Optional tools: repo_map, find_symbol, read_symbol, callers, callees and outline; tool use was unit-tested but not benchmarked with Gemma 4
Dataset
SWE-bench Lite: 150 held-out test issues across 12 repositories after a separate 60-instance development split. File Acc@1/3 uses all 150 issues; function Acc@1 uses the 119 issues with touched lines inside a function or class.
Results & metrics
- File Acc@1 · 2,048-token budget
- 0.527 (95% CI 0.447–0.607; n=150)
- File Acc@3 · 2,048-token budget
- 0.647
- Function Acc@1
- 0.235 (n=119)
- File Acc@1 vs snippet RAG
- +0.147 (95% CI 0.060–0.233; pHolm=0.004)
- Edges + control-flow variant
- 0.487 File Acc@1 · 0.143 Function Acc@1
- 8k-token T4 prefill
- 15.4 s; prefill only, answer quality not tested
Deployment steps
- 1Install the local Python package with pip install -e .
- 2Run astgraph map <repo> --issue '<issue>' --budget 2048 to build a ranked, budgeted repository map
- 3Prepend RepoIndex.context(issue, budget).text to the issue prompt for the local model
- 4Optionally expose the repository index through its tool interface or MCP server; this path was not measured with Gemma 4
Tech stack
- Python
- Tree-sitter
- Gemma 4 E4B
- Transformers
- bitsandbytes
- MCP