{"id":51040059,"url":"https://github.com/microsoft/fastcontext","last_synced_at":"2026-06-22T11:05:22.280Z","repository":{"id":366535313,"uuid":"1256787497","full_name":"microsoft/fastcontext","owner":"microsoft","description":"FastContext: Training Efficient Repository Explorer for Coding Agents","archived":false,"fork":false,"pushed_at":"2026-06-22T07:59:01.000Z","size":1289,"stargazers_count":777,"open_issues_count":11,"forks_count":46,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-06-22T09:31:55.218Z","etag":null,"topics":["code-explorer","sub-agent"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-02T05:01:11.000Z","updated_at":"2026-06-22T09:19:40.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/microsoft/fastcontext","commit_stats":null,"previous_names":["microsoft/fastcontext"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/microsoft/fastcontext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Ffastcontext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Ffastcontext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Ffastcontext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Ffastcontext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/fastcontext/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Ffastcontext/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34645750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-explorer","sub-agent"],"created_at":"2026-06-22T10:00:28.885Z","updated_at":"2026-06-22T11:05:22.268Z","avatar_url":"https://github.com/microsoft.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# FastContext: Training Efficient Repository Explorer for Coding Agents\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://arxiv.org/abs/2606.14066\"\u003e\u003cimg src=\"https://img.shields.io/badge/arXiv-2606.14066-b31b1b.svg\" alt=\"arXiv\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/microsoft/fastcontext\"\u003e\u003cimg src=\"https://img.shields.io/badge/Code-GitHub-181717.svg\" alt=\"Code\"\u003e\u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Python-3.12%2B-blue.svg\" alt=\"Python 3.12+\"\u003e\n  \u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-MIT-green.svg\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#news\"\u003e📰 News\u003c/a\u003e |\n  \u003ca href=\"#overview\"\u003e🔎 Overview\u003c/a\u003e |\n  \u003ca href=\"#results\"\u003e📊 Results\u003c/a\u003e |\n  \u003ca href=\"#quick-start\"\u003e⚡ Quick Start\u003c/a\u003e |\n  \u003ca href=\"#reproduction\"\u003e🧪 Reproduction\u003c/a\u003e |\n  \u003ca href=\"#citation\"\u003e📚 Citation\u003c/a\u003e\n\u003c/p\u003e\n\nFastContext is a lightweight repository-exploration subagent for coding agents. Instead of letting the main\ncoding agent spend its own context window on broad file reads and code searches, the main agent delegates\na natural-language context query to FastContext. FastContext explores the repository with read-only tools,\nissues independent tool calls in parallel, and returns compact file-line citations as focused evidence for the\nmain agent.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"figures/overview.png\" alt=\"FastContext overview\" width=\"95%\"\u003e\n\u003c/p\u003e\n\n## News\n\n- 🚀 **2026-06-15**: We released the arXiv paper [[📄 arXiv](https://arxiv.org/abs/2606.14066)] and the model weights [[🤗 Model](https://huggingface.co/collections/microsoft/swe-fastcontext)].\n\n\n## Overview\n\nModern coding agents often use the same model to explore a repository and solve the task. This makes\nexploration expensive: exploratory reads and searches consume tokens, stay in the solver's history, and can\npollute later reasoning with irrelevant snippets.\n\nFastContext separates repository exploration from solving:\n\n- 🧭 **Delegated exploration**: the main agent asks FastContext for repository context before editing or answering.\n- 🔒 **Read-only tools**: FastContext uses `Read`, `Glob`, and `Grep`; it does not modify files.\n- ⚙️ **Parallel tool calling**: independent reads and searches can be issued in the same exploration turn.\n- 📌 **Compact evidence**: the final response is a short `\u003cfinal_answer\u003e` block with file paths and line ranges.\n- 🧠 **Trainable explorers**: the paper trains 4B-30B exploration models with SFT and task-grounded RL.\n\nThe intended contract is simple: FastContext finds the relevant code; the main coding agent uses that focused\nevidence to edit, test, or answer.\n\n```text\n\u003cfinal_answer\u003e\n/path/to/repo/src/router.py:42-58\n/path/to/repo/tests/test_router.py:101-119\n\u003c/final_answer\u003e\n```\n\n## Results\n\nAcross SWE-bench Multilingual, SWE-bench Pro, and SWE-QA, FastContext improves the score-token tradeoff of\nMini-SWE-Agent style coding agents.\n\n| Result | Finding |\n| --- | --- |\n| 📈 End-to-end success | Up to **+5.5** score improvement with delegated repository exploration. |\n| 💸 Main-agent token use | Up to **60.3%** fewer main-agent tokens. |\n| 🧠 Compact trained explorer | FC-4B-RL improves or ties FC-4B-SFT across all reported end-to-end settings. |\n| 🎯 Standalone exploration | Trained FastContext models recover patch-relevant files and symbols more accurately than non-FastContext small-model baselines. |\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"figures/main-result.png\" alt=\"FastContext main results\" width=\"95%\"\u003e\n\u003c/p\u003e\n\n## Token Efficiency\n\nFastContext reduces the main agent's context burden by moving broad repository exploration outside the\nsolver trajectory. The reduction is especially visible in file-reading and code-search tokens.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"figures/breakdown.png\" alt=\"FastContext token breakdown\" width=\"95%\"\u003e\n\u003c/p\u003e\n\n## Installation\n\nFastContext requires Python 3.12 or newer. The repository uses [`uv`](https://docs.astral.sh/uv/) for package\nand environment management.\n\nInstall the CLI from the repository root:\n\n```bash\nuv tool install .\n```\n\nFor development:\n\n```bash\nuv sync --all-groups\n```\n\nBuild a local wheel:\n\n```bash\nuv build\n```\n\nThe built wheel is written under `dist/`, for example:\n\n```text\ndist/fastcontext-0.1.0-py3-none-any.whl\n```\n\n## Model Configuration\n\nFastContext expects an OpenAI-compatible chat completions endpoint. For direct CLI usage, configure:\n\n```bash\nexport BASE_URL=\"https://your-endpoint.example/v1\"\nexport MODEL=\"your-model-name\"\nexport API_KEY=\"your-api-key\"\n```\n\nBenchmark runners may also pass separate FastContext credentials through `FASTCONTEXT_*` variables in\n`benchmark/evaluation/configs/example.env`.\n\n## Quick Start\n\nRun FastContext from the repository you want to explore:\n\n```bash\nfastcontext \\\n  --query \"Find the files that implement authentication and explain where to make a change\" \\\n  --max-turns 6 \\\n  --traj .fastcontext/trajectory.jsonl\n```\n\nReturn only the machine-readable citation block:\n\n```bash\nfastcontext \\\n  --query \"Locate the request validation logic\" \\\n  --citation\n```\n\nUseful CLI options:\n\n| Option | Description |\n| --- | --- |\n| `--query`, `-q` | Natural-language exploration request. |\n| `--traj`, `-t` | JSONL trajectory output path. |\n| `--max-turns` | Maximum exploration turns before forcing a final answer. |\n| `--verbose` | Print intermediate messages and runtime information. |\n| `--citation` | Return only the `\u003cfinal_answer\u003e` block when present. |\n\n## Programmatic Use\n\n```python\nimport asyncio\n\nfrom fastcontext.agent.agent_factory import make_fastcontext_agent\n\n\nasync def main() -\u003e None:\n    agent = make_fastcontext_agent(\n        trajectory_file=\".fastcontext/trajectory.jsonl\",\n        work_dir=\"/path/to/repo\",\n    )\n    answer = await agent.run(\n        prompt=\"Find where database migrations are defined\",\n        max_turns=6,\n        citation=True,\n    )\n    print(answer)\n\n\nasyncio.run(main())\n```\n\n## Reproduction\n\nThis repository contains scripts for end-to-end Mini-SWE-Agent runs and standalone exploration evaluation.\nThe exact paths, model names, and credentials should be adapted to your serving environment.\n\n### End-to-End SWE-Bench Runs\n\n```bash\ngit submodule update --init --recursive\nuv build\ncp benchmark/evaluation/configs/example.env .env\n```\n\nEdit `.env` with the main-agent and FastContext endpoint credentials, then run:\n\n```bash\nuv run --group benchmark python benchmark/evaluation/bench_mini_swe_agent.py \\\n  --bench swebench-multilingual \\\n  --agent-config prompts/gpt-multi-fc.yaml \\\n  --config .env \\\n  --output preds.json \\\n  --logs-dir logs \\\n  --workers 1\n```\n\nFor SWE-bench Pro, use the Pro prompt:\n\n```bash\nuv run --group benchmark python benchmark/evaluation/bench_mini_swe_agent.py \\\n  --bench ScaleAI/SWE-bench_Pro \\\n  --agent-config prompts/gpt-pro-fc.yaml \\\n  --config .env \\\n  --output preds-pro.json \\\n  --logs-dir logs-pro\n```\n\n### Standalone Exploration\n\nThe standalone runner evaluates FastContext as a repository explorer on SWE-bench-style subagent queries.\n\n```bash\ncd benchmark/swebench\ncp run.sh.sample run.sh\n# Edit run.sh with BASE_URL, MODEL, and API_KEY.\n\nuv run --group benchmark python bench_fastcontext.py \\\n  --bench swebench-multilingual \\\n  --experiment fastcontext-eval \\\n  --prediction-file predictions.jsonl \\\n  --local-mount-dir /absolute/path/to/output \\\n  --num-threads 1\n```\n\nAfter extracting the final FastContext responses into a JSONL file with `instance_id` and `finial_response`\nfields, score citation quality from the repository root:\n\n```bash\nuv run --group benchmark python benchmark/evaluation/run_score.py \\\n  swebench-multilingual \\\n  result_finial_response.jsonl\n```\n\n## Training and Serving\n\nThe `training/` directory contains scripts used for the SFT and RL experiments described in the paper.\nThese scripts assume a research training environment with external model checkpoints, datasets, and cluster\nsettings; treat paths and launcher options as examples to adapt.\n\n```text\ntraining/\n  fastcontext-sft/     Supervised fine-tuning scripts and data utilities\n  fastcontext-rl/      Reinforcement-learning scripts and reward utilities\n```\n\nThe `serving/` directory contains example manifests and API checks for serving FastContext-compatible\nmodels behind an OpenAI-compatible endpoint.\n\n## Repository Layout\n\n```text\nsrc/fastcontext/\n  cli.py                         Command-line entry point\n  agent/\n    agent.py                     Agent loop\n    agent_factory.py             Default FastContext agent construction\n    context.py                   Conversation and trajectory storage\n    llm.py                       OpenAI-compatible LLM wrapper\n    system.md                    Explorer system prompt\n    tool/\n      read.py                    Read tool\n      glob.py                    Glob tool\n      grep.py                    Grep tool\n      tool.py                    Tool base classes and ToolSet\n\nbenchmark/\n  environment/                   Docker environment helpers\n  evaluation/                    End-to-end Mini-SWE-Agent runners and scoring utilities\n  swebench/                      SWE-bench-style standalone exploration runner\n\nprompts/                         Mini-SWE-Agent prompt configs with FastContext integration\ntraining/                        SFT and RL training scripts\nserving/                         Example serving manifests and API checks\ntests/                           Unit and integration-style tests\nfigures/                         README and paper figures\n```\n\n## Development\n\nRun linting:\n\n```bash\nuv run ruff check .\n```\n\nRun tests:\n\n```bash\nuv run pytest -q\n```\n\nBuild the package:\n\n```bash\nuv build\n```\n\n## Notes\n\n- FastContext is intended for repository exploration, not code modification.\n- Tool outputs are capped to keep interactions responsive.\n- The default CLI records trajectories under `.fastcontext/` unless `--traj` is provided.\n- For best results, write specific exploration queries that name the behavior, subsystem, error, or files you are trying to locate.\n\n## Citation\n\nIf you find FastContext useful, please cite:\n\n```bibtex\n@misc{zhang2026fastcontexttrainingefficientrepository,\n      title={FastContext: Training Efficient Repository Explorer for Coding Agents},\n      author={Shaoqiu Zhang and Maoquan Wang and Yuling Shi and Yuhang Wang and Xiaodong Gu and Yongqiang Yao and Tori Gong and Sheng Chen and Rao Fu and Anisha Agarwal and Spandan Garg and Gabriel Ryan and Colin Merkel and Yufan Huang and Shengyu Fu},\n      year={2026},\n      eprint={2606.14066},\n      archivePrefix={arXiv},\n      primaryClass={cs.SE},\n      url={https://arxiv.org/abs/2606.14066},\n}\n```\n\n## Acknowledgements\n\nFastContext builds on open research infrastructure and benchmarks for coding agents, including SWE-bench,\nSWE-bench Multilingual, SWE-bench Pro, SWE-QA, Mini-SWE-Agent, and open model / serving ecosystems.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Ffastcontext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Ffastcontext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Ffastcontext/lists"}