Skip to content

sherkevin/Weaver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

56 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Weaver Logo

๐Ÿ•ท๏ธ Weaver

Weave workflows, ship code.

A powerful, configuration-driven framework for orchestrating multiple AI agents using LangGraph and Aider

The Weaver (็ผ–็ป‡่€…): Unlike ants that swarm, the spider (Weaver) is solitary, highly intelligent, and excels at building complex structures (Web/Graph). It perfectly embodies LangGraph's formโ€”weaving workflows, transforming code (threads) into software (fabric).

Python Version License LangGraph Aider

Features โ€ข Quick Start โ€ข Documentation โ€ข Examples โ€ข Contributing

English | ไธญๆ–‡


๐Ÿ“– Overview

LangGraph + Aider Framework

Weaver is an enterprise-grade framework that enables seamless collaboration between multiple AI agents through declarative YAML configurations. Built on top of LangGraph's powerful graph-based orchestration engine and Aider's code editing capabilities, it allows you to define complex multi-agent workflows without writing a single line of Python code.

The Weaver Philosophy

Just as a spider weaves its web with precision and intelligence, Weaver helps you craft sophisticated multi-agent workflows. Each agent is like a thread, and together they form a robust fabric of software solutions. The framework's graph-based architecture mirrors the spider's webโ€”complex, interconnected, and beautifully structured.

Why This Framework?

  • ๐ŸŽฏ Zero-Code Workflow Definition: Define complex agent collaboration flows using simple YAML files
  • ๐Ÿ”„ Production-Ready: Built-in error handling, retry mechanisms, and comprehensive logging
  • โšก High Performance: Agent caching and keep-alive sessions for optimal execution speed
  • ๐Ÿ”Œ Extensible: Plugin-based architecture with hot-swappable routers
  • ๐Ÿ›ก๏ธ Robust: Complete state management, execution history, and error recovery

โœจ Key Features

๐ŸŽจ Configuration-Driven Workflows

  • Zero-code workflow definition via YAML configuration files
  • Complete decoupling of business logic from framework code
  • Hot-swappable routers with Convention over Configuration support

๐Ÿ”€ LangGraph-Powered Orchestration

  • Graph-based state machines for complex branching and loops
  • Flexible condition routing with expressive condition evaluation
  • Complete state tracking with execution history and recovery support

๐Ÿ’พ Keep-Alive Session Management

  • Persistent sessions via FastAntsSession to keep agents alive in memory
  • Intelligent agent caching to avoid redundant initialization
  • Continuous workflow execution within a single session

๐Ÿ”ง Deep Aider Integration

  • Powerful code editing capabilities through Aider integration
  • Diff-based modifications for precise file change tracking
  • Automatic Git integration with version control support

๐Ÿ“Š Comprehensive Monitoring

  • Unified error handling with decorator-based retry mechanisms
  • Detailed logging system with agent responses, state transitions, and errors
  • Execution history tracking for debugging and auditing

๐Ÿค Flexible Collaboration Patterns

  • Multi-agent collaboration following defined workflows
  • Shared workspace with isolated workspaces per workflow
  • Built-in collaboration guidelines ensuring consistent agent output formats

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.10+
  • Git
  • OpenAI API Key (or compatible API service)

Installation

# Clone the repository
git clone https://github.com/sherkevin/Weaver.git
cd Weaver

# Install dependencies
pip install -r src/requirements.txt

Configuration

  1. Set up environment variables

Create a .env file in the src/ directory:

cd src
cat > .env << EOF
OPENAI_API_KEY=your_api_key_here
OPENAI_API_BASE=https://api.openai.com/v1
EOF

Or export them directly:

export OPENAI_API_KEY="your_api_key_here"
export OPENAI_API_BASE="https://api.openai.com/v1"
  1. Configure project paths

Edit src/config/config.yaml and update paths.project_root:

paths:
  project_root: "/your/actual/project/path/Weaver"
  framework_root: "${paths.project_root}/src"
  workspace_root: "${paths.project_root}/workspaces"

Run Your First Workflow

Option 1: Command Line (Single Run)

# List available workflows
python -m src.main --list

# Run a specific workflow (hulatang is a demo case: PPT creation workflow)
python -m src.main --run hulatang

# Run default workflow
python -m src.main

Workflow Config File Location: src/workflows/{workflow_name}/workflow.yaml

For example, the hulatang workflow config is located at: src/workflows/hulatang/workflow.yaml

Option 2: Python Script (Keep-Alive Session) โญ Recommended

Create run_workflow.py:

from src.main import FastAntsSession

