Skip to content

Releases: ENDEVSOLS/LongGuard

LongGuard v0.1.4

Choose a tag to compare

@github-actions github-actions released this 24 Sep 11:01

🚀 What's Changed in v0.1.4

🚀 Added

  • CrewAI Integration (CrewGuard & add_guard_to_crew): Added native CrewAI support in longguard.integrations.crewai. Protects multi-agent crews from delegation loops and repetitive tool calls via step_callback and 1-line add_guard_to_crew(crew).
  • Universal @guarded Decorator: Added @guarded decorator in longguard.core.decorator (exported top-level as longguard.guarded). Wraps arbitrary Python functions, SDK calls, generators, and async coroutines with circuit breaker protection in 1 line.
  • PEP 561 Typing Support (py.typed): Added src/longguard/py.typed marker file and Typing :: Typed package classifier for strict IDE and static analysis support (MyPy, Pyright, VS Code Pylance).
  • CircuitBreakerTrippedError / CircuitBreakerError: Added explicit exception classes carrying reason, report, and decision for programmatic inspection when an agent is terminated.
  • Documentation & Theme Polish: Enhanced MkDocs configuration with logo, favicon, GitHub repository icon, back-to-top navigation, tab synchronization, social footer, and new documentation guides for CrewAI and the @guarded decorator.

🔄 Changed

  • PyPI Metadata & SEO Optimization: Updated official documentation URL to https://endevsols.github.io/LongGuard/, expanded keywords to 15 high-intent discovery tags, and added Operating System :: OS Independent and Topic :: System :: Monitoring classifiers.
  • README Links: Converted relative markdown links to absolute GitHub URLs to prevent 404 errors when rendered on PyPI.
  • Expanded Test Suite: Added 16 new test cases (271 tests total, 100% passing) covering @guarded (sync, async, generators, cost limits, fallbacks) and CrewGuard (action/finish parsing, crew wrapping, callback chaining).

📦 Install / Upgrade

Defaulting to user installation because normal site-packages is not writeable
Collecting longguard
Downloading longguard-0.1.3-py3-none-any.whl.metadata (14 kB)
Collecting numpy>=1.24.0 (from longguard)
Downloading numpy-2.5.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.metadata (6.6 kB)
Downloading longguard-0.1.3-py3-none-any.whl (49 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 49.5/49.5 kB 1.9 MB/s eta 0:00:00
Downloading numpy-2.5.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (16.7 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 16.7/16.7 MB 21.0 MB/s eta 0:00:00
Installing collected packages: numpy, longguard
Successfully installed longguard-0.1.3 numpy-2.5.3

🔗 Resources

Link
📖 Documentation https://endevsols.github.io/LongGuard/
🐍 PyPI https://pypi.org/project/longguard/
🌐 EnDevSols Long Suite https://endevsols.com/open-source
🐛 Report a Bug https://github.com/ENDEVSOLS/LongGuard/issues
📜 Full Changelog https://github.com/ENDEVSOLS/LongGuard/blob/main/CHANGELOG.md

✅ Quality

  • All tests passing (ruff + mypy strict + pytest)
  • Supported: Python 3.10, 3.11, 3.12 · Ubuntu & macOS

Part of the EnDevSols Long Suite — production AI tooling for Python.

LongGuard v0.1.3

Choose a tag to compare

@github-actions github-actions released this 05 Sep 15:55

🚀 What's Changed in v0.1.3

🚀 Added

  • Raw Client Integration (OpenAI & Anthropic): Added AgentStep.from_openai_response() and AgentStep.from_anthropic_response() class methods. Enables using LongGuard directly with standard openai and anthropic SDK client loops without requiring LangGraph or LangChain.
  • Dollar Cost Tracking: Built-in pricing engine (PRICING_TABLE, compute_cost, list_supported_models) supporting 40+ major LLM models (OpenAI GPT-4o/o1/o3, Anthropic Claude 3.5/4, Gemini 1.5/2.0/2.5, LLaMA 3.1/3.3, Mistral, Cohere).
  • Budget Hard Cap (max_cost_usd): Configure hard dollar spend limits on agent runs (max_cost_usd) to immediately trip the circuit breaker and prevent runaway API bills.
  • Custom Token Pricing Overrides: Added cost_per_input_token and cost_per_output_token in GuardConfig for private/fine-tuned or unlisted models.
  • Report Persistence (save / load): Persist telemetry to disk via report.save("run.json") and restore full state using GuardReport.load("run.json"). Supports JSON natively and YAML (when pyyaml is installed).
  • Runnable Examples & Docs: Added standalone example in examples/openai_raw_guard.py and documentation in docs/integrations/raw-client.md.

🔄 Changed

  • GuardReport Telemetry: GuardReport.summary() now displays Estimated Cost: $X.XXXX USD (model) when cost tracking is configured.
  • Expanded Test Suite: Added 76 new test cases (255 tests total, 100% passing) covering SDK response parsing, pricing calculations, breaker cost limits, and report serialization.
  • Automated GitHub Releases: Enhanced GitHub Actions workflow to parse release notes directly from CHANGELOG.md and exclude internal build metadata from release assets.

📦 Install / Upgrade

pip install --upgrade longguard
# or
uv add longguard

🔗 Resources

Link
📖 Documentation https://endevsols.github.io/LongGuard/
🐍 PyPI https://pypi.org/project/longguard/
🌐 EnDevSols Long Suite https://endevsols.com/open-source
🐛 Report a Bug https://github.com/ENDEVSOLS/LongGuard/issues

✅ Quality

  • All tests passing (ruff + mypy strict + pytest)
  • Supported: Python 3.10, 3.11, 3.12 · Ubuntu & macOS

Part of the EnDevSols Long Suite — production AI tooling for Python.

Full Changelog: v0.1.1...v0.1.3

v0.1.1

Choose a tag to compare

@github-actions github-actions released this 05 Sep 08:06

🛡️ 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