An academic paper writing agent based on LangGraph
Project description
seele-scholar-agent
LangGraph-based academic paper writing agent for topic proposal, literature retrieval, outline planning, section drafting, review loops, consistency checks, and reference generation.
Features
- Search papers from OpenAlex, Semantic Scholar, ArXiv, and custom retrievers.
- Propose concrete paper topics from broad research directions.
- Generate paper-type-aware outlines with section purpose, transitions, evidence maps, and suggested figures or tables.
- Draft sections with numbered citations, evidence packets, and claim-evidence bindings.
- Review sections, revise drafts, and cap revisions per section without force-approving failed reviews.
- Generate references with CrossRef/OpenAlex metadata enrichment and reject papers with no inline citations.
- Check outline quality, citation validity, claim support, methodology, paragraph quality, terminology, logic, and citation consistency.
- Apply locale-aware style packs for Chinese, Japanese, and English academic writing.
- Stream node output with
astream()for UI integration.
Install
git clone https://github.com/onekyuu/seele-scholar-agent
cd seele-scholar-agent
uv sync
For development dependencies:
uv sync --extra dev
Configuration
This package only owns agent-level configuration. LLM keys and models are injected by the caller.
Agent .env file:
cp src/seele_scholar_agent/.env.example src/seele_scholar_agent/.env
Supported agent variables:
| Variable | Description | Default |
|---|---|---|
SEMANTIC_SCHOLAR_API_KEY |
Optional Semantic Scholar API key | empty |
MAX_REVISIONS |
Max review cycles per section | 3 |
Example caller environment:
OPENAI_API_KEY=sk-...
OPENAI_MODEL=gpt-4o-mini
OPENAI_BASE_URL=https://api.openai.com/v1
Any OpenAI-compatible endpoint can be used through ChatOpenAI.
Quality Controls
The workflow includes deterministic gates in addition to LLM review:
OutlineQualityGateNode: blocks incomplete outlines that lack purpose, transitions, target claims, evidence plans, or use an empirical template for a non-empirical paper type.ReviewerNode: checks citation numbering, claim-source support, methodology/statistics issues, paragraph quality, and locale-specific writing style.ReferenceGeneratorNode: returnsNO_INLINE_CITATIONSinstead of generating a full bibliography when the draft has no inline citations.IntegrityGateNode: enforces strict academic checks whenstrict_academic_mode=True.MaterialRegistry: always enforces citation boundaries for uploaded, external, background-only, excluded, trusted, normal, or low-confidence materials when provided.
The RAG context is represented as evidence packets with chunk_id, title, authors, year, page, section, relevance score, relevance rationale, and quote. Writer output is audited through ClaimEvidenceBinding so citations are checked against the claim they support, not only against reference numbers.
Caller State Options
The caller can pass optional fields in AgentState to control structure, evidence policy, and style:
state.update(
{
"paper_type": "literature_review",
"structure_pattern": "thematic_review",
"target_word_count": 6000,
"strict_academic_mode": True,
"writing_locale": "zh-CN", # zh-CN, ja-JP, en-US, or a custom locale
"style_profile": "thesis",
"term_glossary": {"大语言模型": "大型语言模型"},
"style_pack_override": {
"display_name": "Custom thesis style",
"general_guidance": ["Use the institution-specific academic style."],
},
"material_registry": {
"entries": [
{
"paper_id": "user-paper-1",
"source_origin": "user_upload",
"citation_role": "citable",
"confidence": "trusted",
"required": True,
}
]
},
"check_required_material_relevance": True,
}
)
material_registry source-boundary checks are always active when a registry is provided. The required-material relevance check is optional and only runs when check_required_material_relevance=True. Required citations are marked with material_registry.entries[].required=True.
Quick Start
Run the no-interrupt workflow:
export OPENAI_API_KEY="sk-..."
export SCHOLAR_TOPIC="large language model interpretability"
export SCHOLAR_LANGUAGE="zh"
uv run python examples/simple_workflow.py
Use the graph in your own code:
from langchain_openai import ChatOpenAI
from seele_scholar_agent.graph import create_simple_writing_graph
from examples.common import build_initial_state, build_prompts
model = ChatOpenAI(model="gpt-4o-mini", api_key="sk-...")
state = build_initial_state("large language model interpretability")
app = create_simple_writing_graph(
model=model,
prompts=build_prompts(),
rag_retriever=None,
)
result = await app.ainvoke(
state,
config={"configurable": {"thread_id": state["thread_id"]}},
)
Examples
Large runnable examples live in examples/:
| File | Purpose |
|---|---|
examples/common.py |
Shared model, prompt, and initial-state helpers |
examples/simple_workflow.py |
Full automatic workflow with create_simple_writing_graph |
examples/full_workflow_with_interrupts.py |
Human-in-the-loop topic and outline approval |
examples/custom_retrievers.py |
Inject custom RAG and paper retrievers |
examples/stream_nodes.py |
Stream a single node with astream() |
examples/figure_placeholders.py |
Parse {{FIGURE: ...}} and {{TABLE: ...}} placeholders |
Run any example from the repository root:
uv run python examples/full_workflow_with_interrupts.py
Core API
The package exposes two graph builders:
from seele_scholar_agent.graph import create_simple_writing_graph, create_writing_graph
create_writing_graph(...): includes interrupts after topic proposal and outline planning.create_simple_writing_graph(...): runs without interrupts and is useful for tests or batch jobs.
Both require:
model: aChatOpenAIinstance or compatible LangChain chat model.prompts: a completePromptsConfig.rag_retriever: optionalCallable[[str], Awaitable[list[DocumentChunk]]].
Optional paper sources can be injected with extra_paper_retrievers.
Workflow
START
-> topic_proposer
-> researcher
-> planner
-> outline_quality_gate
-> writer <-> reviewer
-> finalizer
-> reference_generator
-> consistency_checker
-> integrity_gate
-> END
create_writing_graph() interrupts after topic_proposer and planner so the caller can choose a topic and approve the outline.
Project Structure
src/seele_scholar_agent/
├── agent_config.py
├── config.py
├── graph.py
├── i18n.py
├── logging.py
├── state.py
├── style_packs.py
├── nodes/
│ ├── topic_proposer.py
│ ├── researcher.py
│ ├── planner.py
│ ├── outline_quality_gate.py
│ ├── writer.py
│ ├── reviewer.py
│ ├── finalizer.py
│ ├── reference_generator.py
│ ├── consistency_checker.py
│ ├── integrity_gate.py
│ └── language_style_audit.py
└── tools/
└── crossref.py
Development
uv run pytest
uv run ruff check src/
uv run mypy src/
Build the package:
uv build
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file seele_scholar_agent-0.12.2.tar.gz.
File metadata
- Download URL: seele_scholar_agent-0.12.2.tar.gz
- Upload date:
- Size: 284.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4175c29faa8b43868ed9e0172954fb2e5834b210bf99a8a13bb0e1cf3d87bacd
|
|
| MD5 |
287dec32e3fdab3ce6aff9bb1ff4270a
|
|
| BLAKE2b-256 |
9f4e5e074753433ad420c6835601e27f52b2c289307ea6ac50c113480a012a16
|
Provenance
The following attestation bundles were made for seele_scholar_agent-0.12.2.tar.gz:
Publisher:
publish.yml on onekyuu/seele-scholar-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
seele_scholar_agent-0.12.2.tar.gz -
Subject digest:
4175c29faa8b43868ed9e0172954fb2e5834b210bf99a8a13bb0e1cf3d87bacd - Sigstore transparency entry: 1949358296
- Sigstore integration time:
-
Permalink:
onekyuu/seele-scholar-agent@04d1117362a4a0c4c9cf6e90a0b28f0895cfca83 -
Branch / Tag:
refs/tags/v0.12.2 - Owner: https://github.com/onekyuu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@04d1117362a4a0c4c9cf6e90a0b28f0895cfca83 -
Trigger Event:
push
-
Statement type:
File details
Details for the file seele_scholar_agent-0.12.2-py3-none-any.whl.
File metadata
- Download URL: seele_scholar_agent-0.12.2-py3-none-any.whl
- Upload date:
- Size: 79.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f79815dd75a413935e5c75976361c5542754adae4b09323daa7b0923c5d64c4
|
|
| MD5 |
08e61dce82778e5f45612eb164d0e523
|
|
| BLAKE2b-256 |
c19e7087471ac19fd43189444785cd84ef39ab0c10ba5cec2832b927177717ac
|
Provenance
The following attestation bundles were made for seele_scholar_agent-0.12.2-py3-none-any.whl:
Publisher:
publish.yml on onekyuu/seele-scholar-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
seele_scholar_agent-0.12.2-py3-none-any.whl -
Subject digest:
9f79815dd75a413935e5c75976361c5542754adae4b09323daa7b0923c5d64c4 - Sigstore transparency entry: 1949358452
- Sigstore integration time:
-
Permalink:
onekyuu/seele-scholar-agent@04d1117362a4a0c4c9cf6e90a0b28f0895cfca83 -
Branch / Tag:
refs/tags/v0.12.2 - Owner: https://github.com/onekyuu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@04d1117362a4a0c4c9cf6e90a0b28f0895cfca83 -
Trigger Event:
push
-
Statement type: