Skip to main content

Audit + coordination layer for agentic teams that span vendors — one envelope log across AutoGen, CrewAI, LangGraph, smolagents, Agno, LlamaIndex, Pydantic AI, OpenAI Agents SDK, Google ADK, and Hermes

Project description

Synapse Python SDK

Phase 1 has shipped. End-to-end coordination flow works against the mock backend; Anthropic adapter is Phase 2.

Install

pip install -e .             # from this directory
# or, from the repo root:
pip install -e sdk-python

Phase 1 surface

import asyncio
from synapse import Agent
from synapse.adapters import MockAdapter
from synapse.bus import Bus
from synapse.state import StateGraph

async def main():
    bus = Bus("redis://localhost:6379/0")
    state = StateGraph("postgresql://synapse:synapse_dev@localhost:5432/synapse")
    await bus.connect()
    await state.connect()

    agent = Agent(
        id="agent_a",
        session="my_session",
        backend=MockAdapter(),
        subscribes=["auth.*"],
        scopes_owned=["auth.middleware"],
        bus=bus,
        state=state,
    )

    async with agent.lifecycle():
        intention_id, conflicts = await agent.emit_intention(
            action={"tool": "edit_file", "args": {"path": "auth/middleware.py"}},
            scope=["auth.middleware:w"],
            expected_outcome="Refactor middleware",
            blocking=True,            # wait at gate for CONFLICT signals
            gate_ms=50,               # default per spec
        )

        if conflicts:
            print("Pivot needed:", conflicts[0].suggested_resolution)
        else:
            # Do the work, then resolve
            await agent.emit_resolution(intention_id=intention_id)

asyncio.run(main())

What ships in v0.1.0a0

Module Status
synapse.messages All 8 message types as Pydantic models, Envelope.make() factory
synapse.bus Redis Streams client (publish, consumer group, inbox drain)
synapse.state Postgres state graph (agents, intentions, scope-overlap query)
synapse.state (scope matcher) Wildcard + read/write modifier semantics, fully unit-tested
synapse.agent.Agent lifecycle(), emit_intention(), emit_resolution(), drain_signals()
synapse.adapters.MockAdapter Scripted-response streaming + inject-and-continue
synapse.adapters.base InferenceAdapter Protocol + StreamHandle, Token

What lands later

Phase Adds
2 adapters.hosted.Anthropic with cached-restart injection; @agent.intention decorator
3 adapters.native.vLLM, adapters.local.Ollama
4 Coordinator integration (cost telemetry, BLOCK handling)
5 OpenAI + Gemini adapters; L3 semantic router; PIVOT support in SDK

Tests

pip install pytest pytest-asyncio
pytest tests/

39 tests, no infrastructure required (mock-only).

Module layout

synapse/
├── __init__.py
├── agent.py              Agent class + lifecycle
├── messages.py           Pydantic models for all 8 message types
├── bus.py                Redis Streams client
├── state.py              Postgres state graph + scope matcher
└── adapters/
    ├── base.py           InferenceAdapter Protocol
    └── mock.py           Mock adapter (Phase 1)

Real adapters land under adapters/{native,local,hosted}/ in their respective phases.

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

synapse_protocol_py-0.2.8.tar.gz (231.5 kB view details)

Uploaded Source

Built Distribution

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

synapse_protocol_py-0.2.8-py3-none-any.whl (232.6 kB view details)

Uploaded Python 3

File details

Details for the file synapse_protocol_py-0.2.8.tar.gz.

File metadata

  • Download URL: synapse_protocol_py-0.2.8.tar.gz
  • Upload date:
  • Size: 231.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for synapse_protocol_py-0.2.8.tar.gz
Algorithm Hash digest
SHA256 eda5d3086e9bafdc9e8c6e1efeb82071b55e007e0ca8664bada1788ad35731e8
MD5 cd51834cff50d3ee912f98cd436bb221
BLAKE2b-256 83560319d1af4b61c6721e8aada36294cd6d3d2ecd0c3e82b12166019b18eb30

See more details on using hashes here.

File details

Details for the file synapse_protocol_py-0.2.8-py3-none-any.whl.

File metadata

File hashes

Hashes for synapse_protocol_py-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 7efbae4c6c4d603c34befab86b8645630addb9a83184c3cf28b3096ab746d0f7
MD5 ec967c525c11a970336ecb2eb4b21d07
BLAKE2b-256 18ce113d5593dd61768c60d7c7ace1655b48cc2ba82be15c58d44436d739bf56

See more details on using hashes here.

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