Skip to main content

LeanCTX SDK

The Context SDK for AI Agents.

Your framework runs the agent. LeanCTX manages its context path.

Select → Shape → Reuse → Recover.

Install

The final distribution is thinkery-leanctx-sdk and the import namespace is leanctx_sdk:

python -m pip install thinkery-leanctx-sdk==1.0.0

Install the supported public Engine v3.10.0 artifact described in COMPATIBILITY.md before running the SDK.

5-minute Quickstart

from pathlib import Path

from leanctx_sdk import ContextSession, ContextSource, SubprocessEngineClient

root = Path.cwd()
engine = SubprocessEngineClient()  # uses the compatible `lean-ctx` on PATH
session = ContextSession("inspect the configuration", project_root=str(root), engine=engine)
source = ContextSource("README.md", project_root=str(root))

view = session.prepare(source)
plan = session.current_plan
assert plan is not None

try:
    host_result = {"selected_context": view.require_text()}
except BaseException as error:
    session.abort(error)
    raise

receipt = session.complete(host_result, outcome="completed")
recovered = session.recover(view)

assert recovered.source_digest == view.source_digest
print(plan.plan_id, receipt.receipt_link.receipt_id)

The host owns prompts, models, tools, retries, scheduling, and result objects. The SDK owns the context lifecycle, identity, bounded degradation, receipts, and exact recovery. Deterministic local use requires no provider credential or Cloud service.

Stable v1

The only Stable Product primitives are:

  • ContextSession
  • ContextSource
  • ContextView
  • ContextPlan
  • ContextReceipt

Stable supporting errors, Engine clients, protocol records, and constants are listed in PUBLIC-SURFACE-MANIFEST.md. Stable APIs follow SemVer; see docs/SEMVER-AND-DEPRECATION.md.

Preview

Local Workspace, Checkpoint, Delta, and Handoff APIs are available from leanctx_sdk.preview. Preview APIs may change in minor releases and are not covered by the Stable v1 compatibility guarantee.

The same namespace contains the narrow Engine-backed .ctxpkg seal, seed, and SnapshotV1 migration operations.

from leanctx_sdk.preview import ContextCheckpoint, ContextWorkspace

See docs/PREVIEW.md. P8 Receipt Board, P9 Governed Optimization, Cloud, and production AutoTune are private Research and are not included.

Run the provider-free lifecycle example with python examples/preview_workspace.py from a source checkout.

Engine

LeanCTX Engine is Apache-2.0, independently useful, and remains a separate product. The dependency is one-way: SDK → Engine. See COMPATIBILITY.md for the exact supported public v3.10.0 release.

Documentation

License

LeanCTX SDK is source-available, not open source. Development, testing, CI, staging, evaluation, and proofs of concept are permitted under the included license. Commercial Production Use, OEM embedding, and commercial redistribution require a separate written agreement with Thinkery AG.

LeanCTX Engine remains an Apache-2.0 open-source product. There is no automatic future open-source conversion for the SDK.

Release files for thinkery-leanctx-sdk 1.0.0

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

Built distribution (wheel)

Table of built distributions (wheels) for thinkery-leanctx-sdk 1.0.0
File Interpreter ABI Platform
thinkery_leanctx_sdk-1.0.0-py3-none-any.whl Python 3 none any Details

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

Download URL thinkery_leanctx_sdk-1.0.0-py3-none-any.whl
Size 83.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
adfaa1b0f30f17b7fcc9e0e1b8c1822ee6389e55020b38963633c3ed2f1a2e09
BLAKE2b-256 checksum
How to use checksums
09d99c0247fb6a520c3e23beb73201d5b91178b095d1e7fce416586dd61d7cb9
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 29, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.0

1 release file

This release

1.0.0 This release

1 release file

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