Multi-agent system for generating A+B type scientific research ideas by combining insights from different fields using LangGraph.
A multi-agent system designed to generate innovative academic research proposals by combining insights from different fields. Built with LangGraph and LangChain, this system searches research threads and creates A+B type research ideas.
This skill helps you build and maintain a Python-based academic idea proposal system using LangGraph's multi-agent architecture. The system uses multiple specialized agents to search for research threads across different domains and intelligently combines them into novel research proposals.
The project uses:
Organize the codebase as follows:
```
/agents/ # Individual agent implementations
/tools/ # External API integrations (arXiv, Google Scholar, etc.)
/models/ # Data models and state definitions
/utils/ # Helper functions and utilities
```
1. **Type Safety**
- Use type hints for all function parameters and return values
- Define state models using `TypedDict` and `Annotated` types
- Example:
```python
from typing import TypedDict, Annotated
from langgraph.graph.message import add_messages
class AgentState(TypedDict):
messages: Annotated[list, add_messages]
research_threads: list[str]
```
2. **Code Quality**
- Follow PEP 8 style guidelines strictly
- Create clear, descriptive variable and function names
- Add comprehensive docstrings to all classes and functions
- Use async/await patterns for API calls
3. **Error Handling**
- Wrap all API calls in try-except blocks
- Implement graceful degradation when external services fail
- Log errors comprehensively for debugging
- Example:
```python
try:
response = await external_api.search(query)
except APIError as e:
logger.error(f"API call failed: {e}")
return fallback_response
```
When building agents:
1. **Use StateGraph for workflows**
```python
from langgraph.graph import StateGraph
workflow = StateGraph(AgentState)
workflow.add_node("researcher", research_agent)
workflow.add_node("combiner", combine_agent)
workflow.add_edge("researcher", "combiner")
```
2. **Implement proper state management**
- Use the `add_messages` pattern for state updates
- Keep state immutable where possible
- Return new state objects rather than modifying in place
3. **Create modular, composable agents**
- Each agent should have a single, clear responsibility
- Agents should be testable in isolation
- Design agents to be reusable across different workflows
When integrating research APIs (arXiv, Google Scholar, etc.):
1. **Security**
- Store API keys in environment variables
- Never hardcode credentials
- Use `.env` files for local development
2. **Rate Limiting**
- Implement rate limiting to respect API quotas
- Use exponential backoff for retries
- Queue requests when approaching limits
3. **Performance**
- Consider concurrent operations for multiple API calls
- Use connection pooling for HTTP requests
- Cache responses when appropriate
```python
from typing import Annotated
from langgraph.graph import StateGraph
from langgraph.graph.message import add_messages
from typing_extensions import TypedDict
class ResearchState(TypedDict):
"""State for research agent."""
messages: Annotated[list, add_messages]
query: str
papers: list[dict]
async def search_papers(state: ResearchState) -> ResearchState:
"""
Search for academic papers using arXiv API.
Args:
state: Current agent state containing search query
Returns:
Updated state with retrieved papers
"""
try:
# Implementation with proper error handling
results = await arxiv_client.search(state["query"], max_results=10)
return {**state, "papers": results}
except Exception as e:
logger.error(f"Paper search failed: {e}")
return {**state, "papers": []}
workflow = StateGraph(ResearchState)
workflow.add_node("search", search_papers)
workflow.set_entry_point("search")
app = workflow.compile()
```
1. Start with simple agent workflows and add complexity incrementally
2. Test each agent independently before composing into larger systems
3. Monitor API usage and costs when using external research services
4. Document the reasoning process of your agents for reproducibility
5. Version control your prompts and agent configurations
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/academic-idea-generator/raw