Bagua Intelligent Quotation: Implementing a Local Circuit Breaker for Skill Calls

Preface

When chaining multiple Agent Skills in environments like Cursor or Claude Code, a downstream skill with continuous errors or a rising error rate often drags the entire conversation into repetitive retries. While manual try/except blocks can mitigate some issues, they lack a unified state machine, logging, and recovery strategy, making it difficult for operations to identify “which skill is dragging the team down.”

Below is an introduction to the SkillHub community skill “Bagua Smart Quote” (Coordinates @user_5b2fc4e3/bagua). The store page categorizes it under business-ops with the tag requires_api_key=false. Upon installation, the package documentation and scripts actually provide a hexagram-circuit-v3 (Bagua Circuit Breaker Mechanism v3): combining rule counting with local Ollama model-assisted judgment to perform circuit breaking and degradation on the skill execution path. If you are looking for “Smart Quoting / Commercial Pricing” capabilities, please check the package contents first—the current public package does not contain implementations related to quotations, price lists, or billing interfaces.

What is this

  • Positioning: A circuit breaking and auditing auxiliary layer for Skill invocation (Rule layer + Optional LLM layer), published by user_5b2fc4e3 as a community source (community) on SkillHub.
  • Version: 1.0.0 (The package’s SKILL.md marks the hexagram-circuit-v3 documentation date as 2026-04-29).
  • Source: SkillHub page Bagua Smart Quote, API Resource Identifier https://api.skillhub.cn/user_5b2fc4e3/bagua.

As of the time of retrieval, SkillHub statistics show a rating of 100000, 1002 downloads, and 0 installs (Data is subject to the store and may change over time).

Core Features

The following are derived from the SKILL.md and scripts/hexagram_circuit_v3.py within the installation package; features not present in the package are not listed.

Circuit Breaking & State

The three-layer approach described in the package is: Rule Detection → LLM Judgment → Manual Takeover (The latter two layers require integration with your Agent workflow).

HexagramCircuitBreaker maintains the circuit breaker state for each skill_name (closed / half_open / open enums) and directly rejects execution when OPEN, returning a result with a fallback prompt.

Rule-side trigger conditions (consistent between code default parameters and SKILL.md text) include:

  • Error rate exceeds error_rate_threshold (default 0.3, i.e., 30%).
  • Consecutive failures reach failure_threshold (default 3).
  • Optional: Local LLM parses JSON and returns should_circuit_break: true.

SKILL.md also states “Timeout > 5 seconds → Degradation”; the current script’s main path primarily records execution duration. Whether to treat the 5-second timeout as a separate degradation condition depends on your local fork or subsequent versions.

Local LLM Layer

call_local_llm connects to http://localhost:11434 via the ollama client and attempts models according to a built-in priority list (e.g., qwen2.5:3b, llama3.2:3b, etc.). The LLM layer is used to assist in judging whether to trip the circuit breaker, rather than replacing the business Skill itself.

run() also supports action=ollama_status to check if local Ollama is available and list pulled models.

Logging & Recovery

  • Retains event logs in memory (get_logs), queryable for recent entries by specific skill or globally.
  • reset can clear the state and counters for a specified skill or all skills.
  • get_status returns the state along with total / failed / success call counts.

Installation & Activation

Prerequisite: SkillHub CLI

If the CLI is not installed, check or install it according to the official instructions:

command -v skillhub && skillhub --version

If not installed, use the installation script in the SkillHub documentation (Full install or --cli-only), see https://skillhub.cn/install/skillhub.md for details.

Installing this Skill

When installing, you must use --dir to point to the current Agent’s skills directory; otherwise, the default ./skills/ location may not be recognized. The common path for Cursor is ~/.cursor/skills/.

skillhub install @user_5b2fc4e3/bagua --dir ~/.cursor/skills/

You can also let the Agent follow the store page prompts to install @user_5b2fc4e3/bagua by referring to https://skillhub.cn/install/skillhub.md.

After successful installation, the directory structure resembles: ~/.cursor/skills/@user_5b2fc4e3/bagua/, containing SKILL.md and scripts/hexagram_circuit_v3.py.

Dependencies

The LLM judgment depends on local Ollama and the Python package ollama. If Ollama is not running, the rule layer still works, but auxiliary judgment when use_llm_decision=True will fail or take the failure branch.

No API Key is required in SkillHub (requires_api_key=false).

Typical Usage

Wrapping Skill Execution in Python

The invocation method provided in the package’s SKILL.md is:

from hexagram_circuit_v3 import HexagramCircuitBreaker

breaker = HexagramCircuitBreaker()
result = breaker.execute(skill_name, params)

The actual script is located at scripts/hexagram_circuit_v3.py. When using it in a project, add scripts to PYTHONPATH, or import it from the same directory, for example:

cd ~/.cursor/skills/@user_5b2fc4e3/bagua/scripts
python3 hexagram_circuit_v3.py

Running the script directly executes the built-in Ollama status check and an example execute("test-skill", {}).

Unified Entry via run()

from hexagram_circuit_v3 import run

# Check circuit breaker status
run({"skill": "my-skill", "action": "status"})

# Check Ollama
run({"action": "ollama_status"})

# Reset counter for a skill
run({"skill": "my-skill", "action": "reset"})

When passing in a real business function, use breaker.execute(skill_name, params, func=your_callable). The circuit breaker will catch exceptions around func(**params) and update the state.

Enabling in Agent Conversations

After installing to the Agent skills directory and restarting or refreshing the skill index, you can specify in the conversation that calls to the specified skill_name must first pass the Bagua Circuit Breaker rules; ensure local Ollama is running if LLM-assisted judgment is required. Specific trigger phrasing depends on how your client loads SKILL.md.

Use Cases & Notes

Who is it for

  • Teams already chaining multiple skills in the SkillHub / OpenClaw ecosystem who want a unified component for failure rate monitoring and rapid circuit breaking.
  • Those willing to run Ollama locally and accept “Rules + Small Model” for auxiliary decision-making rather than Cloud APIs.

Limitations & Pitfalls

  • Name vs. Content: The store name is “Bagua Smart Quote”, but the current package implements a circuit breaker mechanism v3 with no quotation business logic; it is recommended to read SKILL.md after installation before selecting.
  • Installation Slug: Use @user_5b2fc4e3/bagua; if you only write user_5b2fc4e3/bagua, the CLI may take the wrong download path.
  • State Persistence: Circuit breaker states and logs are kept in process memory and will be lost after the Agent or interpreter restarts. If persistence is required for production, you need to extend it yourself.
  • Half-Open State: The enum includes half_open, but the main flow primarily uses OPEN to reject execution; the half-open recovery strategy needs to be verified against your SLO by combining parameters like success_threshold.

Conclusion

“Bagua Smart Quote” is a business-ops community skill on SkillHub: it requires no API Key, and its core value lies in providing configurable circuit breaking, logging, and local Ollama-assisted judgment for Skill invocation. In case of inconsistency between the store listing name and the circuit breaker documentation in the package, the installed SKILL.md and scripts prevail.

Official Entrances:

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye