MS-Agent Documentation

repository·main·Indexed 26 days ago

https://github.com/modelscope/ms-agent

A lightweight framework enabling agents to perform autonomous exploration, deep research, and complex tasks such as code and video generation using the Model Calling Protocol (MCP). The documentation covers the ms-agent-webui package (v1.0.0) and provides detailed integration guides for connecting MS-Agent's 30 MCP capabilities with other agent frameworks, including Hermes Agent, nanobot, and OpenClaw.

Tokens
91.3K
Snippets
207
Records
423
Agent score
87%

What's inside MS-Agent

  1. Overview of MS-Agent

    main
    MS-Agent is a lightweight framework designed to provide agents with autonomous exploration capabilities. It features a flexible and extensible architecture that enables developers to create agents capable of complex tasks such as code generation, data analysis, and general tool calling via Model Context Protocol (MCP) support.
  2. Overview of MS-Agent Deep Research versions

    main

    MS-Agent Deep Research provides an agent workflow for generating in-depth, multimodal research reports. It offers two distinct versions depending on your requirements:

    Base Version

    Designed for lightweight, efficient, and low-cost investigation. It uses a "search-then-execute" paradigm that completes tasks in minutes with modest token consumption. Key features include:

    • Autonomous Exploration: Automatic analysis of complex questions.
    • Multimodality: Extracts original chart/graph information for illustrated reports.
    • Accelerated Parsing: Uses Ray for document parsing acceleration.

    Extended Version

    Designed for deep, comprehensive, large-scale research. It builds on the Base Version by adding:

    • Intent Clarification: Proactively asks clarifying questions to refine research direction.
    • Deep Search: Recursively optimizes search paths to broaden coverage, stopping based on user budget or research progress.
    • Context Compression: Condenses long-context multimodal data into information-dense summaries to maintain quality across multi-round searches.
  3. Overview of Code Genesis Multi-Agent Framework

    main

    Code Genesis is a production-ready, open-source multi-agent framework designed for end-to-end project generation. It utilizes a topology-aware code synthesis approach, meaning it uses dependency-driven scheduling to prevent hallucinated references and enable parallel generation. The framework follows a holistic engineering pipeline that includes requirement analysis, architecture design, implementation, and deployment.

    Key technical features include:

    • Topology-Aware Code Synthesis: Uses dependency-driven scheduling to ensure correct file ordering.
    • LSP-Integrated Validation: Incorporates real-time Language Server Protocol (LSP) feedback during the generation process to ensure code correctness.
    • Multi-Agent Workflow: Employs specialized agents for different stages of the software development lifecycle (SDLC).
  4. Overview of Code Genesis Workflows

    main

    Code Genesis offers two distinct pipeline modes depending on your needs:

    1. Standard Workflow (Production-Grade): A 7-stage process (User Story → Architect → File Design → File Order → Install → Coding → Refine) designed for complex, high-quality applications with explicit architectural planning and dependency-driven generation.
    2. Simple Workflow (Rapid Prototyping): A 4-stage condensed process (Orchestrator → Install → Coding → Refine) optimized for speed and lightweight projects or quick iterations.
  5. Understand FinResearch Project Components

    main

    The FinResearch workflow is orchestrated via a Directed Acyclic Graph (DAG) of five specialized agents. Key configuration and logic files include:

    • workflow.yaml: The main entry point defining the execution process.
    • agent.yaml files: Individual configurations for the Orchestrator, Searcher, Collector, Analyst, and Aggregator agents.
    • conf.yaml: Configuration for search engines (e.g., Exa, SerpAPI) used by the Searcher agent.
    • callbacks/: Modules for handling agent outputs (e.g., orchestrator_callback.py saves plans, aggregator_callback.py saves final reports).
    • tools/: Contains build_jupyter_image.sh for Docker sandbox setup and principle_skill.py for analytical frameworks.
    • searcher.py: Triggers ms-agent/projects/deep_research for sentiment searches.
    • aggregator.py: Merges sentiment and quantitative analysis results.
  6. Understand the Code Genesis Standard Workflow

    main

    The standard workflow follows a 7-stage pipeline defined in workflow.yaml:

    1. User Story Agent: Parses requirements into structured stories.
    2. Architect Agent: Selects tech stack and defines architecture.
    3. File Design Agent: Generates physical file structure.
    4. File Order Agent: Constructs dependency DAG and topological sort.
    5. Install Agent: Bootstraps environment and resolves dependencies.
    6. Coding Agent: Synthesizes code with LSP validation.
    7. Refine Agent: Performs runtime validation, bug fixing, and automated deployment.
  7. Understand the Long-term Memory structure for Nanobot

    main

    The MEMORY.md file serves as the long-term memory storage for the nanobot agent. It is designed to persist important information across different sessions. The file is structured into four main sections:

    • User Information: Stores important facts about the user.
    • Preferences: Stores user preferences learned by the agent over time.
    • Project Context: Stores information regarding ongoing projects.
    • Important Notes: Stores miscellaneous things the agent should remember.

    Note: This file is automatically updated by nanobot when the agent identifies information that should be remembered.

  8. Key Features of MS-Agent

    main

    MS-Agent offers several core capabilities:

    • Multi-Agent for general purpose: Chat with agents featuring tool-calling capabilities based on MCP.
    • Deep Research: Enables advanced autonomous exploration and complex task execution.
    • Code Generation: Supports code generation tasks with artifacts.
    • Short Video Generation: Supports video generation of approximately 5 minutes.
    • Agent Skills: A knowledge-driven skill system providing reusable procedural knowledge via standard tool integration. It features multi-source loading, progressive disclosure, and runtime self-evolution.
    • WebUI: A modern web interface for agent interaction using real-time WebSocket communication.
    • Lightweight and Extensible: Designed for easy customization and extension.
  9. Understand the Standard Workflow stages

    main

    The Standard Workflow uses seven specialized agents to ensure production-ready output:

    • User Story Agent: Parses requirements and augments them with missing specifications (e.g., auth, error handling).
    • Architect Agent: Selects the technology stack (frameworks, databases) and defines communication protocols (REST, GraphQL, etc.).
    • File Design Agent: Creates the physical file tree and package structures based on the architecture.
    • File Order Agent: Constructs a dependency-aware directed acyclic graph (DAG) and performs topological sorting to ensure files are generated in the correct order.
    • Install Agent: Bootstraps the environment by generating dependency manifests and invoking package managers (e.g., pip, npm, mvn).
    • Coding Agent: Synthesizes code following the topological order and validates it using Language Server Protocol (LSP) for syntax, types, and imports.
    • Refine Agent: Performs runtime verification, executes the project, applies surgical fixes to errors, and handles automated deployment.
  10. Understand the Simple Workflow stages

    main

    The Simple Workflow is a condensed pipeline for rapid prototyping:

    • Orchestrator Agent: A single reasoning step that handles requirement analysis, architecture design, and file planning.
    • Install Agent: Handles dependency resolution and environment setup.
    • Coding Agent: Performs direct code generation with integrated file ordering.
    • Refine Agent: Handles final validation and deployment.
  11. Use LLMAgent for basic agent functionality

    main

    The LLMAgent class is the core component in MS-Agent responsible for conversational capabilities and tool invocation. It manages the execution loop, including LLM calls, tool usage, message management, and RAG.

    Execution Loop Logic:

    1. Registers configured callbacks.
    2. Initializes LLM, tools, message management, and RAG.
    3. Reads message history cache.
    4. Prepares messages (RAG queries, plans, etc.).
    5. Enters loop: attempts to compress messages, prepares tool list, calls LLM, and executes tools based on results.

    Loop Termination Conditions:

    • The model provides a reply without any tool calls.
    • The number of rounds reaches max_chat_round specified in the configuration.
  12. Understand Skill Progressive Disclosure

    main

    MS-Agent uses a three-level progressive disclosure mechanism to manage context window costs and detail levels:

    1. L1 (Automatic): The system prompt includes a lightweight index (Name + one-line description) for all enabled skills (~30 tokens per skill).
    2. L2 (On Demand): The model calls the skill_view(skill_id) tool to load the full SKILL.md body.
    3. L3 (On Demand): The model uses skill_view with a file_path to access referenced scripts, templates, or documentation files.