Executable contracts for multi-agent systems - deterministic coordination across frameworks and languages
Project description
AssertLang
Executable contracts for multi-agent systems. Define agent behavior once in AL, agents from different frameworks (CrewAI, LangGraph, AutoGen) execute identical logic. Deterministic coordination guaranteed.
The Problem
Multi-agent AI systems are growing fast ($5.25B → $52.62B by 2030), but agents can't reliably coordinate:
What happens today:
# Agent A (Python/CrewAI) interprets "create user"
def create_user(name, email):
if not name: # Agent A's validation
raise ValueError("Missing name")
# ... creates user
// Agent B (JavaScript/LangGraph) interprets same task differently
function createUser(name, email) {
if (name === "") // Agent B's validation (different!)
throw new Error("Name is required");
// ... creates user (differently)
}
Result: ❌ Different validation, different errors, inconsistent behavior
Existing solutions:
- MCP, A2A, ACP - Handle messaging, NOT semantic contracts
- JSON Schema - Types only, no business logic
- Natural language - Ambiguous, unreliable
- LLM interpretation - Non-deterministic
The Solution: AssertLang Contracts
Define behavior once, execute everywhere:
// user_service.al - Contract defines EXACT behavior
function createUser(name: string, email: string) -> User {
// Deterministic validation (not just types!)
if (str.length(name) < 1) {
return ValidationError("name", "Name cannot be empty");
}
if (!str.contains(email, "@")) {
return ValidationError("email", "Invalid email format");
}
// Deterministic ID generation
let id = str.length(name) + str.length(email);
return User(id, name, email, timestamp());
}
Transpile to Agent A (Python/CrewAI):
asl build user_service.al --lang python -o agent_a.py
Transpile to Agent B (JavaScript/LangGraph):
asl build user_service.al --lang javascript -o agent_b.js
Result: ✅ Both agents execute IDENTICAL logic
Proof: 100% Identical Behavior
Test Case: createUser("Alice Smith", "alice@example.com")
Agent A (Python) Output:
✓ Success: User #28: Alice Smith <alice@example.com>
Agent B (JavaScript) Output:
✓ Success: User #28: Alice Smith <alice@example.com>
Same ID, same format, same validation. See proof
🚀 Quick Start (2 Minutes)
1. Install
pip install assertlang
2. Write a contract
cat > hello_contract.al << 'EOF'
function greet(name: string) -> string {
if (str.length(name) < 1) {
return "Hello, Guest!";
}
return "Hello, " + name + "!";
}
EOF
3. Generate for your framework
# For CrewAI (Python)
asl build hello_contract.al --lang python -o crewai_agent.py
# For LangGraph (JavaScript)
asl build hello_contract.al --lang javascript -o langgraph_agent.js
# For AutoGen (Python)
asl build hello_contract.al --lang python -o autogen_agent.py
4. Use in your agent framework
CrewAI example:
from crewai import Agent
from crewai_agent import greet # Uses AL contract
agent = Agent(
role='Greeter',
goal='Greet users consistently',
backstory='I implement the AL greeting contract'
)
# Guaranteed to match other agents implementing same contract
result = greet("Alice") # "Hello, Alice!"
LangGraph example:
import { StateGraph } from "@langchain/langgraph";
import { greet } from './langgraph_agent.js'; // Uses AL contract
const greetNode = async (state) => {
// Guaranteed to match CrewAI agent behavior
return { greeting: greet(state.name) };
};
🎨 VS Code Extension
Get syntax highlighting and file icons for .al files:
Installation
Option 1: CLI (Recommended)
asl install-vscode
Option 2: Manual
cp -r .vscode/extensions/al-language ~/.vscode/extensions/assertlang.al-language
Features:
- Syntax highlighting for AL contracts
- File icons for
.alfiles - Language configuration (brackets, comments, auto-closing)
Restart VS Code after installation to activate the extension.
Why This Matters
Without AssertLang Contracts
Scenario: Two agents need to validate user input
Agent A decides:
if not name or len(name) > 100:
raise ValueError("Invalid name")
Agent B decides:
if (name.length === 0 || name.length > 50) { // Different limit!
throw new Error("Bad name"); // Different error!
}
Result:
- ❌ Inconsistent validation (100 vs 50 chars)
- ❌ Different error messages
- ❌ System unreliable
- ❌ Debugging nightmare
With AssertLang Contracts
Both agents implement:
if (str.length(name) < 1 || str.length(name) > 100) {
return ValidationError("name", "Name must be 1-100 characters");
}
Result:
- ✅ Identical validation
- ✅ Identical errors
- ✅ System reliable
- ✅ Easy to maintain
🎯 Use Cases
1. Multi-Framework Coordination
Challenge: CrewAI agent (Python) and LangGraph agent (JavaScript) need to coordinate
Solution:
# Define contract
cat > task_contract.al
# Both agents transpile from same contract
asl build task_contract.al --lang python
asl build task_contract.al --lang javascript
# Guaranteed coordination
2. Framework Migration
Challenge: Migrating from CrewAI to LangGraph without breaking behavior
Solution:
- Extract CrewAI logic to AL contract
- Transpile to LangGraph
- Verify identical behavior
- Migrate incrementally
3. Cross-Team Collaboration
Challenge: Python team and JavaScript team can't share specifications
Solution: AL contracts as shared source of truth
- One contract file
- Each team generates their language
- Behavior guaranteed identical
4. Enterprise Multi-Agent Systems
Challenge: 10+ agents in different languages need consistent business logic
Solution: AL contracts enforce consistency across all agents
Framework Support
| Framework | Language | Status | Example |
|---|---|---|---|
| CrewAI | Python | ✅ Ready | See example |
| LangGraph | JavaScript/TypeScript | ✅ Ready | See example |
| AutoGen | Python | 🟡 Coming soon | Planned Q1 2025 |
| LangChain | Python/JavaScript | 🟡 Coming soon | Planned Q1 2025 |
| Custom | Any language | ✅ Ready | Transpile to Python/JS/Go/Rust/C# |
Language Support
AL contracts transpile to:
| Language | Status | Use For |
|---|---|---|
| Python | ✅ Production | CrewAI, AutoGen, LangChain |
| JavaScript/TypeScript | ✅ Production | LangGraph, Node.js agents |
| Go | ✅ Production | High-performance agents |
| Rust | ✅ Production | Performance-critical agents |
| C# | ✅ Production | Windows/enterprise agents |
All languages:
- 100% semantic equivalence
- Deterministic behavior
- Full test coverage
How It Works
┌─────────────────────────────────────────────────┐
│ AL Contract (Source of Truth) │
│ function createUser(name, email) -> User │
└─────────────────┬───────────────────────────────┘
│
┌────────┴────────┐
│ AssertLang │
│ Transpiler │
└────────┬────────┘
│
┌─────────────┼─────────────┐
│ │ │
▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌─────────┐
│ Python │ │JavaScript│ │ Go │
│ (CrewAI)│ │(LangGraph│ │ (Custom)│
└─────────┘ └─────────┘ └─────────┘
All execute IDENTICAL logic
Under the hood:
- Parse AL contract
- Extract semantic requirements
- Generate idiomatic code for each language
- Guarantee behavioral equivalence
Contract Features
✅ Deterministic Validation
if (str.length(name) < 1) {
return ValidationError("name", "Required");
}
✅ Type Safety
function process(data: list<string>) -> map<string, int>
✅ Error Handling
try {
let result = risky_operation();
return result;
} catch (error) {
return fallback_value;
}
✅ Business Logic
let discount = price * 0.1;
if (is_premium_user) {
discount = discount * 2;
}
📊 Comparison
| Approach | Deterministic | Framework-Agnostic | Language-Agnostic | Verifiable |
|---|---|---|---|---|
| Natural Language | ❌ | ✅ | ✅ | ❌ |
| JSON Schema | ⚠️ Types only | ✅ | ✅ | ⚠️ Partial |
| MCP | ❌ | ⚠️ MCP only | ✅ | ❌ |
| LLM Interpretation | ❌ | ✅ | ✅ | ❌ |
| AssertLang Contracts | ✅ | ✅ | ✅ | ✅ |
Real-World Example
See complete working example: examples/agent_coordination/
What's included:
- User service contract (validation, creation, formatting)
- CrewAI agent (Python) implementation
- LangGraph agent (JavaScript) implementation
- Proof of identical behavior (100% match on all tests)
- Integration guides
Run it yourself:
cd examples/agent_coordination
python agent_a_crewai.py # Agent A output
node agent_b_langgraph.js # Agent B output
# Compare - they're identical!
Technical Details
Contract Language (AL)
Simple C-style syntax:
function name(param: type) -> return_type {
// Logic here
}
Full language features:
- Variables:
let x = value - Conditionals:
if,else - Loops:
for,while - Functions:
function name() {} - Classes:
class Name {} - Types:
string,int,float,bool,list,map - Error handling:
try/catch/finally
Transpilation
Command:
asl build contract.al --lang <target> -o output.file
Targets:
python- Python 3.10+javascript- ES2020+typescript- TypeScript 4.0+go- Go 1.18+rust- Rust 2021csharp- C# 10+
Output:
- Idiomatic code for target language
- Full type annotations
- Production-ready error handling
🧪 Testing
Contract testing:
# Run contract against test cases
asl test contract.al
# Verify transpiled outputs match
asl verify contract.al --langs python,javascript
Framework integration testing:
# Test CrewAI integration
pytest tests/integration/test_crewai.py
# Test LangGraph integration
npm test tests/integration/langgraph.test.js
📚 Documentation
- Quick Start Guide - Get started in 5 minutes
- Contract Syntax - AL language reference
- Framework Integrations - CrewAI, LangGraph, AutoGen guides
- Examples - Real-world contracts
- API Reference - Complete API documentation
🤝 Contributing
AssertLang is MIT licensed and community-driven.
Ways to contribute:
- Add framework integrations (AutoGen, LangChain, etc.)
- Improve documentation
- Submit example contracts
- Report bugs / request features
- Star the repo ⭐
See CONTRIBUTING.md for details.
🎯 Roadmap
Q4 2024
- ✅ Core contract language
- ✅ Python/JavaScript transpilation
- ✅ CrewAI + LangGraph proof-of-concept
Q1 2025
- AutoGen integration
- LangChain integration
- Contract validation enhancements
- VS Code extension improvements
Q2 2025
- Contract testing framework
- Additional language targets (Java, PHP)
- Cloud-hosted transpilation service
- Enterprise support
🌟 Why AssertLang?
For Multi-Agent Developers:
- Agents coordinate reliably
- No more behavior drift
- One source of truth
For Framework Authors:
- Enable cross-framework compatibility
- Reduce integration complexity
- Build on proven technology
For Enterprises:
- Consistent business logic across agents
- Easier testing and verification
- Reduced maintenance burden
📊 Stats
✅ 134/134 tests passing (100%)
✅ 5 languages supported
✅ 2 frameworks integrated (CrewAI, LangGraph)
✅ 100% identical behavior verified
✅ 350K+ lines of production transpiler code
✅ MIT licensed, open source
📝 License
MIT © AssertLang Contributors
Built with ❤️ for the multi-agent AI community.
🚀 Get Started
# Install
pip install assertlang
# Create a contract
cat > my_contract.al << 'EOF'
function hello(name: string) -> string {
return "Hello, " + name + "!";
}
EOF
# Transpile for your framework
asl build my_contract.al --lang python -o agent.py
# Run
python agent.py
Questions? Open an issue • Join discussions
Love AssertLang? ⭐ Star us on GitHub!
🔗 Links
- GitHub: github.com/AssertLang/AssertLang
- PyPI: pypi.org/project/assertlang
- Documentation: docs/
- Examples: examples/agent_coordination/
Note: AssertLang is under active development. The multi-agent contract system is production-ready, with additional framework integrations coming soon. Star the repo to follow progress!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file assertlang-0.0.2.tar.gz.
File metadata
- Download URL: assertlang-0.0.2.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a0a431449df9021f71e4490e94ba1df5fa83ebd8634edd466633b032c98efaf
|
|
| MD5 |
3c5f26867ce95587e727ac2cfdf201f5
|
|
| BLAKE2b-256 |
1364f5221f66650bdb198df1fc5b72ac6a6066f3abedf971a35a924c5c166aee
|
File details
Details for the file assertlang-0.0.2-py3-none-any.whl.
File metadata
- Download URL: assertlang-0.0.2-py3-none-any.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3866382be13520474e18d4748827bd41d957a2d96a87088dfea136087a5ddc8
|
|
| MD5 |
afd1e494ecb99e2ca1aa28bebd3e2b86
|
|
| BLAKE2b-256 |
fa722a3a477b4036bef1cc630491574683e91a28e53123d83943a31ce40d44d4
|