Context P&L
A command-line tool and GitHub Action that price each component of an agent's context: quality gained per 1,000 tokens, with confidence intervals and a CI gate.
- Status
- Design (not built)as of
- Claim
No measured result yet.
What will be measured. On two open-source agents: the share of always-loaded context tokens whose marginal value cannot be told apart from zero, and what those tokens cost per 1,000 sessions. Each figure will carry a paired-bootstrap 95% interval, a run date and a pinned model snapshot. If the effects sit inside the intervals, this page will lead with the interval instead.
- Run it
Not runnable yet.
How it works
- Declare
List the context as components in a config file: system-prompt sections,
SKILL.mdbundles, tool schemas, retrieved chunks, memory, few-shot examples. - Ablate
Run an eval suite with each component left out in turn, plus sampled Shapley.
- Attribute
Give each component its change in quality, cost and latency.
- Price
Price tokens by prefix position, cache hit rate and cache lifetime, using the providers' price pages on a stamped date.
- Bound
Put a paired-bootstrap 95% interval on every figure.
- Report
Write a profit-and-loss table, a JSON file, a README badge and a pull-request comment. The gate flags a pull request that adds a component with no positive value.
Quality comes from programmatic checks, or from a pinned judge whose model family differs from the system under test. Leave-one-out is reported as the baseline beside Shapley. Each ledger row records the model snapshot ID, the temperature and the run date, and no reported number comes from a model alias.
Built on
Prior art
- ProCut: LLM Prompt Compression via Attribution Estimation. LinkedIn, 2025. Estimates how much each prompt segment contributes to task performance and prunes the low-impact ones. The closest published method.
- Data Shapley: Equitable Valuation of Data for Machine Learning. 2019. Scores each training example's contribution to a model. The same attribution idea, applied here to context components.
- Context Rot: How Increasing Input Tokens Impacts LLM Performance. Chroma, July 2025. Reliability declines as input length grows, even on simple tasks.
- Effective context engineering for AI agents. Anthropic, September 2025. Agents work best on a tight, chosen set of information.
- Context Engineering for AI Agents: Lessons from Building Manus. July 2025. Treats cache hit rate as a production metric, which is why the cost model is cache-aware.
- Control the Harness, Control the Cost. September 2026. A router that moves work between models only where prompt caches are not disrupted.
- Quantifying Language Models' Sensitivity to Spurious Features in Prompt Design. 2023. Prompt formatting alone moved accuracy by up to 76 points on one model, which is why intervals are mandatory here.
Closest existing tools
- tokenscope. A token-aware directory explorer for LLMs, by its own package summary.
Overlap
Attributing value to parts of a prompt is not new: ProCut already does it, and token-aware tooling exists. What this design adds is an interval on every figure, cache-aware pricing, and a pull-request gate.
Every link in this section was opened on 11 November 2026.
Main risk
At an affordable eval budget, most components may be indistinguishable from noise. If that happens, the result is the interval you need before pruning anything, and Shapley drops out of the claim.
Skills this project is designed to show
Context engineering, Evaluation frameworks, Agent skills, Cost optimization.
Links
No public repository yet. It will be linked here when one exists.