Skip to main content

Multi-agent coherence and coordination for AI systems

Project description

Convergent

Coordination library for multi-agent AI systems. Agents share an intent graph, detect overlaps before building, and converge on compatible outputs — eliminating rework cycles from parallel code generation.

CI License: MIT Python 3.10+ Tests Coverage

Why This Exists

  • Problem: Parallel AI agents generating code independently produce incompatible outputs. Agent A builds User with int IDs while Agent B uses UUID. Code fails to merge. 2-3 rework cycles before anything integrates.
  • Audience: Multi-agent orchestration frameworks, distributed systems with autonomous agents, anyone running parallel AI code generation.
  • Outcome: Agents publish what they're building to a shared intent graph. Before starting work, they check for overlaps and adopt existing decisions. Compatible output on first try. Zero rework.

What It Does

  • Intent graph — Shared, append-only graph of architectural decisions. Agents publish intents (what they build, what they need) and query for overlaps
  • Structural matching — Detect when two agents plan to build the same interface based on name, kind, and tag similarity
  • Stability scoring — Evidence-weighted confidence (test passes, code commits, downstream consumers) determines which intent wins conflicts
  • Constraint enforcement — Hard requirements that must hold (type checks pass, no circular deps) validated by subprocess gates
  • Triumvirate voting — Phi-weighted consensus engine with configurable quorum (ANY, MAJORITY, UNANIMOUS)
  • Stigmergy — Trail markers that agents leave for future agents, with exponential decay (inspired by ant pheromone trails)
  • Flocking — Emergent group behavior from local rules: alignment (adopt patterns), cohesion (detect drift), separation (avoid file conflicts)
  • Zero dependencies — Pure Python, stdlib only. Optional Rust acceleration via PyO3

Quickstart

Prerequisites

  • Python 3.10+

Install

pip install convergent
# or from source:
git clone https://github.com/AreteDriver/convergent.git
cd convergent
pip install -e .

Run

from convergent import IntentResolver, PythonGraphBackend, Intent, InterfaceSpec

resolver = IntentResolver(backend=PythonGraphBackend())

# Agent A publishes what it's building
resolver.publish(Intent(
    intent_id="auth-service",
    agent_id="agent-a",
    description="JWT authentication service",
    interfaces=[
        InterfaceSpec(name="User", kind="class", tags=["auth", "model"]),
    ],
))

# Agent B checks for overlapping work before starting
overlaps = resolver.find_overlapping(Intent(
    intent_id="user-module",
    agent_id="agent-b",
    description="User management",
    interfaces=[
        InterfaceSpec(name="User", kind="class", tags=["auth", "model"]),
    ],
))
# → overlaps shows agent-a already owns the User class
# → agent-b adopts agent-a's schema instead of building its own

Usage Examples

Example 1: Persistent intent graph with SQLite

from convergent import IntentResolver, SQLiteBackend

# WAL mode, concurrent reads, persistent across restarts
resolver = IntentResolver(backend=SQLiteBackend("./intents.db"))
resolver.publish(intent)

# Inspect from CLI
# python -m convergent inspect ./intents.db --format table

Example 2: Consensus voting

from convergent import GorgonBridge, CoordinationConfig

bridge = GorgonBridge(CoordinationConfig(db_path="./coordination.db"))

# Request a vote
request_id = bridge.request_consensus(
    task_id="pr-42",
    question="Should we merge this PR?",
    context="All tests pass, adds new auth endpoint",
)

# Agents vote (phi-weighted by historical trust)
bridge.submit_agent_vote(
    request_id, "agent-1", "reviewer", "claude:sonnet",
    "approve", 0.9, "LGTM"
)

decision = bridge.evaluate(request_id)
# → DecisionOutcome.APPROVED

Example 3: Enrich agent prompts with coordination context

context = bridge.enrich_prompt(
    agent_id="agent-1",
    task_description="implement auth",
    file_paths=["src/auth.py"],
)
# → Returns stigmergy markers + flocking constraints + phi score context
# → Inject into agent's system prompt for coordination-aware generation

Architecture

Gorgon (orchestrator)
    │
    ▼
┌── Convergent ───────────────────────────────────────┐
│                                                      │
│  Coordination Protocol (Phase 3)                     │
│  ┌────────────┐  ┌───────────┐  ┌─────────┐        │
│  │ Triumvirate │  │ Stigmergy │  │Flocking │        │
│  │ (voting)    │  │ (trails)  │  │ (swarm) │        │
│  └──────┬──────┘  └─────┬─────┘  └────┬────┘        │
│         └───────┬───────┴─────────────┘              │
│                 ▼                                     │
│  Intent Graph + Intelligence (Phase 1-2)             │
│  ┌──────────────────────────────────────────┐        │
│  │ Resolver │ Contracts │ Governor │ Gates  │        │
│  └──────────────────────────────────────────┘        │
│                 ▼                                     │
│  ┌──────────────────────────────────────────┐        │
│  │ Python (memory) │ SQLite │ Rust (opt)    │        │
│  └──────────────────────────────────────────┘        │
└──────────────────────────────────────────────────────┘

Key components:

Component Purpose
IntentResolver Query the intent graph, detect overlaps, resolve conflicts
MergeGovernor Three-layer decision authority: constraints → intents → economics
Triumvirate Phi-weighted voting with configurable quorum levels
StigmergyField Trail markers with exponential decay for indirect agent communication
FlockingCoordinator Alignment, cohesion, separation rules for emergent coordination
GorgonBridge Single entry point for orchestrator integration

Testing

# Python-only (no Rust needed)
PYTHONPATH=python pytest tests/ -v

# With optional Rust acceleration
maturin develop --release && pytest tests/ -v

# Lint
ruff check python/ tests/ && ruff format --check python/ tests/

800+ tests, 99% coverage, CI green.

Roadmap

  • v1.0.0 (current): Stable API contract, published to PyPI, PEP 561 py.typed
  • v0.6.0: Pluggable signal bus (SQLite cross-process + filesystem), decision history query API
  • v0.5.0: Coordination protocol (triumvirate voting, stigmergy, flocking, signal bus)
  • v0.4.0: CLI inspector, async backend, Rust backend parity

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

convergentai-1.0.0.tar.gz (147.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

convergentai-1.0.0-py3-none-any.whl (98.7 kB view details)

Uploaded Python 3

File details

Details for the file convergentai-1.0.0.tar.gz.

File metadata

  • Download URL: convergentai-1.0.0.tar.gz
  • Upload date:
  • Size: 147.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for convergentai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 655328bd9ca09ac93b9c5d63f5d84ba10a70bc575401197a764e0971401679d1
MD5 ddd520975e6105e8f3325b7025ab5aba
BLAKE2b-256 b2452c56b74e9a87141d034ac86e50e0a218ff9733d9cd22cc709125f776455b

See more details on using hashes here.

Provenance

The following attestation bundles were made for convergentai-1.0.0.tar.gz:

Publisher: publish.yml on AreteDriver/convergent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file convergentai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: convergentai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 98.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for convergentai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d17cd47f7e59841eda94c8ee5096ec8373850824440342ce28720a8da62d177f
MD5 142a36edf4e6a2feed58fb806e0da360
BLAKE2b-256 c34965f9e9ff2165c23de89dcafc83bf2616b4d0c89b5febda0a6950655648ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for convergentai-1.0.0-py3-none-any.whl:

Publisher: publish.yml on AreteDriver/convergent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page