feat(mcp): add AGENTMEMORY_DISABLE_LOCAL_FALLBACK to fail loud on outage#838
feat(mcp): add AGENTMEMORY_DISABLE_LOCAL_FALLBACK to fail loud on outage#838MarvinFS wants to merge 2 commits into
Conversation
|
@MarvinFS 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 (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds ChangesDisable Local Fallback on Proxy Unavailability
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant MCPClient
participant standaloneHandlers
participant restProxy
participant RemoteServer
participant InMemoryKV
MCPClient->>standaloneHandlers: request tool call or tool list
standaloneHandlers->>restProxy: resolve or invoke remote operation
restProxy->>RemoteServer: probe or proxy request
RemoteServer-->>restProxy: error or unexpected response
restProxy-->>standaloneHandlers: throw proxy error
standaloneHandlers-->>MCPClient: reject request
standaloneHandlers--xInMemoryKV: do not use local fallback
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/mcp/rest-proxy.ts`:
- Around line 174-178: The probe() path logs “falling back to local InMemoryKV”
even when disableLocalFallback() is true, which is misleading; update the
probe() implementation (the probe function and its failure handling) to check
disableLocalFallback() before emitting any “falling back” message and instead
log a clear error/throw when local fallback is disabled (matching the existing
throw branch that uses disableLocalFallback()); essentially, gate the fallback
log behind !disableLocalFallback() (or replace it with a different log/throw) so
the message is only emitted when an actual local fallback will occur.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0a11120d-fb9f-44ee-81e3-8da77b109c9a
📒 Files selected for processing (3)
src/mcp/rest-proxy.tssrc/mcp/standalone.tstest/mcp-standalone-proxy.test.ts
8e0aef6 to
ebc5bad
Compare
|
Gentle ping on this one too. Still merges cleanly against current main, and it is opt-in / off by default. Setting |
By default the standalone shim silently switches to the local InMemoryKV / ~/.agentmemory/standalone.json store when the configured server is unreachable or a proxy call fails. For clients that treat a remote agentmemory server as the single source of truth, that masks an outage and lets writes diverge into a local store the user never sees. Add an opt-in AGENTMEMORY_DISABLE_LOCAL_FALLBACK env flag (off by default, so existing behaviour is unchanged). When set, every silent-fallback path throws instead: probe-failure handle resolution, the proxy-call-failure catch in handleToolCall, and the tools/list unexpected-shape and proxy-failure paths. AGENTMEMORY_FORCE_PROXY only skips the startup probe; a mid-session proxy failure still fell back. This closes that gap for callers that opt in. Signed-off-by: MarvinFS <7998636+MarvinFS@users.noreply.github.com>
With AGENTMEMORY_DISABLE_LOCAL_FALLBACK set, a failed livez probe throws instead of switching to InMemoryKV, so the "falling back to local InMemoryKV" line misstated what happens during an outage. Derive the suffix from disableLocalFallback() so the log reads "local fallback disabled (request will fail)" in that mode. Signed-off-by: MarvinFS <7998636+MarvinFS@users.noreply.github.com>
ebc5bad to
d5bca24
Compare
By default the standalone shim silently switches to the local InMemoryKV /
~/.agentmemory/standalone.jsonstore when the configured server is unreachable or a proxy call fails. For deployments that treat a remote agentmemory server as the single source of truth, that masks an outage and lets writes diverge into a local store the operator never sees.This adds an opt-in
AGENTMEMORY_DISABLE_LOCAL_FALLBACKflag (off by default — existing behaviour is unchanged). When set, every silent-fallback path throws instead:resolveHandle)handleToolCalltools/listunexpected-shape and proxy-failure pathsAGENTMEMORY_FORCE_PROXYonly skips the startup probe; a mid-session proxy failure still fell back. This closes that gap for callers that opt in.Tests
Four cases in
test/mcp-standalone-proxy.test.ts: proxy-failure throw (asserting no local write), the probe-failure throw,tools/listthrow on unexpected remote shape, and a regression guard that the unset flag still falls back.Summary by CodeRabbit
New Features
Behavior Changes / Bug Fixes
Tests