Context apoptosis for LangChain: µs-scale, class-aware history pruning (B.I.O.M.A. kernel) as a drop-in Runnable.
Project description
bioma-langchain
Context apoptosis for LangChain: prune stale, low-value history with the B.I.O.M.A. Rust kernel (~1 µs decision) before messages reach the model.
Custom LangChain agents that resend a growing history are exactly where the kernel measured −84% input tokens (and up to −97.6% on bloated sessions) with answer quality at parity — see the repo's honest benchmark report, including where it does not help.
Install
pip install bioma-langchain
Use
from bioma_langchain import BiomaDehydrator
from langchain_core.messages import HumanMessage
dehydrator = BiomaDehydrator() # tool-calling default: safe_threshold=0.2
# LCEL — drop it right before the model:
chain = dehydrator | llm
# or call it directly:
lean_history = dehydrator.invoke(messages)
print(dehydrator.last_audit) # tokens_before/after, reduction, µs
Durable values must be marked to survive forever (the usage contract):
HumanMessage("The rollback token is RBK-5521.",
additional_kwargs={"bioma": "fact"})
Class mapping
| LangChain message | Kernel class | Behavior |
|---|---|---|
SystemMessage |
SYSTEM |
never purged |
additional_kwargs={"bioma": "fact"} |
FACT |
never purged |
HumanMessage / AIMessage |
USER/ASSISTANT |
decay by recency |
ToolMessage, tool-call-only AIMessage |
TOOL |
dehydrates first |
Declared limit: an old, untagged value decays below the threshold and is
purged by design — tag durable info as fact.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bioma_langchain-0.1.0.tar.gz.
File metadata
- Download URL: bioma_langchain-0.1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
400a883cb246cea239dc35f2dc035fd404769f8749b49f057a718b352842b79a
|
|
| MD5 |
f6be57779d277bc0b614ecd39ff26331
|
|
| BLAKE2b-256 |
63a1b5ba47d91cfab711639dee37ddfc17f5691f06efea2398d5d2a5678fd059
|
Provenance
The following attestation bundles were made for bioma_langchain-0.1.0.tar.gz:
Publisher:
release.yml on jonathascordeiro20/bioma-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bioma_langchain-0.1.0.tar.gz -
Subject digest:
400a883cb246cea239dc35f2dc035fd404769f8749b49f057a718b352842b79a - Sigstore transparency entry: 2190914067
- Sigstore integration time:
-
Permalink:
jonathascordeiro20/bioma-framework@80906ad5aadb4d516ff0783aa08b6f3002715f35 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jonathascordeiro20
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@80906ad5aadb4d516ff0783aa08b6f3002715f35 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file bioma_langchain-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bioma_langchain-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccb6343dda6f2c22d6979888fa247754a9d5d54d84e6b1d59753b2a569863ef0
|
|
| MD5 |
28ce1b80f7ccdc63ad11d409496c6fd6
|
|
| BLAKE2b-256 |
0877c2fbeed2432358fb0b091629506ba1b79657d1e0f35556b04957e560b25d
|
Provenance
The following attestation bundles were made for bioma_langchain-0.1.0-py3-none-any.whl:
Publisher:
release.yml on jonathascordeiro20/bioma-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bioma_langchain-0.1.0-py3-none-any.whl -
Subject digest:
ccb6343dda6f2c22d6979888fa247754a9d5d54d84e6b1d59753b2a569863ef0 - Sigstore transparency entry: 2190914231
- Sigstore integration time:
-
Permalink:
jonathascordeiro20/bioma-framework@80906ad5aadb4d516ff0783aa08b6f3002715f35 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jonathascordeiro20
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@80906ad5aadb4d516ff0783aa08b6f3002715f35 -
Trigger Event:
workflow_dispatch
-
Statement type: