Repository navigation
fix: skip summarize for noop provider behind resilient wrapper (#996) - #1001
costajohnt wants to merge 1 commit into
Conversation
The zero-LLM guard in mem::summarize checked provider.name === "noop", but the provider is always wrapped in ResilientProvider whose name is resilient(noop), so the guard never fired. Execution fell through to the noop provider's empty response and recorded a metrics failure on every invocation, inflating failureCount indefinitely in zero-LLM mode. Add an isNoop flag to MemoryProvider, set it on NoopProvider, propagate it through ResilientProvider and FallbackChainProvider, and guard summarize on it. The no_provider skip stays metrics-silent. Signed-off-by: John Costa <costajohnt@gmail.com>
|
@costajohnt is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughAdds an optional ChangesisNoop propagation and summarize guard
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant SummarizeHandler as mem::summarize handler
participant Provider as MemoryProvider (wrapped)
participant MetricsStore
Caller->>SummarizeHandler: invoke mem::summarize
SummarizeHandler->>Provider: check provider.isNoop
alt provider.isNoop is true
Provider-->>SummarizeHandler: isNoop = true
SummarizeHandler-->>Caller: success:false, error:"no_provider"
else provider.isNoop is false
Provider-->>SummarizeHandler: isNoop = false
SummarizeHandler->>Provider: run summarize
Provider-->>SummarizeHandler: summary result
SummarizeHandler->>MetricsStore: record(mem::summarize metric)
SummarizeHandler-->>Caller: success:true
end
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary
In zero-LLM mode
mem::summarizerecords a failure in the health metrics on every invocation, sofunctionMetricsformem::summarizeshows an ever-growingfailureCount(observed 1419 -> 1429 within minutes) even though skipping is the correct behavior without an LLM.One correction to the diagnosis in the issue. The
no_providerearly return itself records nothing, so it is not the skip being tallied. The real problem is that the skip guard never fires at all.createProvideralways wraps the base provider inResilientProvider, whose name isresilient(noop), so the guardif (provider.name === "noop")inregisterSummarizeFunctionis dead code. Execution falls through toNoopProvider.summarize(), which returns an empty string, and theempty_provider_responsebranch then callsmetricsStore.record("mem::summarize", latencyMs, false). That happens twice per Claude Code turn (the Stop hook posts both/agentmemory/summarizeand/agentmemory/session/end), which matches the observed growth rate.Fix
isNoopflag toMemoryProviderand set it onNoopProvider.ResilientProvidermirrors its inner provider, andFallbackChainProvideris noop only when every chain member is.provider.isNoopinstead of the name. The skip returnsno_providerbefore any metrics call, so zero-LLM invocations stay metrics-silent.No new "skipped" metrics outcome is needed. Once the guard fires, the skip path records nothing, which keeps
failureCountreserved for genuine failures.Testing
test/zero-llm-summarize-metrics.test.tscovers four cases:resilient(noop)skips withno_providerand never touches the metrics store,resilient(fallback(noop))does the same, and a real provider (bare or in a chain) is not skipped and still records success metrics. The first two fail on main (they getempty_provider_responseand a recorded failure) and pass with the fix.npm testpasses (1414 tests; the only local exceptions were 5hook-projecttests that assert on the checkout directory name and fail in any git worktree, unrelated to this change).npm run buildandnpm run skills:checkalso pass.Fixes #996
Notes for reviewers
isNoopis optional with strict=== truechecks in the wrappers, so a provider that never sets it can only fail toward "not noop" (real work still happens). Making it a required member was considered and skipped to keep the diff minimal; happy to change if you prefer the compiler-enforced version.no_providerreason.Summary by CodeRabbit
New Features
Bug Fixes
Tests