The Context SDK for AI Agents

Build context-efficient agents by default.

LeanCTX gives your agent a structured runtime for context selection, reuse, compression, recovery and measurement.

Context Primitives

Five operations. One context boundary.

Each operation maps to a fundamental context decision your agent makes before inference.

ctx.read

Read

Load files with 10 compression modes. Cached across the entire session.

ctx.search

Search

Find symbols, patterns, or meaning across the project with compact results.

ctx.shell

Shell

Run commands with 95+ output compression patterns built in.

ctx.compress

Compress

Reduce any content while preserving the operational signal.

ctx.measure

Measure

Record cost, quality, and the context path for every task execution.

Integration Depths

Start where you are. Go deeper when ready.

level 1 / attach

Zero-code

Add LeanCTX as a proxy or MCP server to any existing coding agent. No code changes required.

level 2 / wrap

Wrap calls

Route tool reads and model calls through the context boundary. One line to wrap an existing agent.

level 3 / embed

Native SDK

Build context policy directly into your agent architecture. Full control over selection and receipts.

Real Code

Context control in six lines.

agent.py
from leanctx import LeanCTX

ctx = LeanCTX(project=".")
agent = ctx.wrap(my_agent)
result = agent.run(task)
receipt = ctx.receipt()

# receipt.baseline_cost  → $0.37
# receipt.treatment_cost → $0.058
# receipt.quality        → PASS
# receipt.cost_delta     → -84.3%

Get Started

One command. Full context control.

terminal
# Install the SDK
pip install lean-ctx

# Or install the runtime directly
curl -fsSL https://leanctx.com/install | sh

# Run your first benchmark
lean-ctx evidence realworld \
  --baseline "stock" \
  --treatment "optimized"

Proof Doctrine

Don't replace your agent. Tune it.

See the evidence