A comprehensive agent-based framework that enhances the reasoning capabilities of foundation models through structured multi-step thinking processes and executable tools.
The MSR Framework is designed to improve problem-solving capabilities of large language models by implementing a structured, agent-based approach to complex tasks. By breaking down problems into explicit reasoning steps with goal-oriented planning, the framework enables more reliable, transparent, and effective solutions across a variety of domains.
The framework revolves around an agent architecture with the following key components:
- PlannerLLM: Generates structured research plans with explicit goals and dependencies between steps
- StepExecutor: Executes individual steps with tool integration and robust error handling
- Agent: Orchestrates the planning and execution processes with proper state management
MSR supports multiple tool types to enhance agent capabilities:
PYTHON_EXECUTION: Execute Python code for data analysis and computationTERMINAL_COMMAND: Run shell commands with security constraintsWEB_SEARCH: Retrieve real-time information from the internetFILE_OPERATIONS: Read and write files securelyDATA_ANALYSIS: Process and analyze structured dataVISUALIZATION: Generate data visualizations and charts
A Flask-based REST API server provides programmatic access to the MSR framework:
- Create and manage agent sessions
- Generate structured research plans
- Execute steps with or without approval workflows
- Monitor execution progress and retrieve results
- Comprehensive logging and security features
- Structured Planning: Generate detailed, multi-step plans with explicit goals for each step
- Dependency Tracking: Manage complex dependencies between steps for proper execution order
- Comprehensive Logging: Detailed logging system for tracking agent activities and debugging
- Tool Integration: Seamlessly integrate with various tools for enhanced capabilities
- REST API: Access all framework capabilities through a well-documented REST API
- Security Controls: Configurable security policies for tool execution and API access
- State Management: Robust state management for resuming interrupted executions
- Complex mathematical reasoning
- Multi-hop question answering
- Logical puzzles and deduction tasks
- Programming and algorithmic problem solving
src/: Core implementation of the multi-step reasoning architecturemodels/: Model configuration and adaptation for Qwen QWQ 32Breasoning/: Implementation of reasoning steps and pipelineutils/: Utility functions for prompts and other helpers
examples/: Sample applications and demonstrationseval/: Evaluation frameworks and benchmarkstests/: Unit tests for componentsscripts/: Utility scripts for configuration and maintenance
# Clone the repository
git clone https://github.com/darwin-labs/MSR.git
cd MSR
# Install dependencies
pip install -r requirements.txt
# Install the package in development mode
pip install -e .
# Set up your API keys
cp .env.template .env
# Edit .env with your API keysThe MSR framework uses environment variables for configuration, which can be set in a .env file:
# LLM API Configuration
OPENROUTER_API_KEY="your-api-key"
DEFAULT_MODEL="anthropic/claude-3-opus-20240229"
# Server Configuration
MSR_SERVER_HOST="0.0.0.0"
MSR_SERVER_PORT="5000"
MSR_API_KEY="your-secure-api-key"
MSR_API_KEY_REQUIRED="true"
# Logging Configuration
MSR_LOG_LEVEL="INFO"
MSR_LOG_FILE="logs/msr_server.log"
# Start the MSR REST API server
python -m src.server.server
# With custom configuration
python -m src.server.server --host 127.0.0.1 --port 8000 --log-level DEBUG --log-file logs/debug.logfrom examples.server_client_example import MSRClient
# Create client instance
client = MSRClient("http://localhost:5000", api_key="your-api-key")
# Create an agent
agent_data = client.create_agent(
task="Research the latest advancements in quantum computing",
allowed_tools=["WEB_SEARCH", "PYTHON_EXECUTION"],
model="anthropic/claude-3-opus",
temperature=0.7
)
# Get agent ID
agent_id = agent_data["agent_id"]
# Generate a plan
plan = client.generate_plan(agent_id, max_steps=5)
# Execute the plan
results = client.execute_plan(agent_id)
# Print results
for step_result in results["results"]["execution_results"]:
print(f"Step {step_result['step_id']}: {'Success' if step_result['success'] else 'Failed'}")
print(f"Findings: {step_result['findings'][:100]}...")# Run the agent example with web search and data analysis
python examples/agent_example.py "Analyze the impact of AI on healthcare in 2023" \
--enable-web-search --enable-data-analysis --max-steps 5 \
--log-file logs/agent.log --log-level INFO- API Reference: Comprehensive documentation of the REST API
- Agent System: Detailed explanation of the agent architecture
- Tool Integration: Guide to available tools and their capabilities
- Configuration: Configuration options and environment variables
Contributions are welcome! Please check out our contributing guidelines for details on how to get started.
This project is licensed under the MIT License - see the LICENSE file for details.
