学习支持代理系统

一个智能教育助手,使用Strands框架和模型上下文协议(MCP)将问题路由到数学、科学和网络搜索查询的专门代理。

  • by shan-mani
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 shan-mani/strands-mcp-based-learning-support-agent

使用说明

Strands MCP-Based Learning Support Agent System

An intelligent educational assistant that routes questions to specialized agents for math, science, and web search queries using the Strands framework and Model Context Protocol (MCP).

Overview

Learning Support uses a supervisor agent pattern to intelligently route user questions to specialized sub-agents:

  • Math Agent: Handles calculations and mathematical problems using the calculator tool
  • Science Agent: Processes science-related queries (physics, chemistry, biology)
  • Search Agent: Performs web searches for current events and factual information via MCP fetch server

Architecture

┌─────────────────┐
│   Supervisor    │  Routes questions to appropriate specialist
│     Agent       │
└────────┬────────┘
         │
    ┌────┴────┬─────────┬──────────┐
    │         │         │          │
┌───▼───┐ ┌──▼───┐ ┌───▼────┐ ┌───▼────┐
│ Math  │ │Science│ │ Search │ │ Direct │
│ Tool  │ │ Tool  │ │  Tool  │ │ Answer │
└───────┘ └───────┘ └────────┘ └────────┘

Project Structure

.
├── agents/
│   ├── factory.py          # Agent factory for consistent configuration
│   ├── supervisor.py       # Main routing agent
│   ├── math_agent.py       # Math specialist agent
│   ├── science_agent.py    # Science specialist agent
│   └── search_agent.py     # Web search agent
├── tools/
│   ├── math_tool.py        # Calculator tool wrapper
│   ├── science_tool.py     # Science query tool
│   └── search_tool.py      # Web search tool
├── config/
│   ├── settings.py         # Configuration and logging setup
│   └── prompts.py          # System prompts for each agent
├── utils/
│   └── helpers.py          # Response cleaning utilities
└── main.py                 # CLI entry point

Installation

  1. Clone the repository
  2. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file with your configuration (if needed)

Usage

Run the interactive CLI:

python main.py

Example Interactions

> What is 25 * 48?
ROUTING DECISION: math_tool
REASON: Question involves multiplication calculation
SUCCESS: 1200

> What is photosynthesis?
ROUTING DECISION: science_tool
REASON: Biology-related question
SUCCESS: [Science explanation]

> What's the latest news about AI?
ROUTING DECISION: search_tool
REASON: Current events query
SUCCESS: [Search results]

Type exit to quit the application.

Features

  • Intelligent Routing: Automatically determines the best specialist for each question
  • Specialized Agents: Each agent is optimized for its domain
  • Clean Logging: Configurable logging system for debugging and monitoring
  • Error Handling: Graceful error handling with user-friendly messages
  • Extensible: Easy to add new specialist agents and tools

Configuration

Logging

Logging is configured in config/settings.py. Default level is INFO.

Model Selection

The default model is configured in config/settings.py via the DEFAULT_MODEL constant.

Development

Adding a New Specialist Agent

  1. Create agent in agents/your_agent.py
  2. Create corresponding tool in tools/your_tool.py
  3. Add prompt in config/prompts.py
  4. Update supervisor routing rules
  5. Export from agents/__init__.py and tools/__init__.py

Dependencies

  • strands: Core agent framework
  • strands-tools: Pre-built tools (calculator, MCP client)
  • python-dotenv: Environment variable management

License

[Add your license here]