Skip to main content

🧩 composables

Familiar patterns. Beautiful types. Better code.

Your next abstraction might already have a name.

Zero runtime dependencies. Every notion uses only the Python standard library.

A growing catalog of notions: recurring patterns expressed through precise Python types. Give your code a shared vocabulary that makes intent easier to read, implementations easier to compose, and changes easier to check.

Notion The pattern
Agent An ongoing exchange of observations and actions.
Policy A stream of actions from an initial observation.
Environment A factory, a live session, a typed transition.
Configurable Construction from a typed configuration.

Agent

Give every interaction a clear contract.

Agent[State, Action] names both sides of an interaction. Yield actions, receive new observations through asend, and let the types describe the exchange before anyone reads the implementation.

interact(observation: State) → AsyncGenerator[Action, State]

The agent holds static configuration. Each call owns its interaction state and actions; concurrent calls on the same agent must remain independent.

Explore the Agent notion →

Policy

Turn an intention into a typed stream of actions.

Policy[State, Action] gives action generation a reusable shape. Start with an observation and produce an asynchronous action stream, with the input and output types visible at the boundary.

run(observation: State) → AsyncIterator[Action]

The policy holds static configuration. Each run owns its execution state and actions; concurrent runs on the same policy must remain independent.

Explore the Policy notion →

Environment

Make the world your code acts on explicit.

Environment[State, Action, Reward, Context] pairs a reusable factory with EnvironmentSession[State, Action, Reward, Context]. The types name what an action changes, what it earns, and what comes back with the result.

await session() → EnvironmentSession[State, Action, Reward, Context]
await __aenter__() → State
await step(action: Action) → tuple[State, Reward, Terminated, Truncated, Context]

The environment is stateless. Await environment.session() to create a session. Each session owns its interaction state and uses async with to scope resource acquisition and cleanup through its asynchronous __aenter__ and __aexit__ methods. Entering a session returns its initial state. Keep the session object to call session.step(action) and await its transition result.

session = await environment.session()
async with session as initial_state:
    transition = await session.step(action)

Two distinct boolean types give episode endings their own meaning:

Type What it tells you
Terminated The episode reached a terminal state.
Truncated An external limit ended the episode.

Explore the Environment notion → · Episode types

Configurable

Give construction the same clarity as behavior.

Configurable[Configuration] binds a component to a configuration type you choose. Its factory accepts that type and returns Self, preserving the concrete subclass in the type contract.

from_configuration(configuration: Configuration) → Self

A shared construction pattern makes configuration requirements visible across implementations.

Explore the Configurable notion →

Release files for composables 0.5.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 composables 0.5.0
File Size Uploaded
composables-0.5.0.tar.gz 4.3 kB Details

Built distribution (wheel)

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

Total release size: 11.9 kB

Release files / composables-0.5.0.tar.gz

Download URL composables-0.5.0.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8abc388198fd5579cf3ddfa8df307758695ee40bb88a442ec1a2d1b63b9c5697
BLAKE2b-256 checksum
How to use checksums
bb01dbdded4d552f28e49726de018b9a7363ab6f0b001819093cf664b1f662b8
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 Sep 13, 2026.

Transparency log

Release files / composables-0.5.0-py3-none-any.whl

Download URL composables-0.5.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a08ba6d276c33698d59bf98604bbba4421d6ae559152cbc8fb5d06910f16089
BLAKE2b-256 checksum
How to use checksums
817e8d0f30caaf61143a477ded47fabd8c09bf696f9954c13073f536f2e383c5
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 Sep 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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