Skip to content

feat(tools): reset_circuit_breaker tool — let the caller clear an open breaker instead of waiting out recovery_timeout #115

Open

Description

@andrewbartels1

Problem

When a tool fails repeatedly, CircuitBreakerAdapter (adapters/circuit_breaker.py) trips that operation's per-op bucket (_BreakerBucket; 5 failures → OPEN) and rejects every later call with Circuit breaker is open for <tool> until recovery_timeout (60 s) elapses. See runbook item #4 in CLAUDE.md.

In Claude sessions this is often a pure wait. The LLM has already stopped retrying and fixed the cause, for example a wrong argument, a dismissed SolidWorks dialog, or a reopened document. It still can't make the next call for up to a minute, and the only workaround is a server restart.

Proposed solution

Add a reset_circuit_breaker MCP tool:

  • Input: operation: str | None = None. Pass a name to reset one bucket, or None to reset all buckets plus the legacy/default bucket used by connect().
  • Reset means state=CLOSED, failure_count=0, half_open_calls=0.
  • Return the state before and after for each affected bucket (name, state, failure_count, seconds since the last failure). The caller can then see what was open.
  • Add a read-only companion, get_circuit_breaker_status (or include it in the same tool with dry_run). It lists the buckets that are open or half-open, so the LLM can tell it's blocked by the breaker and not by SolidWorks.
  • Go through the adapter abstraction:
    • Add reset_circuit_breaker / get_circuit_breaker_status to base.py as no-op defaults. They report "no circuit breaker in this adapter chain".
    • Implement them in circuit_breaker.py.
    • Delegate through connection_pool.py, which may wrap the breaker.
  • The reset tool must never be blocked by a breaker itself: no breaker bucket for this operation.

Acceptance criteria

  • After a breaker trips for operation X, reset_circuit_breaker(operation="X") lets the next X call through immediately, without waiting for recovery_timeout
  • reset_circuit_breaker() with no argument clears every bucket
  • Resetting an unknown or closed operation succeeds and reports no change
  • Status and reset work through the server's real adapter wrapping (pool → breaker → pywin32/mock)
  • Unit tests in mock mode, plus a live test that trips a breaker with a deliberately failing call against real SolidWorks, resets it, and confirms the next call reaches SW
  • CLAUDE.md runbook feat(adapter): implement sweep and loft COM operations in pywin32_adapter #4 and the tool catalog updated to mention the tool

Notes

Queued as item 5 after #106, #101, #98 and #105 (2026-10-13).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions