How jokyun/langmanus works
Project Type and Purpose
• LangManus is an open-source, community-driven AI automation framework focused on multi-agent coordination. It combines language models with specialized tools for tasks such as web search, crawling, Python code execution, and workflow management.
• The README emphasizes the academic research objectives as well as system experimentation for multi-agent collaboration (e.g., coordinator, planner, supervisor, researcher, coder, browser, and reporter roles).
File Structure for Architectural Clues
• Top-Level Components:
• Configuration and environment: Files like .env.example, conf.yaml.example, Dockerfile, docker-compose.yml, and pre-commit indicate environment management and deployment automation.
• Source code structure: The src folder is divided into sub-modules such as agents, api, config, crawler, graph, llms, prompts, service, tools, and utils. This organization points to a layered design, where agents handle specific tasks and integrate with API and tool modules.
• Entry points: main.py (likely for CLI or main workflow execution) and server.py (FastAPI-based API server for streaming chat interactions).
• Testing and Continuous Integration: The tests directory, Makefile, and GitHub workflows (build, lint, test) indicate automated quality checks.
• Prominent Patterns:
• Modular decomposition with clear separation for agents, configuration, tools, and API endpoints.
• Use of prompt files to define agent roles, suggesting a template-based behavioral system.
• Docker and docker-compose files indicate containerization and support for both backend and web UI (the latter is in a separate repo).
Key Components
a. Multi-Agent System:
• Agent Coordinator/Supervisor: Central entity that delegates tasks to and orchestrates other agents.
• Specialized Agents: Include Planner, Researcher, Coder, Browser, Reporter. Use the prompts (in src/prompts) and implementation (in src/agents) as references.
b. API Server:
• The FastAPI-based interface (server.py and src/api/app.py) that exposes endpoints (e.g., POST /api/chat/stream) for external interactions.
c. Supporting Modules:
• Configuration Module: (src/config) which holds settings, LLM model configurations, and environment variable integration.
• Web Crawling Module: (src/crawler) dealing with content extraction, web scraping, and interaction with Jina and Tavily.
• Graph Visualization: (src/graph) that possibly builds and maintains the workflow graph.
• LLM Integration: (src/llms) managing different models for reasoning, basic tasks, and vision-language tasks.
• Tooling and Utilities: (src/tools and src/utils) encapsulating common supporting functions (e.g., file management, bash tool, search utilities).
d. Infrastructure and Deployment Elements:
• Docker Configuration: Dockerfile and docker-compose.yml are used to containerize the application.
• Versioning and CI/CD: GitHub workflows and Makefile directives for linting, testing, and formatting.
Relationships and Data Flow
• How a client or web UI (which is provided via a separate repository) interacts with the API server.
• Interactions for external integrations such as online search (Tavily, Jina) and web browsing (using Playwright with browser configurations).
Architectural Patterns and Design Principles
• Multi-agent architectural pattern: Emphasize the hierarchical structure (with a coordinator/supervisor at the top level orchestrating various specialized agents).
• Separation of concerns: Distinct modules for API handling, configuration, crawling, intelligent reasoning (LLMs), and utility functions.
• Extensibility: The prompt system (markdown templates) encourages easy modifications to agent behaviors without deeply changing the codebase.