Multi-Agent Framework for Scientific Research Automation
Agent4Science is a production-ready multi-agent framework designed for scientific research automation. It provides a role-based agent system where specialized agents collaborate to handle complex research tasks.
| Agent | Role | Description |
|---|---|---|
| Miner | Literature Explorer | Deep research and paper discovery |
| Assayer | Knowledge Validator | Cross-verification and fact-checking |
| Caster | Code Engineer | Script and code generation |
| Artisan | Domain Expert | Field-specific Q&A and explanations |
graph LR
U[User Request] --> M[Miner]
M --> A[Assayer]
A --> C[Caster]
C --> T[Artisan]
T --> R[Result]
M -.->|handoff| C
A -.->|handoff| T
Agents can transfer tasks to specialized agents using the handoff system:
from agents import MinerAgent, CasterAgent
miner = MinerAgent()
handoff = miner.delegate_to(CasterAgent, "Generate analysis code")
result = handoff.execute()┌─────────────────────────────────────────────────────────┐
│ Orchestrator │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Miner │ │ Assayer │ │ Caster │ │ Artisan │ │
│ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │
│ │ │ │ │ │
│ └────────────┴────────────┴────────────┘ │
│ │ │
│ ┌───────────┴───────────┐ │
│ │ Handoff Manager │ │
│ └───────────────────────┘ │
│ │ │
│ ┌───────────────────────┼───────────────────────┐ │
│ │ Checkpoint Manager (SQLite/Memory) │ │
│ └───────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
- Tracing: End-to-end request tracing with span management
- Metrics: Token usage tracking per agent
- Logging: Structured logging with context propagation
git clone https://github.com/tsingxuanhan/agent4science.git
cd agent4science
pip install -r requirements.txtfrom agents import MinerAgent, AssayerAgent, CasterAgent, ArtisanAgent
# Create specialized agents
miner = MinerAgent(model="pro")
assayer = AssayerAgent(model="flash")
caster = CasterAgent(model="pro")
artisan = ArtisanAgent(model="flash")# Step 1: Literature search
papers = miner.search_papers("low carbon cement nano modification")
# Step 2: Validate findings
verified = assayer.verify_entries(papers)
# Step 3: Generate analysis code
code = caster.generate_code(
task="Statistical analysis of compressive strength data",
language="python"
)
# Step 4: Get domain explanation
explanation = artisan.explain_concept("LC3 ternary blend synergy")from orchestrator import TaskOrchestrator, ExecutionMode
orchestrator = TaskOrchestrator("research_pipeline")
# Add tasks with dependencies
orchestrator.add_task("search", miner.search, depends_on=[])
orchestrator.add_task("validate", assayer.verify, depends_on=["search"])
orchestrator.add_task("generate", caster.generate, depends_on=["validate"])
# Execute
results = orchestrator.execute(mode=ExecutionMode.SEQUENTIAL)# config.py
MODELS = {
"pro": "deepseek-v4-pro", # Complex reasoning
"flash": "deepseek-v4-flash" # Lightweight tasks
}
DEFAULT_PARAMS = {
"pro": {"temperature": 1.0, "max_tokens": 4096},
"flash": {"temperature": 1.0, "max_tokens": 2048}
}| Feature | Agent4Science | LangChain | CrewAI | AutoGen |
|---|---|---|---|---|
| Role-based Agents | ✅ Native | ✅ Native | ||
| Handoff System | ✅ Built-in | ❌ | ❌ | |
| Checkpoint/Resume | ✅ SQLite/Memory | ❌ | ❌ | |
| Scientific Focus | ✅ Domain-aware | |||
| Lightweight | ✅ Single-file core | ❌ Heavy |
- Literature Review Automation - Batch paper discovery and summarization
- Code Generation for Experiments - Auto-generate analysis scripts
- Knowledge Validation - Cross-check research findings
- Domain-specific Q&A - Expert-level explanations
agent4science/
├── base_agent.py # Core agent base class
├── checkpoint.py # Persistence layer
├── handoff.py # Task transfer system
├── memory.py # Conversation memory
├── observability.py # Tracing & metrics
├── orchestrator.py # Workflow orchestration
├── config.py # Configuration
├── agents/ # Specialized agents
│ ├── miner.py # Literature explorer
│ ├── assayer.py # Knowledge validator
│ ├── caster.py # Code generator
│ └── artisan.py # Domain expert
└── knowledge/ # Domain knowledge base
Contributions are welcome! Please ensure:
- New agents follow the BaseAgent interface
- Add tests for new functionality
- Update documentation accordingly
MIT License - See LICENSE for details.