Skip to main content


Sinapsis
sinapsis-core

Agent graphs · Template execution · Shared data semantics

sinapsis-core implements the Agent and Template runtime and owns the DataContainer and typed Packet models behind Sinapsis. This document describes the computational model and the contracts that other framework components depend on. It is not an installation guide or a catalogue of integrations.

1. Runtime model

Sinapsis separates the description of a computation from the objects that execute it and the data exchanged during execution.

flowchart TD
    D["Agent definition<br/>declarative configuration"] --> V["AgentSchema<br/>Pydantic validation and graph resolution"]
    V --> R["Agent runtime<br/>template instantiation and orchestration"]
    R --> T1["Template instance A"]
    R --> T2["Template instance B"]
    T1 -->|"DataContainer"| T2
    T2 --> O["Results / completion"]
Concept Meaning Responsibility
Agent definition User-supplied description of a computational graph. Names template nodes, selects implementations, configures attributes, and declares dependencies.
AgentSchema Validated, normalized representation of that definition. Enforces the canonical graph and configuration rules and records information derived during validation.
Agent runtime Live orchestration object created from a valid definition. Instantiates and coordinates Templates, manages execution and completion, and produces results.
Template instance Configured instance of a reusable Python computation. Performs one unit of work under the runtime's input/output and lifecycle conventions.
DataContainer / Packet Shared computation-level data model. Moves multimodal content and associated metadata between Templates.

These concepts must remain distinct: validating an Agent does not instantiate or execute it, and a runtime instance is not a substitute for its serializable definition.

2. Agent definitions and graph semantics

An Agent is a directed graph whose nodes are Template instances and whose edges express declared input dependencies. The graph describes what depends on what, rather than prescribing which Python method must call which other method.

A node declaration has several separate identities:

- template_name: DetectObjects
  class_name: ObjectDetector
  template_input: DecodeImage
  attributes:
    confidence: 0.5
Field Semantics
template_name Identifies this instance within the Agent graph. Multiple nodes may use the same Template class but must remain distinguishable as instances.
class_name Identifies the Template implementation to resolve in the installed environment.
template_input Refers to the upstream node supplying input; it is a graph edge, not a direct Python invocation.
attributes Supplies configuration for this node, validated according to its Template's typed attribute model.

The fragment illustrates the relationship; the referenced class and its attributes are examples, not built-in core implementations.

Dependency resolution

The runtime uses graph dependencies to determine valid execution order, including topological sorting. An upstream node must supply the data needed by its dependent node. Independent portions of a graph can be candidates for parallel execution; the actual scheduling strategy is a runtime concern, not a guarantee implied by configuration order.

flowchart LR
    A[Input] --> B[Preprocess]
    B --> C[Vision model]
    B --> D[Metadata extraction]
    C --> E[Postprocess]
    D --> E

The graph's textual order is not the authoritative execution order. When changing graph validation or scheduling, preserve the distinction between dependency ordering, runtime readiness, and completion: a node can exist in the graph without being ready to run, and repeated execution is possible under non-single modes.

Canonical validation

The framework has one authoritative Agent-graph builder, exposed by the stable sinapsis interface:

from sinapsis.agent import AgentSchema, generic_agent_schema_builder

agent_schema: AgentSchema = generic_agent_schema_builder(agent_definition)

Import convention: Although AgentSchema and generic_agent_schema_builder are implemented in sinapsis-core, they are exposed through the sinapsis package, which provides the stable public API.

Consumers should import from sinapsis to avoid coupling their code to internal implementation details. Internal modules within sinapsis-core may use direct imports where appropriate.

The builder returns the canonical AgentSchema. Its output may contain derived graph structures such as sorted_templates, template_mapping_dict, or sorted_templates_as_dict. These are part of the validated representation: consumers must not discard them, invent a competing schema, or coerce typed values (for example, numeric template_type values) into different representations.

Pydantic is the schema boundary, not a replacement for runtime coordination. It validates models and configuration; the Agent runtime still owns execution state, scheduling, and lifecycle transitions.

