Behaviour changes (read first)
None: this is the first release of a new package. Design: #1164.
What's new
Optimizer: runs steps over an LLM request and returns the new request plus a report with the tokens before and after, per step, and whether information was lost. A step whose result is longer than its input is discarded; the caller's request is never changed.- Steps:
dedupe_context(removes a long message that is an exact copy of a later one; nothing is lost),minify_whitespace(spacing only),stable_prefix(system messages first, tool JSON in sorted key order), andtrim_tool_output(keeps the start and end of an oversized tool message; this loses the middle, so the report sayslossy=Truewhen it cuts). ExactCache: in-memory, a tenantScopeis required, the whole request is part of the key, entries expire, least-recently-used eviction, erase per scope.retryandwith_fallback: bounded attempts, doubling waits with a cap, a deadline, and an error that names the failures without their text.evaluate: runs your own cases with and without the optimizer, scores both answers with your judge, and reports input tokens saved, the quality change with a 95% interval, and every case that got worse. With fewer than 30 cases it gives no savings figure.- Threat model with 9 rows; a mutation check with 84 mutations.
Verified
- 156 tests pass and all 84 mutations are killed, both in the author's sandbox (Python 3.12) and on the VPS (Python 3.10.12).
- CI on #1183 (code) and #1198 (release): 52 checks passed on each, including
ragleap-optimizer-testson Python 3.10, 3.11 and 3.12 and the Plugin Security Scan. pip install ragleap-optimizer==0.1.0from PyPI into a clean Python 3.10 venv (withragleap-security0.1.0), then the README example ran: optimizer, cache, retry, fallback andevaluate.- The published wheel has the same sha256 as the build made before the tag and as a separate build on Python 3.12. The published sdist has the same sha256 as a fresh build of the tagged commit. It differs from the sdist built before the tag only in
CHANGELOG.md, because that earlier build was made before the release date was written into it (a mistake in our release steps, found and explained by comparing the files).
Not verified
- Any speed or token-saving number on real traffic. No benchmark has been run; the library makes no savings claim. Token counts are estimates (one token per 3 UTF-8 bytes) unless you pass your own counter.
- Message shapes other than the OpenAI-style
messageslist; several processes sharing a cache (the cache is per process). - TestPyPI: not published for 0.1.0. The PyPI provenance display for this release was not checked by us.
- No independent security review has been done. Alpha software.
Provenance
- Tag
ragleap-optimizer-v0.1.0(annotated) on merge commit8917b06a693454162adbbaaffc001fc643f71412. - Pull requests: #1183 (code), #1198 (release changelog). Release run: 41978745883. Design issue: #1164.
- Uploaded to PyPI on 2026-11-05T06:11:50.341555Z (wheel) and 2026-11-05T06:11:51.528680Z (sdist).
- Wheel
ragleap_optimizer-0.1.0-py3-none-any.whlsha256a96f4b632d63c483e1ecd1389e86d616e3a390d4dbdf6f228db35579ee042c6e - Sdist
ragleap_optimizer-0.1.0.tar.gzsha256d3aeb9710de70dc6dfb47bffdebe7848f7ac9412f033cf2ebda3989d24a6240f - Digests were read from PyPI's JSON by script, not retyped.