An open API service indexing awesome lists of open source software.

https://github.com/saadmsft/nanoresearch

Tri-level co-evolving multi-agent research automation โ€” a faithful re-implementation of arXiv:2605.10813 with a ChatGPT-style web UI.
https://github.com/saadmsft/nanoresearch

Last synced: 25 days ago
JSON representation

Tri-level co-evolving multi-agent research automation โ€” a faithful re-implementation of arXiv:2605.10813 with a ChatGPT-style web UI.

Awesome Lists containing this project

README

          

# ๐Ÿ”ฌ NanoResearch

**A tri-level co-evolving multi-agent research automation system.**

_Re-implementation of [NanoResearch (arXiv:2605.10813)](https://arxiv.org/abs/2605.10813) with a ChatGPT-style web UI and field-agnostic prompts._

[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/)
[![FastAPI](https://img.shields.io/badge/FastAPI-0.115-009688?logo=fastapi)](https://fastapi.tiangolo.com/)
[![React](https://img.shields.io/badge/React-18-61DAFB?logo=react)](https://react.dev/)
[![Tests](https://img.shields.io/badge/tests-61_passing-brightgreen.svg)](#testing)
[![Docs](https://img.shields.io/badge/docs-online-blue.svg)](https://saadmsft.github.io/nanoresearch/)

[**๐Ÿ“– Documentation**](https://saadmsft.github.io/nanoresearch/) ยท
[**๐Ÿ— Architecture**](https://saadmsft.github.io/nanoresearch/architecture/) ยท
[**๐Ÿš€ Quickstart**](#quickstart) ยท
[**๐Ÿ“„ Original paper**](https://arxiv.org/abs/2605.10813)

---

> _"Automation **for whom**? Researchers operate under different resource configurations, hold different methodological preferences, and target different output formats. A system that produces uniform outputs regardless of these differences will systematically under-serve every individual user."_
>
> โ€” NanoResearch (Xu et al., 2026)

NanoResearch takes a one-line research idea โ€” in **any scholarly field** โ€” and rides it through ideation, planning, experimentation, analysis, writing, and review to produce a downloadable LaTeX paper, while **learning your preferences** so the next run feels more like _you_.

## โœจ Highlights

- ๐Ÿ’ฌ **Single chat surface.** No buttons. Tell it your field and a topic; it narrates the pipeline back to you and pauses for feedback at every stage.
- ๐ŸŒ **Field-agnostic.** Biology, social sciences, engineering, mathematics, computer science โ€” prompts adapt to the field's conventions (regressions vs. proofs vs. case studies vs. ablations).
- ๐Ÿง  **Tri-level co-evolution.** Per-user **Skill Bank** (procedural rules), **Memory Module** (project-specific facts), and a planner adapter trained via **SDPO** from your free-form feedback.
- ๐Ÿ”ฌ **Real artefacts.** Generates and **runs** a Python project for empirical fields, parses results, then assembles a section-by-section LaTeX paper that compiles to PDF (when `pdflatex` is installed).
- ๐Ÿ” **Azure AD auth.** Talks to your private GPT-5.1 deployment via `DefaultAzureCredential` โ€” no API keys in `.env`.

### Pipeline at a glance

```mermaid
flowchart LR
T[Topic] --> O((Orchestrator))
O -->|retrieve| SB[(Skill Bank ๐’ฎ)]
O -->|retrieve| MM[(Memory Module โ„ณ)]
O --> I[Ideation]:::s1
I --> P[Planning]:::s1
P --> C[Coding +
Execution]:::s2
C --> A[Analysis]:::s2
A --> W[Writing]:::s3
W --> R[Review]:::s3
R --> Paper[paper.pdf]
W -.->|distil| SB
W -.->|distil| MM
I -.->|narrations| U[Chat]
P -.-> U
C -.-> U
A -.-> U
W -.-> U
U -.->|feedback โ„ฑ| O
classDef s1 fill:#1e3a8a,stroke:#3b82f6,color:#fff
classDef s2 fill:#92400e,stroke:#f59e0b,color:#fff
classDef s3 fill:#065f46,stroke:#10b981,color:#fff
```

## ๐Ÿ—‚ What's in the box

| Component | Folder | Purpose |
|---|---|---|
| ๐Ÿง  **Backend (Python)** | [`src/nanoresearch/`](src/nanoresearch/) | Multi-agent pipeline, FastAPI server, Skill/Memory stores, SDPO trainer |
| ๐Ÿ’ฌ **Frontend (React + Vite)** | [`ui/`](ui/) | Chat-first UI with assistant-uiโ€“style bubbles and live SSE narrations |
| ๐Ÿ“š **Documentation site** | [`docs/`](docs/) | Jekyll-friendly markdown; deployed to GitHub Pages |
| ๐Ÿ–ผ **Diagrams** | [`docs/assets/diagrams/`](docs/assets/diagrams/) | Mermaid sources + rendered PNGs |
| ๐Ÿงช **Tests** | [`tests/`](tests/) | 61 unit + integration tests, offline-runnable |

## ๐Ÿš€ Quickstart

### Prerequisites

- Python **3.11+** (3.12 tested)
- Node **18+** (Vite + assistant-ui)
- An **Azure OpenAI / Foundry** deployment of GPT-5.1 (or a compatible reasoning model)
- `az login` performed locally; your account needs the **Cognitive Services OpenAI User** role
- _(optional)_ `pdflatex` or `tectonic` for PDF compilation โ€” otherwise the paper ships as `.tex`
- _(optional)_ Apple-Silicon Mac with 32 GB+ unified RAM for the local Qwen planner (SDPO)

### Setup

```bash
# 1. Clone + venv
git clone https://github.com/saadmsft/nanoresearch.git
cd nanoresearch
python3.12 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

# 2. Configure Azure (AAD auth โ€” no API keys)
cp .env.example .env
# edit AZURE_OPENAI_ENDPOINT + AZURE_OPENAI_DEPLOYMENT
az login

# 3. Backend
nanoresearch serve # http://127.0.0.1:8000

# 4. Frontend (separate terminal)
cd ui && npm install && npm run dev # http://localhost:5173
```

Open and say hi.

### Optional: local SDPO planner

```bash
pip install -e ".[local]" # torch, transformers, peft, accelerate
huggingface-cli download Qwen/Qwen2.5-7B-Instruct \
--local-dir data/models/Qwen2.5-7B-Instruct
```

## ๐Ÿ’ฌ What it looks like

```text
You โ–ธ I'm Mia, an ecologist. I prefer field studies, 6-month timeline.
Start a run on canopy cover and breeding-bird richness in city parks.

NanoResearch โ–ธ Nice to meet you, Mia. Starting on canopy cover + bird richness.
NanoResearch โ–ธ ๐Ÿ”Ž Searching scholarly databasesโ€ฆ
NanoResearch โ–ธ ๐Ÿ“š Done. 12 papers.
NanoResearch โ–ธ ๐Ÿ’ก Drafted hypotheses (n=6). Checking novelty next.
NanoResearch โ–ธ ๐ŸŽฏ Going with: Canopy ร— heterogeneity interaction predicts richness.
NanoResearch โ–ธ โธ Paused at ideation โ€” what should I emphasise or change?

You โ–ธ Keep the design simple and proceed.

NanoResearch โ–ธ ๐Ÿ“ Drafting an experiment blueprintโ€ฆ
NanoResearch โ–ธ ๐Ÿ‘€ Running an internal peer review of the blueprintโ€ฆ
NanoResearch โ–ธ ๐Ÿงช Writing a small experiment project to test the planโ€ฆ
NanoResearch โ–ธ โ–ถ๏ธ Running the experimentโ€ฆ
NanoResearch โ–ธ ๐Ÿ“ˆ Run finished (ok=True exit=0 dur=3.2s).
NanoResearch โ–ธ ๐Ÿ“Š Analysing resultsโ€ฆ
NanoResearch โ–ธ โœ๏ธ Drafting the introduction / method / experiments / โ€ฆ sections.
NanoResearch โ–ธ ๐Ÿ‘“ Reviewing the paper draft.
NanoResearch โ–ธ ๐Ÿ“„ Paper compiled. [Download PDF] โ€” or the [LaTeX source].
```

## ๐Ÿ› Architecture

NanoResearch is a **stage pipeline** orchestrated around two persistent stores and one trainable planner.

```mermaid
flowchart TB
subgraph User["๐Ÿ‘ค User"]
Chat["๐Ÿ’ฌ Chat UI"]
end

subgraph API["โšก FastAPI"]
Intent["/api/intent
NL โ†’ action"]
RunMgr["RunManager
background thread"]
Narr["Narrator
event โ†’ English"]
SSE["SSE /stream
+ narration"]
Files["paper.pdf
paper.tex"]
end

subgraph Pipe["๐Ÿ”ฌ Pipeline (Orchestrator)"]
direction LR
I[Ideation] --> P[Planning]
P --> C[Coding]
C --> An[Analysis]
An --> W[Writing]
end

subgraph Stores["๐Ÿ’พ Per-User Stores"]
Profile[(Profile)]
Skill[(Skill Bank ๐’ฎ)]
Mem[(Memory โ„ณ)]
LoRA[(LoRA adapter)]
end

subgraph LLMs["๐Ÿค– Models"]
Azure[Azure OpenAI
GPT-5.1]
Qwen[Qwen2.5-7B
local ยท planner only]
end

Chat <-->|HTTP| Intent
Chat <-->|EventSource| SSE
Chat -->|download| Files
Intent --> RunMgr
RunMgr --> Pipe
Pipe --> Narr --> SSE
Pipe <-->|retrieve / distil| Stores
Pipe -->|complete| Azure
Pipe -->|plan| Qwen
Qwen <-->|SDPO LoRA| LoRA
```

๐Ÿ“– **Full architecture deep-dive:** [docs/architecture.md](docs/architecture.md) ยท [paper ยง3 mapping](docs/paper-mapping.md) ยท [SDPO math](docs/sdpo.md)

## ๐Ÿงช Testing

```bash
pytest -m "not azure and not local_model" # 61 offline tests
pytest -m azure # AAD smoke
pytest -m local_model # Qwen MPS smoke
```

| Suite | Tests |
|---|---|
| Config + manifest + router | 9 |
| Stores (schemas, retrieval, distill) | 18 |
| Orchestrator | 8 |
| Stage I (literature + ideation + planning) | 9 |
| Stage II + III (sandbox, narrator, TeX, schemas) | 9 |
| HTTP API | 7 |
| SDPO (gradient + LoRA) | 3 (opt-in) |
| Azure / local smoke | 2 (opt-in) |

## ๐Ÿ“‚ Repository layout

```text
nanoresearch/
โ”œโ”€โ”€ src/nanoresearch/
โ”‚ โ”œโ”€โ”€ agents/ # Stage I-III stage controllers + prompts + artefacts
โ”‚ โ”œโ”€โ”€ api/ # FastAPI app, RunManager, intent classifier, narrator
โ”‚ โ”œโ”€โ”€ cli/ # `nanoresearch serve`, `health`, `settings`
โ”‚ โ”œโ”€โ”€ config/ # pydantic-settings
โ”‚ โ”œโ”€โ”€ literature/ # OpenAlex client + evidence extraction
โ”‚ โ”œโ”€โ”€ llm/ # Azure (AAD) + local Qwen backends, agent-role router
โ”‚ โ”œโ”€โ”€ logging/ # structlog + per-run JSONL manifest
โ”‚ โ”œโ”€โ”€ orchestrator/ # Retrieve โ†’ Plan โ†’ Dispatch โ†’ Reflect โ†’ Update
โ”‚ โ”œโ”€โ”€ planner/ # Qwen wrapper + LoRA + SDPO trainer (Eq. 14-15)
โ”‚ โ”œโ”€โ”€ schemas/ # Profile / Skill / Memory pydantic models
โ”‚ โ””โ”€โ”€ stores/ # SkillBank + MemoryStore + Profile (JSON-backed)
โ”œโ”€โ”€ ui/ # React + TypeScript + Tailwind chat
โ”œโ”€โ”€ docs/ # Jekyll site (GitHub Pages)
โ”œโ”€โ”€ tests/ # Pytest suite
โ”œโ”€โ”€ runs/ # โ† created at runtime (event logs + papers//paper.tex)
โ””โ”€โ”€ data/users// # โ† created at runtime (profile, skills, memories, lora)
```

## ๐Ÿ—บ Roadmap

- [x] Phase 0โ€“4 โ€” bootstrap, stores, planner+SDPO, orchestrator, Stage I (Ideation + Planning)
- [x] Phase 5 โ€” Stage II (Coding + sandboxed exec + debug loop) + Analysis
- [x] Phase 6 โ€” Stage III (Writing + Reviewer + LaTeX/PDF)
- [x] FastAPI + React/Vite UI with live SSE narrations
- [ ] Phase 7 โ€” Compliance/Novelty/Writing judges (paper ยง8โ€“10) + 20-topic benchmark harness
- [ ] Phase 8 โ€” CLI ergonomics (`nanoresearch run`, `nanoresearch eval`)
- [ ] Docker sandbox upgrade for Stage II
- [ ] Per-section figure generation + bibliography auto-fill

## ๐Ÿ“œ Citation

If this implementation is useful in your research, please cite the original paper:

```bibtex
@misc{xu2026nanoresearch,
title = {NanoResearch: Co-Evolving Skills, Memory, and Policy for Personalized Research Automation},
author = {Xu, Jinhang and Zhu, Qiyuan and Wu, Yujun and Wang, Zirui and Zhang, Dongxu and others},
year = {2026},
eprint = {2605.10813},
archivePrefix = {arXiv},
primaryClass = {cs.AI},
url = {https://arxiv.org/abs/2605.10813}
}
```

## ๐Ÿ“„ License

Apache 2.0 โ€” see [LICENSE](LICENSE).

Original NanoResearch paper ยฉ Xu et al., 2026.
This implementation is independent and not affiliated with the original authors.