3. Template semantics

A Template wraps an individual Python computation behind the framework's configuration, lifecycle, and input/output conventions. Its implementation may use any suitable library, model, API, or ordinary Python code; the Agent interacts with it through the common Template contract.

Configuration versus instance state

Template attributes describe how a node should behave (for example, model selection or thresholds). A running Template may also hold state (for example, initialized resources, iterators, cached models, or progress across inputs). These are different concerns:

  • Attribute validation establishes the configured shape and types before or during instantiation.
  • Initialization may be eager or lazy, depending on the Template and runtime configuration.
  • Execution consumes framework data and produces framework data under the shared contract.
  • Reset, attribute updates, completion, and stopping are lifecycle operations; they should not be confused with reconstructing the Agent definition.

The framework's conventional processing boundary is one DataContainer input and one DataContainer output for a Template invocation. A container may itself hold many packets across modalities. A streaming or iterative Agent can process many such invocations over its lifetime.

Composition

A composite Template or SubAgent encapsulates a more complex computation behind a Template-level interface. This allows a parent Agent to treat a nested workflow as a reusable unit while the nested structure retains its own internal execution semantics.

Composition does not imply that every nested operation shares one process, one set of dependencies, or one scheduling policy; those are execution-environment concerns.

4. Agent execution and lifecycle

The orchestration layer resolves graph dependencies, manages Template instances, advances their execution, and tracks whether further work is available or the Agent should terminate.

A useful conceptual lifecycle is:

Agent definition
      │
      ▼
Validate / normalize graph
      │
      ▼
Resolve and create Template instances
      │     (possibly with lazy resource initialization)
      ▼
Determine ready Templates from graph and runtime state
      │
      ▼
Execute Templates / propagate DataContainers
      │
      ├── more work available ──► continue
      │
      ├── blocked / waiting ────► coordinate readiness
      │
      └── completed / stopped ──► finish execution

The runtime also supports blocking and completion signalling where needed. Those signals are control state, not extra modality data to insert into a DataContainer.

Execution modes

Mode Termination semantics Typical data behavior
Single Execute a workflow once. Produces a result for that execution.
Generator Advance through successive inputs/results until the participating Templates finish. Suitable for finite streams, datasets, or iterators.
Continuous Continue processing until explicitly stopped. Suitable for live sources; outputs are often consumed or persisted as they are produced.

The mode governs how execution progresses and ends; it does not change the Template or DataContainer contracts. The precise Python entry point and result-consumption mechanism are determined by the caller/runner.

5. DataContainer and Packet semantics

DataContainer and the typed Packet models are defined in sinapsis-core. Together they form Sinapsis's universal data transport (UDT) contract at Template boundaries. A container is a structured collection of content, not a requirement that every Template understand every modality.

DataContainer
├── container_id
├── llm_conversations[]  → LLmconversationPacket
├── images[]             → ImagePacket
├── audios[]             → AudioPacket
├── texts[]              → TextPacket
├── time_series[]        → TimeSeriesPacket
├── binary_data[]        → BinaryPacket
└── generic_data{}       → additional structured values

The collections above illustrate the core data model; exact field types and optional metadata are defined by the sinapsis-core Pydantic models.

Container versus Packet

  • A container is the unit exchanged between Template invocations. One container can carry zero, one, or many packets, including multiple modalities at once.
  • A Packet represents an individual content item plus metadata relevant to that item. Packet schemas preserve modality-specific structure instead of flattening everything into untyped dictionaries.
  • generic_data accommodates structured values without a suitable native packet type. Use typed packets when one exists, so downstream Templates retain a predictable contract.
Packet Represents Examples of modality-specific context
ImagePacket Image content, including individual video frames where appropriate. Colour space, boxes, keypoints, segmentation annotations.
AudioPacket Audio content. Sample rate, duration.
TextPacket Text content. Language or token-related information.
TimeSeriesPacket Temporal observations or forecasts. Time indexes, past/future covariates.
BinaryPacket Binary payloads. Content carried without requiring a modality-specific interpretation.

