Repository navigation
fix(active-memory): bound timeout circuit breakers - #105316
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 26, 2026, 5:44 AM ET / 09:44 UTC. ClawSweeper reviewWhat this changesBounds Active Memory’s process-local timeout circuit-breaker map by removing cooled entries and evicting the oldest entry above 1,000 keys. Merge readiness⛔ Blocked until stronger real behavior proof is added - 7 items remain Keep open: the new capacity eviction can reopen an already-tripped breaker before its documented cooldown expires, so the patch is not ready to merge. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherActive Memory invokes a recall subagent through the plugin hook and records timeout state by agent, provider, and model. Later recall attempts consult that state to decide whether to skip work during the configured cooldown. flowchart LR
A[Plugin recall hook] --> B[Recall subagent]
B --> C[Timeout breaker state]
C --> D{Breaker open?}
D -->|yes| E[Skip recall]
D -->|no| F[Run recall]
F --> C
C --> G[Expiry and capacity cleanup]
Decision needed
Why: The existing plugin contract promises a cooldown duration, while a strict fixed-size map requires an explicit priority rule when all retained entries are live. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +12, Tests +86. Total +98 across 3 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Preserve the configured cooldown for already-tripped breakers under capacity pressure, define bounded admission for new state explicitly, add a hook-level regression, and then provide a redacted after-fix gateway trace. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: configure a one-timeout breaker, create 1,001 distinct keys within the cooldown, then query the oldest key; eviction makes it appear closed before its cooldown expires. Is this the best way to solve the issue? No: the LRU cap is a plausible memory bound but violates the existing cooldown contract; capacity admission must preserve live breaker protection or receive explicit approval as a contract change. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a901d3318474. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (15 earlier review cycles; latest 8 shown)
|
e5f35da to
5bf424d
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
This pull request has been automatically marked as stale due to inactivity. |
Co-authored-by: Peter Steinberger <[email protected]>
5bf424d to
e1afbe8
Compare
|
Merged via squash.
|
Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes an issue where Active Memory's process-local
timeoutCircuitBreakermap could grow without bound: entries were only removed when the same key was checked after cooldown or after a later success, so distinct failing agent/provider/model combinations that were never revisited stayed for the process lifetime.Why This Change Was Made
Bound the map in its current owner,
extensions/active-memory/recall-state.ts. On each timeout,recordCircuitBreakerTimeoutfirst removes all entries that have expired under the existing normalizedcircuitBreakerCooldownMs, including the current key, then refreshes the current entry's insertion order. After insertion, it evicts the oldest entry only when the existingDEFAULT_MAX_CACHE_ENTRIESlimit of 1000 is exceeded. The sole production caller inextensions/active-memory/recall.tssupplies the already configured cooldown.No configuration option, public interface, authorization boundary, or persistent storage changes. Production delta: +12 lines, justified by bounded process-local resource ownership.
User Impact
Before: Each new failing agent/provider/model combination could permanently add process state, and stale below-threshold timeout counts could survive their cooldown.
After: Expired timeout counts and peer entries honor the configured cooldown, distinct agent/provider/model circuit breakers remain isolated, and remaining process-local breaker state has a hard cap of 1000 keys.
Evidence
97196164358dd9b58bd6d2207ccfcd219a2492ade1afbe815b71631c948ce3c95cd9f4b91e58c12aOPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs \ extensions/active-memory/recall-state.test.ts \ extensions/active-memory/index.test.ts \ -t 'active-memory timeout circuit breakers|skips recall after consecutive timeouts when circuit breaker trips|resets circuit breaker after a successful recall'Contributor's historical live Gateway proof
The original contributor also exercised the real gateway path while developing this PR; this historical proof demonstrates the reachable timeout and circuit-breaker behavior, while the exact-head regression above proves the corrected current owner, expiry, capacity, ordering, and recovery.
Environment tested: Windows, Node v24.18.0, real gateway child process with
plugins.slots.memory=memory-coreandplugins.entries.active-memoryenabled; webchat Control UI client; hanging recall provider; fail-fast main provider.am0,am1, andam2,timeoutMs=800,circuitBreakerMaxTimeouts=1,circuitBreakerCooldownMs=600000, and logging enabled.chat.sendfor each agent to produce distinct timeout keys.am0within its cooldown.Observed historical result: Three distinct timeout records and one same-agent circuit-breaker skip; the gateway loaded both
active-memoryandmemory-core.Not tested: A multi-hour live-gateway 1000-key soak. The exact-head owner regression directly covers capacity eviction, cooldown expiry, ordering, isolation, and the registered plugin timeout/recovery flow.