Skip to main content

CLM — Cognitive Load Manager

Real-time metacognitive middleware for LLM agents. Detects when your agent is cognitively overloaded and intervenes before it hallucinates, drifts, or crashes.

Installation

# Lightweight install (numpy only, ~10MB)
pip install clm-plugin

# Full install with embedding support (~1.5GB)
pip install clm-plugin[embed]

Quickstart

from clm import CLM

clm = CLM(verbose=True)

# In your agent loop, add one line:
result = clm.observe_raw(llm_output)

if result.action == "interrupt":
    # CLM detected cognitive overload
    prompt = f"Clarification needed: {result.clarification}"
elif result.action == "patch":
    # Use compressed context in next call
    context = result.context

What it monitors

CLM tracks 4 cognitive signals:

  • Branching — too many tasks in flight
  • Repetition — agent going in circles
  • Uncertainty — excessive hedging language
  • Goal drift — wandering from original intent

Combines these into a CLM score (0–100) and acts:

Zone Score Action
Green 0–40 Pass through
Amber 40–70 Compress task branches, patch context
Red 70–100 Full compression + goal re-anchor

Configuration

from clm import CLM, CLMConfig

config = CLMConfig(
    weights=[0.30, 0.25, 0.25, 0.20],  # [branching, repetition, uncertainty, goal_distance]
    green_max=40.0,
    amber_max=70.0,
    no_embed=False,  # Auto-set to True if sentence-transformers not installed
)

clm = CLM(config, verbose=True)

Adapters

LangChain

from clm.adapters import CLMCallbackHandler

handler = CLMCallbackHandler(verbose=True)
agent.run("your task", callbacks=[handler])

Loop Decorator

from clm.adapters import CLMLoop

loop = CLMLoop(verbose=True)

@loop
def agent_step(prompt: str) -> str:
    return openai_client.chat(prompt)

Observability

clm.get_score()       # Current CLM score (0–100)
clm.get_zone()        # "Green" | "Amber" | "Red"
clm.get_history()     # Step-by-step intervention log
clm.summary()         # Session statistics

Links

License

MIT

Metadata

Release files for clm-plugin 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clm-plugin 0.1.3
File Size Uploaded Provenance
clm_plugin-0.1.3.tar.gz 47.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for clm-plugin 0.1.3
File Interpreter ABI Platform
clm_plugin-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 79.9 kB

Release files / clm_plugin-0.1.3.tar.gz

Download URL clm_plugin-0.1.3.tar.gz
Size 47.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e8bb987a0838a93bc94940352c5386f91e975c96e81aa13053cd8397813d98a3
BLAKE2b-256 checksum
How to use checksums
4e82924f87fb2877c87f3514a7fa050af3335687e1d2a6a6d265fdf8eca6cd1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Release files / clm_plugin-0.1.3-py3-none-any.whl

Download URL clm_plugin-0.1.3-py3-none-any.whl
Size 32.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
515d8457c869e1a72f5d2bdafd66cd016175f44452b5e053548a12421af356f3
BLAKE2b-256 checksum
How to use checksums
29e30d0655c8ef19dba0d649eed0d3ffae05cda859c93fdc33cd4c4922fa17bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Security for clm-plugin 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page