Some packet models also record provenance (for example, source or modified_by_templates) and annotations. These fields describe the individual item's history or interpretation, not the Agent's scheduling state. Preserve them when transforming a packet unless the operation explicitly changes their meaning.

Data flow is not wire serialization

DataContainer defines the logical in-memory contract. Encoding its content for network transport, streams, databases, or object storage is a separate responsibility. A serialization layer must preserve typed content and metadata; a plain JSON conversion is not automatically suitable for arbitrary binary or numerical payloads.

Likewise, the contract does not guarantee automatic cloning or merging of containers at every graph edge. Copying, mutation, fan-out, and fan-in behavior must follow the actual Template/runtime implementation rather than assumptions made by an integration.

6. Architectural boundaries and invariants

sinapsis-core owns the Agent runtime, Template contracts, and universal data transport models (DataContainer and typed Packets). The separate sinapsis distribution supplies the stable public import surface over those implementations. Serialization and remote-transport integrations may live in other packages, but the in-memory data model itself is part of sinapsis-core.

Core must remain independent of particular hosted services. Authentication, package publication, persistence, billing, remote scheduling, result streaming, and infrastructure scaling belong to surrounding components, not to the Agent graph model.

When working on the runtime, the important invariants are:

  1. One graph authority. generic_agent_schema_builder() and AgentSchema define the canonical validated Agent representation. No parallel graph validator in the API, CLI, SDK, or Management layer.
  2. Distinct graph identities. Preserve the difference between a Template's implementation class, its named graph instance, and an instantiated runtime object.
  3. Declarative edges. template_input expresses dependencies; execution order is derived from graph and runtime state, not YAML position.
  4. Typed configuration. Retain Pydantic validation and serialisation semantics, including derived fields in model_dump(mode="json").
  5. Consistent data transport. Maintain DataContainer and Packet contracts across Template boundaries; do not replace them with integration-specific interchange types.
  6. Explicit lifecycle semantics. Keep initialization, execution, blocking, completion, reset, and stopping distinct, particularly across generator and continuous modes.
  7. Stable facade. Internal refactors may change sinapsis-core, but must preserve the supported interfaces exported by sinapsis.

License

Unless otherwise noted, sinapsis-core is dual-licensed under MIT OR Apache-2.0. See LICENSE-MIT and LICENSE-APACHE in the Sinapsis Hub repository.

Metadata

Release files for sinapsis_core 1.0.0

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

Source distribution (sdist)

Source distribution for sinapsis_core 1.0.0
File Size Uploaded Provenance Actions
sinapsis_core-1.0.0.tar.gz 74.2 kB Without provenance Details for sinapsis_core-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sinapsis_core 1.0.0
File Interpreter ABI Platform Actions
sinapsis_core-1.0.0-py3-none-any.whl Python 3 none any Details for sinapsis_core-1.0.0-py3-none-any.whl

Total release size: 148.9 kB

Release files / sinapsis_core-1.0.0.tar.gz

Download URL sinapsis_core-1.0.0.tar.gz
Size 74.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9e16275806dcb14225cb296a42fc3556afca23d5b0a3a2b5c0bf4a801183e0a0
BLAKE2b-256 checksum
How to use checksums
2250b24b9fa7fb2c9ecf0bd7d7f7439dbf62f87aed985002d764ec043be272f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.17

Release files / sinapsis_core-1.0.0-py3-none-any.whl

Download URL sinapsis_core-1.0.0-py3-none-any.whl
Size 74.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1fed791b4b8c62a9985c51c579c47ffad64d22bfed2b6e75e384d093200c0a1
BLAKE2b-256 checksum
How to use checksums
e2df8052d1506c5aa16900fdb6078a2e3a34e374c6795c6a0afec22c05aeaf64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.17

Security for sinapsis_core 1.0.0

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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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