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).
Features โข Quick Start โข Documentation โข Examples โข Contributing
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.
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.
- ๐ฏ 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
- Zero-code workflow definition via YAML configuration files
- Complete decoupling of business logic from framework code
- Hot-swappable routers with Convention over Configuration support
- 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
- Persistent sessions via
FastAntsSessionto keep agents alive in memory - Intelligent agent caching to avoid redundant initialization
- Continuous workflow execution within a single session
- Powerful code editing capabilities through Aider integration
- Diff-based modifications for precise file change tracking
- Automatic Git integration with version control support
- 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
- Multi-agent collaboration following defined workflows
- Shared workspace with isolated workspaces per workflow
- Built-in collaboration guidelines ensuring consistent agent output formats
- Python 3.10+
- Git
- OpenAI API Key (or compatible API service)
# Clone the repository
git clone https://github.com/sherkevin/Weaver.git
cd Weaver
# Install dependencies
pip install -r src/requirements.txt- 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
EOFOr export them directly:
export OPENAI_API_KEY="your_api_key_here"
export OPENAI_API_BASE="https://api.openai.com/v1"- 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"# 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.mainWorkflow Config File Location: src/workflows/{workflow_name}/workflow.yaml
For example, the hulatang workflow config is located at: src/workflows/hulatang/workflow.yaml
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.pyfrom 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")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
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"๐ For detailed workflow engineering guide, see Workflow Development Guide
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.yamlDefine your workflow following the example above. Key components:
name: Unique workflow identifieragents: List of agents participating in the workflowstates: State machine definition with prompts and transitionsexit_conditions: Global conditions for workflow termination
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)Option 1: Command Line
python -m src.main --run my_workflowOption 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.
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 turnsOPENAI_API_KEY(required): Your API keyOPENAI_API_BASE(optional): API endpoint (defaults to OpenAI)
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.)
)Ensure src/config/config.yaml exists and paths.project_root is correctly set.
Check that OPENAI_API_KEY is correctly set in .env file or environment variables.
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
Check log files (usually in project root) for detailed error messages.
The framework follows a modular architecture:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FastAntsSession โ
โ (Keep-Alive Session Manager) โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโดโโโโโโโโโ
โ โ
โโโโโโโโผโโโโโโโ โโโโโโโโผโโโโโโโ
โ Environment โ โ Agent โ
โ Service โ โ Service โ
โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโ
โ โ
โโโโโโโโโฌโโโโโโโโโ
โ
โโโโโโโโโผโโโโโโโโโ
โ WorkflowFactoryโ
โโโโโโโโโฌโโโโโโโโโ
โ
โโโโโโโโโผโโโโโโโโโ
โ ConfigWorkflow โ
โโโโโโโโโฌโโโโโโโโโ
โ
โโโโโโโโโผโโโโโโโโโ
โ LangGraphEngineโ
โโโโโโโโโฌโโโโโโโโโ
โ
โโโโโโโโโผโโโโโโโโโ
โ LangGraph โ
โ State Graph โ
โโโโโโโโโโโโโโโโโโ
We welcome contributions! Please see our Contributing Guide for details.
# 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/- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Workflow Development Guide - Complete guide to writing workflow YAML files
- Workflow Development Guide (ไธญๆ) - ๅทฅไฝๆต YAML ็ผๅๅฎๆดๆๅ
- Configuration Reference
- API Documentation (Coming soon)
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
- LangGraph - Powerful graph-based orchestration
- Aider - AI pair programming tool
- LangChain - LLM application framework
If you find this project useful, please consider giving it a star! โญ
Report Bug โข Request Feature โข Documentation
