Skip to main content

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.

Metadata

Release files for synapse-protocol-py 0.2.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for synapse-protocol-py 0.2.10
File Size Uploaded Provenance Actions
synapse_protocol_py-0.2.10.tar.gz 233.2 kB Without provenance Details for synapse_protocol_py-0.2.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for synapse-protocol-py 0.2.10
File Interpreter ABI Platform Actions
synapse_protocol_py-0.2.10-py3-none-any.whl Python 3 none any Details for synapse_protocol_py-0.2.10-py3-none-any.whl

Total release size: 466.4 kB

Release files / synapse_protocol_py-0.2.10.tar.gz

Download URL synapse_protocol_py-0.2.10.tar.gz
Size 233.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a0c0c31e77bb29e94919735f672e86f04055340c8c6aeac650136dfa8746fb06
BLAKE2b-256 checksum
How to use checksums
ef3c8e33a1b8cbc698a8d38e4f6868977f03f1fd1813f5e2c66878300a108e8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Release files / synapse_protocol_py-0.2.10-py3-none-any.whl

Download URL synapse_protocol_py-0.2.10-py3-none-any.whl
Size 233.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc801152a88c0dc3a2f5cd72e0a8bf4ba21c57d625f9fc5fe064c6e0f555fb8a
BLAKE2b-256 checksum
How to use checksums
d14742ee42e956767c8aed337cce7d27d872e22315e7cb7e189b915a39a64c1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Security for synapse-protocol-py 0.2.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page