Skip to main content

Decision models use the independent DecisionModel / DecisionBackend / Decide API for typed probabilities, choices, scores, and refusals. See decision models. English · 简体中文

Purrcept Core: composable agent foundations for Python

Status: 0.5.0 alpha Python 3.11 through 3.14 Typed package Coverage gate: 100 percent

Why Purrcept · Quick start · Model layer · Boundaries · Documentation

Purrcept Core is a Python-native, effect-driven foundation for composable agents. Plain generator flows decide what happens next, typed Effect values describe one step, an Executor performs it, and AgentDriver advances the run.

The optional purrcept_core.models standard library adds provider-neutral conversations, prompts, function tools, streaming events, context policies, and backend conformance—without taking ownership of provider clients, credentials, persistence, or the application runtime.

The execution model

A Flow yields an Effect to an Executor; AgentDriver advances the run, model operations use the same Effects, and the Runtime owns external resources

Every yielded operation passes through one execution boundary. That gives cancellation, middleware, progress, lifecycle events, retries, approvals, and testing a precise step to act on. A model tool loop does not bypass this model: one conversation.ask() can yield Generate → InvokeTool → Generate, with every generation and tool call remaining an independent Effect.

Why Purrcept

  • Compose with ordinary Python. Use generators, yield from, conditions, loops, nested flows, return values, and normal exception handling.
  • Observe every side effect. Run and Effect identifiers, step indexes, progress, success, failure, and cancellation all cross the same driver lifecycle.
  • Keep reality at the edge. The Runtime owns provider clients, credentials, databases, scheduling, persistence, and platform policy.
  • Switch Providers without changing agent semantics. The model layer defines immutable messages, requests, responses, tools, streaming events, cache intent, and error categories.
  • Extend by composition. Extensions are ordinary Python packages and explicitly supplied objects—installing or importing a package does not silently enable it.

Quick start

Purrcept Core is currently developed from source. From a checkout:

pip install -e .

Or install the full contributor environment and run the first offline example:

uv sync --all-groups
uv run python examples/01_inline_effect.py

Define one typed Effect, compose it in a Flow, and run it through the driver:

import asyncio
from dataclasses import dataclass

from purrcept_core import (
    AgentDriver,
    AgentFlow,
    Effect,
    ExecutionContext,
    InlineExecutor,
    perform,
)


@dataclass(frozen=True, slots=True)
class Add(Effect[int]):
    left: int
    right: int

    def execute(self, context: ExecutionContext[None]) -> int:
        return self.left + self.right


def calculate() -> AgentFlow[int]:
    first = yield from perform(Add(1, 2))
    return (yield from perform(Add(first, 4)))


async def main() -> None:
    result = await AgentDriver(InlineExecutor()).run(calculate(), host=None)
    print(result)


asyncio.run(main())
7

perform() preserves the result type of Effect[T]. The Runtime owns the event loop; Core never calls asyncio.run() internally.

Add the model layer

Bind a Runtime-owned backend to a model, then let Conversation run the observable tool loop:

from purrcept_core import AgentFlow
from purrcept_core.models import Model, tool


@tool
async def search(query: str) -> list[str]:
    """Search a trusted application data source."""

    return [f"Result for {query}"]


def researcher(model: Model, question: str) -> AgentFlow[str]:
    conversation = model.conversation(
        instructions="Separate verified facts from assumptions.",
        tools=(search,),
        cache="auto",
    )
    result = yield from conversation.ask(question)
    return result.text

The concrete ModelBackend comes from a Provider package. It receives immutable, provider-neutral requests and maps them to its SDK or transport. Core supplies a deterministic Backend Conformance Kit so adapters can verify request semantics, streaming order, errors, cancellation, tool transactions, and reminder removal without making real network calls.

The separately developed purrcept_litellm package is one concrete adapter for LiteLLM Chat Completions.

Choose the boundary you need

Layer Owns Reach for it when
Effect kernel Flow, Effect, Executor, AgentDriver Any operation needs explicit orchestration, observation, or policy.
Model standard library Model, Conversation, prompts, tools, context, model events An agent needs Provider-neutral model and tool semantics.
Provider package ModelBackend, SDK mapping, transport errors A concrete model service must implement the Core protocol.
Runtime / application Clients, credentials, host resources, persistence, scheduling Real resources and product policy must be owned and enforced.

Deliberately outside Core

Core does not create event loops, background tasks, provider clients, database connections, or process-wide singletons. It does not provide platform sessions, Memory/RAG, task scheduling, durable execution, HTTP/CLI services, a global tool registry, or hidden retries and fallbacks.

Effects and handlers are normal in-process Python code. The unified execution boundary makes them observable and wrappable; it is not a sandbox or permission boundary. The Runtime must enforce authorization and decide which inputs, outputs, and errors are safe to record.

Model capabilities at a glance

  • Immutable message, content, request, response, usage, continuation, and streaming-event values.
  • PromptTemplate, composable render policies, local PromptLibrary, and deterministic PromptCompiler.
  • Transactional Conversation turns, snapshots, restore, fork, scoped reminders, dynamic ReminderSource, prompt traces, and complete-request token budgets.
  • Typed Python function tools with generated JSON Schema, argument validation, result encoding, and explicit error policy.
  • Append-only, sliding-window, and injected token-budget context policies.
  • Provider-neutral cache intent, continuation policy, structured model errors, and an offline backend conformance suite.

For the full contracts and examples, see Model standard capabilities.

Documentation

Start here

Build and extend

Reference, compatibility, and architecture decisions

Development

Purrcept Core targets Python 3.11 through 3.14, publishes py.typed, uses strict Pyright, and enforces 100% branch coverage.

uv sync --all-groups
uv run ruff check .
uv run ruff format --check .
uv run pyright
uv run pytest --cov=purrcept_core --cov-report=term-missing
uv build

Read CONTRIBUTING.md before changing a public contract. New behavior should arrive with focused tests and matching narrative documentation.

Project status

  • Current version: 0.6.0 alpha.
  • Supported Python versions: 3.11, 3.12, 3.13, and 3.14.
  • Runtime dependency: Pydantic v2, used internally by function tools without entering the public model protocol.
  • Published on PyPI as purrcept_core. See Releasing for the automated release process.

Metadata

Release files for purrcept-core 0.6.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 purrcept-core 0.6.0
File Size Uploaded Provenance
purrcept_core-0.6.0.tar.gz 240.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for purrcept-core 0.6.0
File Interpreter ABI Platform
purrcept_core-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 354.1 kB

Release files / purrcept_core-0.6.0.tar.gz

Download URL purrcept_core-0.6.0.tar.gz
Size 240.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a1b5a3581f1f95a6c7813f14284cdbe4566d1f53cb9d5ef8cacd05e0d6a80981
BLAKE2b-256 checksum
How to use checksums
2dbffea301a752a7745646c9e10aa327638c68ed3faf800fae9f5fe6baf1d0a6
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 Oct 21, 2026.

Transparency log

Release files / purrcept_core-0.6.0-py3-none-any.whl

Download URL purrcept_core-0.6.0-py3-none-any.whl
Size 113.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e29f635e88865810b63ef28f908937d65d3fff962c5867351d20521481435f5c
BLAKE2b-256 checksum
How to use checksums
6e492a672e0aef5414375c23cdbe445ccf851c82b420506e2f8fc2539a20fc1e
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 Oct 21, 2026.

Transparency log

Security for purrcept-core 0.6.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for purrcept_core-0.6.0.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 Oct 21, 2026.

Transparency log

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.

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