cogno-synapse
Model-transport layer for the Cogno cognitive pipeline — LLM + embedding backend protocols, Ollama + cloud backends, a single-backend factory, and a resilient fallback chain.
Named for the synapse: the junction that carries the signal between neurons. Where cogno-anima is the mind and cogno-engram is the memory, cogno-synapse is the channel the mind speaks to language/embedding models through.
Status: alpha — extracted from
cogno-anima'sllm/package; unit suite (mocked SDKs) in place.
Protocol first, implementation optional
The light, stable contract everyone shares is a set of structurally-typed Protocols (no inheritance required):
LLMBackend—async generate(system, prompt) -> (text, tokens_in, tokens_out)+ amodelattr.ToolCallingBackend(extendsLLMBackend) — addschat_with_tools(...)+supports_native_tools()for native function calling. Separate and optional, so a text-only backend (a stub, a distilled student) satisfies onlyLLMBackend.Embedder—async embed(text) -> list[float],async similarity(a, b) -> float.
The heavy concrete cloud backends are optional extras (lazy-imported SDKs) — depend on the protocol, install only the providers you use:
pip install cogno-synapse # protocols + Ollama + OpenAI-compatible HTTP + fallback (httpx only)
pip install "cogno-synapse[openai]" # + OpenAI SDK
pip install "cogno-synapse[anthropic|groq|gemini|bedrock]"
pip install "cogno-synapse[llm]" # all cloud SDKs
Backends
OllamaBackend/OllamaEmbedder (local, think=false by default so reasoning models still return direct JSON), plus OpenAIBackend, AnthropicBackend, GroqBackend, GeminiBackend, BedrockBackend — each implements LLMBackend + ToolCallingBackend. OpenAI-compatible providers (DeepSeek, Moonshot, xAI/Grok, OpenRouter, Together, Fireworks) reuse OpenAIBackend via base_url; create_backend("provider:model") instantiates one by string. Backends raise on transport/auth failure (InvalidAPIKeyError for 401/403) rather than degrading silently.
CachingEmbedder wraps any Embedder with a bounded LRU + token accounting (EmbeddingUsage). parse_tool_calls_from_text reads <TOOL_CALL> tags for the text-fallback function-calling path (and rescues FC leaks).
Resilient fallback — over cogno-homeo
FallbackBackend tries an ordered chain, first success wins, last error propagates. The loop runs on cogno-homeo's resilient_call, so you can opt into a circuit breaker, retry/backoff, and a metrics seam — with none supplied it behaves like the historical "try each once" chain:
from cogno_synapse import FallbackBackend, create_backend
from cogno_homeo import CircuitBreaker, RetryPolicy
chain = FallbackBackend(
[create_backend("openai:gpt-4o-mini"), create_backend("groq:llama-3.1-8b-instant")],
breaker=CircuitBreaker(), policy=RetryPolicy(max_retries=2), # optional
)
text, tin, tout = await chain.generate(system, prompt)
Scope
This library is transport only — it produces raw token counts but does not price them (the host does), and it carries no business model-ladder/_FALLBACK_MATRIX (also host). Resilience is delegated to cogno-homeo; cognition lives in cogno-anima.
The Cogno ecosystem
cogno-synapse is one organ of Cogno — a family of
small, composable, Apache-2.0 libraries that together form a complete
conversational-agent platform. Each library owns a single concern and stays
infra-agnostic; a host assembles them into a running agent:
The open-source libraries are the organs; the host is the body that joins
them. Our reference host — cogno-host, with its cogno-ui dashboard — is the
private product layer, but it holds no special powers: everything it does rides
on the public seams documented in each library's docs/HOST_INTEGRATION.md, so
you can assemble a body of your own.
Test
pip install -e ".[dev]" # unit tests mock every SDK — no cloud keys needed
pytest tests/unit -q
Metadata
Release files for cogno-synapse 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cogno_synapse-0.1.2.tar.gz | 34.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cogno_synapse-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 77.7 kB
Release files / cogno_synapse-0.1.2.tar.gz
| Download URL | cogno_synapse-0.1.2.tar.gz |
|---|---|
| Size | 34.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f6b3a84950aa426a73d70757a4b0934e0fe6f01a5b01ac5173d929540406974b
|
|
BLAKE2b-256 checksum How to use checksums |
3c076f619b8e162c0d6a44676c52c7a3ecde33f64271a58c22e08115ae2aa7d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.
Transparency logRelease files / cogno_synapse-0.1.2-py3-none-any.whl
| Download URL | cogno_synapse-0.1.2-py3-none-any.whl |
|---|---|
| Size | 43.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1c72e0cec858384e9e442aca18d571f02caefbc1a9a8617867f7de2b180f088a
|
|
BLAKE2b-256 checksum How to use checksums |
0c285166d6fbf26eda2782cb342140ceeb3a532d801194d9b51ee43a82e188b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.
Transparency logSecurity for cogno-synapse 0.1.2
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for cogno_synapse-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.
Transparency logA 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.