Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bioma_langchain-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bioma_langchain-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

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

Hashes for bioma_langchain-0.1.0.tar.gz
Algorithm Hash digest
SHA256 400a883cb246cea239dc35f2dc035fd404769f8749b49f057a718b352842b79a
MD5 f6be57779d277bc0b614ecd39ff26331
BLAKE2b-256 63a1b5ba47d91cfab711639dee37ddfc17f5691f06efea2398d5d2a5678fd059

See more details on using hashes here.

Provenance

The following attestation bundles were made for bioma_langchain-0.1.0.tar.gz:

Publisher: release.yml on jonathascordeiro20/bioma-framework

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bioma_langchain-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bioma_langchain-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ccb6343dda6f2c22d6979888fa247754a9d5d54d84e6b1d59753b2a569863ef0
MD5 28ce1b80f7ccdc63ad11d409496c6fd6
BLAKE2b-256 0877c2fbeed2432358fb0b091629506ba1b79657d1e0f35556b04957e560b25d

See more details on using hashes here.

Provenance

The following attestation bundles were made for bioma_langchain-0.1.0-py3-none-any.whl:

Publisher: release.yml on jonathascordeiro20/bioma-framework

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page