# Use context manager for automatic cleanup
with FastAntsSession() as session:
    # Run workflow
    result = session.run_workflow("hulatang")
    
    # View session info
    info = session.get_session_info()
    print(f"Session Info: {info}")
    
    # Run multiple workflows in the same session
    # result2 = session.run_workflow("collaboration")

Run it:

python run_workflow.py

Option 3: Interactive Python

from src.main import FastAntsSession

# Create session
session = FastAntsSession()

# Run workflow
result = session.run_workflow("hulatang")

# Check results
print(f"Success: {result.success}")
print(f"Total Turns: {result.total_turns}")
print(f"Agents Used: {result.agents_used}")

# Cleanup (optional)
session.cleanup_workflow("hulatang")

๐Ÿ“ Project Structure

Weaver/
โ”œโ”€โ”€ src/                          # Source code
โ”‚   โ”œโ”€โ”€ main.py                   # Main entry point, FastAntsSession
โ”‚   โ”œโ”€โ”€ config/                   # Configuration management
โ”‚   โ”‚   โ”œโ”€โ”€ config.yaml          # Main config file
โ”‚   โ”‚   โ””โ”€โ”€ app_config.py        # Config loader
โ”‚   โ”œโ”€โ”€ core/                     # Core components
โ”‚   โ”‚   โ”œโ”€โ”€ workflow_factory.py   # Workflow factory
โ”‚   โ”‚   โ”œโ”€โ”€ workflow_base.py      # Base workflow class
โ”‚   โ”‚   โ”œโ”€โ”€ workflow_state.py    # State definitions
โ”‚   โ”‚   โ””โ”€โ”€ config_workflow.py   # Config-driven workflow
โ”‚   โ”œโ”€โ”€ engines/                  # Execution engines
โ”‚   โ”‚   โ””โ”€โ”€ langgraph_engine.py  # LangGraph engine
โ”‚   โ”œโ”€โ”€ services/                 # Service layer
โ”‚   โ”‚   โ”œโ”€โ”€ agent_service.py     # Agent service
โ”‚   โ”‚   โ”œโ”€โ”€ environment_service.py # Environment service
โ”‚   โ”‚   โ””โ”€โ”€ evaluators/          # Condition evaluators
โ”‚   โ”œโ”€โ”€ workflows/                # Workflow definitions
โ”‚   โ”‚   โ”œโ”€โ”€ hulatang/            # Example: PPT creation workflow
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ workflow.yaml   # Workflow config
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ router.py       # Custom router (optional)
โ”‚   โ”‚   โ””โ”€โ”€ guide.py            # Collaboration guidelines
โ”‚   โ”œโ”€โ”€ decorators/               # Decorators
โ”‚   โ”œโ”€โ”€ diagnostics/             # Logging and diagnostics
โ”‚   โ””โ”€โ”€ requirements.txt         # Python dependencies
โ”œโ”€โ”€ workspaces/                   # Workspace directory
โ”‚   โ””โ”€โ”€ {workflow_name}/         # Isolated workspace per workflow
โ”‚       โ”œโ”€โ”€ collab/              # Shared deliverables
โ”‚       โ””โ”€โ”€ {agent_name}/        # Private agent directories
โ”œโ”€โ”€ aider/                        # Aider integration (local)
โ””โ”€โ”€ README.md                     # This file

๐Ÿ“ Workflow Configuration Example

Workflows are defined using YAML files. Here's an example from src/workflows/hulatang/workflow.yaml:

name: "hulatang"
description: "PPT Creation Workflow: Natural Conversation Collaboration"
initial_message: "Create a promotional PPT about Hulatang"
max_turns: 10

# Agent definitions
agents:
  - name: "client"
    type: "coder"
  - name: "supplier"
    type: "coder"

# State machine definition
states:
  - name: "client_request"
    agent: "client"
    start: true
    prompt: |
      ใ€roleใ€‘๏ผšYou are the client (requester).
      ใ€taskใ€‘๏ผš{{initial_message}}
      Please create a requirements document including:
      - PPT theme, number of pages, style requirements
      - Key content, special requirements
      ใ€decisionsใ€‘:
      {
        "decisions": {
          "request_complete": true  // true: ready to discuss; false: need more info
        }
      }
    transitions:
      - to: "supplier_discuss"
        condition: "request_complete"
  
  - name: "supplier_discuss"
    agent: "supplier"
    prompt: |
      ใ€roleใ€‘๏ผšYou are the supplier (developer/designer).
      Client said: {{last_agent_content}}
      Please discuss the PPT design plan and confirm requirements.
      ใ€decisionsใ€‘:
      {
        "decisions": {
          "design_confirmed": false,  // true: agreement reached
          "ready_to_build": false     // true: ready to start coding
        }
      }
    transitions:
      - to: "client_discuss"
        condition: "NOT (design_confirmed AND ready_to_build)"
      - to: "supplier_create"
        condition: "design_confirmed AND ready_to_build"

  # ... more states

# Global exit conditions
exit_conditions:
  - condition: "max_turns_exceeded"
    action: "force_end"
  - condition: "error_occurred"
    action: "save_and_end"

๐ŸŽจ Creating Custom Workflows

๐Ÿ“– For detailed workflow engineering guide, see Workflow Development Guide

Step 1: Create Workflow Directory and Config File

Workflow config files must be located at: src/workflows/{workflow_name}/workflow.yaml

# Create workflow directory
mkdir -p src/workflows/my_workflow

# Create config file
touch src/workflows/my_workflow/workflow.yaml

Step 2: Write workflow.yaml

Define your workflow following the example above. Key components:

  • name: Unique workflow identifier
  • agents: List of agents participating in the workflow
  • states: State machine definition with prompts and transitions
  • exit_conditions: Global conditions for workflow termination

Step 3: (Optional) Create Custom Router

For complex condition evaluation logic, create router.py:

from ...core.router_base import BaseRouter

class MyWorkflowRouter(BaseRouter):
    def evaluate_condition(self, condition: str, context: dict) -> bool:
        # Custom condition evaluation logic
        if condition == "custom_check":
            return context.get("some_field") == "expected_value"
        return super().evaluate_condition(condition, context)

Step 4: Run Your Workflow

Option 1: Command Line

python -m src.main --run my_workflow

Option 2: Python Script

from src.main import FastAntsSession

with FastAntsSession() as session:
    result = session.run_workflow("my_workflow")

Note: The workflow name (my_workflow) must match the directory name where the config file is located.


๐Ÿ”ง Configuration Reference

Main Config (src/config/config.yaml)

paths:
  project_root: "/path/to/project"  # Must be updated
  workspace_root: "${paths.project_root}/workspaces"

aider:
  model: "openai/glm-4.6"           # AI model name
  api_key: ${oc.env:OPENAI_API_KEY} # From environment variable
  api_base: ${oc.env:OPENAI_API_BASE}

workflow:
  max_turns: 6                       # Default max turns

Environment Variables

  • OPENAI_API_KEY (required): Your API key
  • OPENAI_API_BASE (optional): API endpoint (defaults to OpenAI)

๐Ÿ“Š Execution Results

Workflow execution returns a WorkflowResult object:

WorkflowResult(
    success: bool,              # Whether execution succeeded
    total_turns: int,           # Total number of turns
    agents_used: List[str],     # List of agents used
    final_content: str,         # Final content (from collab directory)
    metadata: dict              # Execution metadata (history, errors, etc.)
)

๐Ÿ› Troubleshooting

Configuration File Not Found

Ensure src/config/config.yaml exists and paths.project_root is correctly set.

API Key Error

Check that OPENAI_API_KEY is correctly set in .env file or environment variables.

Workflow Config Not Found

Ensure workflow config file is located at src/workflows/{workflow_name}/workflow.yaml.

For example, to run the hulatang workflow, the config file path should be: src/workflows/hulatang/workflow.yaml

Run command: python -m src.main --run hulatang

Agent Execution Failed

Check log files (usually in project root) for detailed error messages.


๐Ÿ—๏ธ Architecture

The framework follows a modular architecture:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         FastAntsSession                 โ”‚
โ”‚  (Keep-Alive Session Manager)           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚                โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Environment โ”‚  โ”‚   Agent     โ”‚
โ”‚  Service    โ”‚  โ”‚  Service    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
       โ”‚                โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚ WorkflowFactoryโ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚ ConfigWorkflow โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚ LangGraphEngineโ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚   LangGraph    โ”‚
       โ”‚  State Graph   โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

# Clone the repository
git clone https://github.com/sherkevin/Weaver.git
cd Weaver

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r src/requirements.txt

# Run tests (if available)
# pytest tests/

Contribution Guidelines

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“š Documentation


๐Ÿ—บ๏ธ Roadmap

  • Web UI for workflow visualization
  • More built-in workflow templates
  • Enhanced monitoring dashboard
  • Support for more LLM providers
  • Workflow versioning and rollback
  • Distributed execution support

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • LangGraph - Powerful graph-based orchestration
  • Aider - AI pair programming tool
  • LangChain - LLM application framework

โญ Star History

If you find this project useful, please consider giving it a star! โญ


About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages