agentmemory icon indicating copy to clipboard operation
agentmemory copied to clipboard

Circuit breaker stays "open" in status after the recovery timeout, so status reports an outage that is over

Open Rex57 opened this issue 1 month ago • 0 comments

Current-main boundary

On main 007a1a7 (0.9.30), CircuitBreaker moves from open to half-open only inside the isAllowed getter, which runs on the next provider call. getState() returns the stored field. While the worker is idle after an outage, status keeps reporting circuitBreaker.state: "open" and raises the error-level problem provider-circuit-open ("LLM provider calls are paused"), although the next call is allowed.

Reproduction and results

const b = new CircuitBreaker({ failureThreshold: 3, recoveryTimeoutMs: 50 });
b.recordFailure(); b.recordFailure(); b.recordFailure();
await new Promise((r) => setTimeout(r, 80));
b.getState().state; // "open"
b.isAllowed;        // true
b.getState().state; // "half-open"

Status reads getState() and so turns red after a provider blip that has already passed, until some background job makes an LLM call.

Required behavior

getState() reports half-open once the recovery timeout has elapsed, without changing the breaker's state or counters. isAllowed and the transition logic stay as they are.

Acceptance checks

A unit test: three failures, wait past the recovery timeout, getState().state === "half-open" before any isAllowed call; a failure then reopens it as today.

Source and existing work

isAllowed transition, getState, status problem.

PR #1350 changes recordSuccess in the same file (failure counter reset); this issue only concerns the reported state.

Environment: agentmemory 0.9.30, Node v26.10.0, macOS 27.0.1 (arm64).

Rex57 avatar Oct 08 '26 06:10 Rex57