Skip to content

v0.1.1

Choose a tag to compare

@github-actions github-actions released this 05 Sep 08:06
· 10 commits to main since this release

πŸ›‘οΈ LongGuard v0.1.1 β€” Initial Public Release

We are excited to introduce the initial open-source release of LongGuard β€” a lightweight, in-flight circuit breaker and reasoning loop recovery middleware designed specifically for autonomous AI agents built with LangGraph, LangChain, or custom loops.


⚑ What is LongGuard?

When autonomous LLM agents encounter ambiguous tool responses, rate limits, or unexpected hurdles, they often get stuck in destructive loops β€” calling identical tools repeatedly, oscillating between conflicting decisions, or drifting aimlessly while burning thousands of tokens.

LangGraph's built-in recursion_limit is a hard crash (GraphRecursionError) that drops user state with zero chance of recovery.

LongGuard catches loops early, injects a dynamic "Reflect & Pivot" prompt to guide the agent back on track, and only halts gracefully if recovery fails.


πŸš€ Key Features

πŸ”„ 4-State Circuit Breaker State Machine

  • CLOSED β†’ Normal agent operation; every step is monitored with sub-millisecond overhead.
  • REFLECTING β†’ Loop detected; injects recovery prompt to force course-correction.
  • HALF_OPEN β†’ Monitoring recovery step to verify the agent successfully pivoted.
  • OPEN β†’ Graceful circuit trip (kill) with complete conversation state preserved.

πŸ” 4 Autonomous Loop Detectors

  1. Tool Repeat Detector: Catches identical tool calls with duplicate parameters using SHA256 argument fingerprinting.
  2. Semantic Oscillation Detector: Detects thought cycles and conceptual loops across a rolling window using embedding variance.
  3. Dead-End Drift Detector: Flags repeated uninformative, empty, or error-laden tool observations using Jaccard similarity.
  4. Token Velocity Detector: Monitors exponential token spikes per step against dynamic rolling baselines.

πŸ”Œ Seamless Integrations

  • LangGraph 1.0+: Wrap your graph nodes in a single line of code with add_guard_to_graph().
  • LangChain: Drop-in wrapper via GuardedAgentExecutor.
  • Standalone Loops: Full control using CircuitBreaker and AgentStep in custom Python while loops.

πŸ“Š Comprehensive Telemetry

  • Detailed GuardReport tracking step latency, token consumption, detection events, and circuit breaker transitions.

πŸ“¦ Install

pip install longguard
# or
uv add longguard

# With optional extras:
pip install "longguard[langgraph]"   # For LangGraph 1.0+
pip install "longguard[langchain]"   # For LangChain
pip install "longguard[embeddings]"  # For fast local semantic embeddings

Full Changelog: https://github.com/ENDEVSOLS/LongGuard/commits/v0.1.1