LeanCTX SDK

Your product.Context built in.

LeanCTX is the Context Gateway for AI systems. Embed supported context selection, controls and evidence through native SDK interfaces. Keep your model, workflow and UI.

Your applicationLeanCTX SDK + EngineYour model

Inside your product

Your product experience. An Engine underneath.

Use a local Engine or an authenticated Enterprise service. The SDK speaks the same versioned contracts for context, permissions and evidence, without duplicating the Engine inside your application.

Embed context

Prepare input in your app.

Prepare sources, inspect the returned view and record the host outcome with ContextSession. Recover source detail when the task needs it.

ContextSession

Build agents

Equip your agent.

Use AgentContext for reads, search, composition and token measurements. Agent Tools can write files or run allowlisted argv commands only with explicit permissions. Your host owns model calls and agent lifecycle.

AgentContext

From code to context

A few lines. A focused context.

Start with context preparation: gather a project’s relevant material and inspect what your application receives. This example leaves the model call to your app. Agent Tools can run explicitly permitted, allowlisted commands through the Engine; they do not take over model inference.

compose()
Gather context for the task you supplied.
result.text
Inspect the prepared tool output before using it.
saved_tokens
Inspect the Engine’s measured input reduction, separately from model billing.
PythonRead-only example
from leanctx_sdk import (
    AgentContext
)

with AgentContext(
    ".",
    task="Explain project"
) as ctx:
    result = ctx.compose()
    metrics = ctx.metrics

print(result.text)
print(metrics.saved_tokens)

Requires a compatible Engine. Runs against your local project; the output depends on its files.

Language packages

Six languages. One Engine contract.

Choose the native package for your stack. Negotiate versions and capabilities with the Engine, then check the operation matrix for your language and transport.

Host control

Grant only the access your app needs.

Your app establishes the user and business context. The Engine enforces the request’s source, content and execution rules. Local sessions start read-only; writes and commands require explicit permission.

A fixed session policy
Write and execute permissions cannot expand within the existing session.
Controlled command execution
Pass an argv list. Only allowlisted executables run, under configured environment and timeout limits. Command policy is not an OS sandbox.
Failures you must handle
Protocol, integrity and permission failures stop the operation. Ambiguous write or execution failures are not retried automatically.

Connected capabilities

Stable context and tool controls. Python continuity stays in Preview.

Stable

Requests & outcomes

Prepare context or request Agent Tools actions with explicit write or execute permission. Execute only allowlisted argv commands; inspect receipts, handle typed errors and cancel an in-flight SDK session. Your host owns model calls and agent lifecycle.

Python SDK Preview

State & continuity

The Python SDK exposes workspace, checkpoint, delta and handoff operations in Preview under leanctx_sdk.preview. These local handoffs carry selected state and source references; the host owns agent launch, lifecycle and permissions. Broader agent orchestration remains Research.

SDK / OEM

Build it in. Bring it to your customers.

Choose the agreement for the components you embed and the service you deliver. SDK/OEM covers commercial integration, redistribution and third-party delivery; Enterprise covers organizational operation.

One integration. A clear agreement.

The public Engine keeps its Apache rights. Additional SDK and runtime components have their own terms. A commercial agreement defines the specific rights, delivery model and support you need.

Planning a commercial product or service?Discuss SDK / OEM licensing

Start with LeanCTX

Build with LeanCTX.

Install your language package, connect the Engine and prepare context for one real task.

Your application. Your model. Supported context controls inside.