On this page
Protect & operate
Bound context. Control execution cost.
Distinguish context size, execution budgets and observed cost across tasks and organizational workloads.
Budget the operation you control
Provide a task and budget to a planning or compilation operation. The tool’s schema defines the relevant field: for example, ctx_plan uses budget, while another operation may use a different parameter.
Do not copy budget keys between tools without checking their schemas.
Leave room for the whole request
A context selection budget is only part of a host’s total model request. System instructions, tool definitions, conversation history, output capacity and retries also consume resources.
Your application owns the final request budget and must account for those parts.
Enforce a spending boundary
In governed execution, LeanCTX checks applicable task, project, team, organization and time-window limits before dispatch. Reserve budget atomically so parallel branches cannot each spend the same remaining allowance. Retries, fallback routes and delegated work remain inside that shared envelope.
Use soft thresholds for alerts or approval and hard limits to stop further admitted work. Reconcile provider-observed usage against the reservation when the operation completes. An unknown provider outcome is not zero spend: resolve it before releasing the allowance or attempting the same paid effect again.
Context mode does not control a model request your application makes independently. To enforce the execution budget through LeanCTX, route the supported operation through the Engine.
Separate estimates from outcomes
Record estimated cost, observed usage and actual charges distinctly. Include input, output, caching, retries and fan-out where the provider supplies the evidence. Evaluate cost per accepted outcome only against a declared acceptance test and comparable baseline; a smaller context alone does not prove better economics.
Define an operational target
Choose an observable target for the workload: maximum source bytes, a token envelope, retrieval latency, or required evidence coverage. Record the source revision, cache state and provider conditions when measuring it.
An SLO is a target your deployment measures and enforces; these docs do not promise a hosted service SLA.
Verify under pressure
Test a large source, an unavailable provider, an exhausted budget and a recovery request. Confirm that your host handles each outcome deliberately instead of silently continuing with missing evidence.
Use observability to connect those outcomes to actual delivered context.
Engine contract & references
- ctx_plan.rsrust/src/tools/ctx_plan.rsGitHub
- ctx_compile.rsrust/src/tools/ctx_compile.rsGitHub
- orchestrator.rsrust/src/core/context_kernel/orchestrator.rsGitHub
Engine concepts describe responsibilities and behavior. Exact commands, package versions and platform contracts belong to their versioned references.
Versions & compatibility