Skip to content

fix(providers): report the circuit breaker as half-open once recovery is due - #1500

Merged
rohitg00 merged 1 commit into
rohitg00:mainfrom
Rex57:fix/1489-breaker-effective-state
Oct 10, 2026
Merged

rohitg00 merged 1 commit into
rohitg00:mainfrom
Rex57:fix/1489-breaker-effective-state

Conversation

@Rex57

@Rex57 Rex57 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #1489.

CircuitBreaker moves from open to half-open only inside the isAllowed getter, which runs on the next provider call. getState() returned the stored field, so while the worker was idle after a provider blip, GET /agentmemory/status kept reporting circuitBreaker.state: "open" and the error-level problem provider-circuit-open ("LLM provider calls are paused") even though the next call is allowed.

getState() now reports half-open once the recovery timeout has passed. It only computes the reported value: the stored state, counters and the isAllowed transition are unchanged, so a failure in that window reopens the breaker exactly as before.

PR #1350 edits recordSuccess in the same file; this change touches only getState, so the two do not overlap.

Checks

  • test/circuit-breaker.test.ts: still open 1 ms before the timeout, half-open at the timeout before any call; reading the state does not change the breaker (a failure then reopens it and isAllowed is false)
  • npm run build, npm run skills:gen, npm run docs:sync (no changes), npm run skills:check
  • npm test: 2596 passed, 4 skipped

Summary by CodeRabbit

  • Bug Fixes
    • Circuit-breaker status now reports half-open after the 30-second recovery timeout, even before another call is attempted. Reading this status does not change how subsequent failures are handled.

… is due

The breaker moves from open to half-open only inside isAllowed, on the next
provider call. getState returned the stored field, so an idle worker kept
reporting "open" after the recovery timeout, and status kept raising the
error-level provider-circuit-open problem for an outage that was over.
getState now reports half-open once the timeout has passed, without changing
the breaker's state or counters.

Signed-off-by: Rex57 <203883624+Rex57@users.noreply.github.com>
@vercel

vercel Bot commented Oct 8, 2026

Copy link
Copy Markdown

@Rex57 is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 45d8897d-b33f-482f-ab6a-28705ab36b5f
📥 Commits

Reviewing files that changed from the base of the PR and between 007a1a7 and d352bff.

📒 Files selected for processing (2)
  • src/providers/circuit-breaker.ts
  • test/circuit-breaker.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

getState() now reports half-open after an open circuit breaker’s recovery timeout elapses, without changing its stored state. Tests cover the timeout boundary and verify that a subsequent failure reopens the breaker.

Changes

Circuit breaker state reporting

Layer / File(s) Summary
Reported recovery state
src/providers/circuit-breaker.ts, test/circuit-breaker.test.ts
getState() reports half-open when an open breaker’s recovery timeout has elapsed. Tests verify the state at 29,999 and 30,000 ms, then confirm that a failure reopens the breaker and disallows calls.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to d352b

This change reports half-open after recovery without changing the breaker’s stored state. The separate re-arming concern predates this PR; no actionable merge-blocking regression remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: reporting the circuit breaker as half-open after the recovery timeout.
Linked Issues check ✅ Passed Issue #1489 requires a read-only half-open report after the recovery timeout. getState() now reports "half-open" when the stored state is "open" and the timeout has elapsed. It does not change t…
Out of Scope Changes check ✅ Passed The reviewed changes are limited to CircuitBreaker.getState() and focused circuit-breaker tests. The implementation and tests directly support issue #1489. No unrelated change is identified.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rohitg00
rohitg00 merged commit 091c7db into rohitg00:main Oct 10, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants