Skip to content

fix: support AGENTMEMORY_EMBEDDING_PROVIDER and xenova/transformers aliases#412

Open
AyushKar2005 wants to merge 2 commits into
rohitg00:mainfrom
AyushKar2005:fix/issue-395
Open

fix: support AGENTMEMORY_EMBEDDING_PROVIDER and xenova/transformers aliases#412
AyushKar2005 wants to merge 2 commits into
rohitg00:mainfrom
AyushKar2005:fix/issue-395

Conversation

@AyushKar2005
Copy link
Copy Markdown

@AyushKar2005 AyushKar2005 commented May 15, 2026

so i was looking at issue #395 and traced it down to detectEmbeddingProvider in config.ts. it was reading EMBEDDING_PROVIDER but the docs and startup logs all say to set AGENTMEMORY_EMBEDDING_PROVIDER — so the env var was just never being read.

also noticed that even if someone set it correctly to xenova or transformers, it would still fall through to null because the switch in index.ts only handles local. added an alias that maps both to local.

tested locally, embedding provider now correctly resolves instead of falling back to BM25-only mode.

Closes #395

Summary by CodeRabbit

  • Improvements
    • Added support for an additional override for embedding provider selection and normalized provider names for consistent behavior.
    • Improved tool discovery so the server can be configured to always expose the full tool set, even when proxying or falling back to local tooling.
  • Chores
    • Server configuration updated to allow forcing proxy behavior and preconfiguring service endpoints for local development.

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

@Adolfler 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
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

📝 Walkthrough

Walkthrough

Adds AGENTMEMORY_EMBEDDING_PROVIDER override (normalizing xenova/transformers → "local"); adds MCP server env defaults; and makes standalone MCP tools/list return the full toolset when AGENTMEMORY_TOOLS=all in proxy or local-fallback code paths.

Changes

AgentMemory runtime configuration and MCP tools

Layer / File(s) Summary
Embedding provider detection with override support
src/config.ts
detectEmbeddingProvider prefers AGENTMEMORY_EMBEDDING_PROVIDER over EMBEDDING_PROVIDER and normalizes xenova/transformers to "local" before returning.
MCP standalone tools/list override handling
src/mcp/standalone.ts
tools/list in proxy mode now returns getAllTools() when AGENTMEMORY_TOOLS=all and the remote .tools array is shorter than the full set; the local fallback also returns getAllTools() when AGENTMEMORY_TOOLS=all, otherwise the implemented subset.
MCP server env defaults
plugin/.mcp.json
Adds env block for agentmemory MCP server: AGENTMEMORY_URL, AGENTMEMORY_TOOLS, and AGENTMEMORY_FORCE_PROXY.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • rohitg00/agentmemory#283: Similar tools/list logic changes to prefer full toolset when AGENTMEMORY_TOOLS=all.
  • rohitg00/agentmemory#391: Documentation and server-side notes about AGENTMEMORY_TOOLS=all behavior and proxy vs local tool counts.
  • rohitg00/agentmemory#179: Adds new tool memory_vision_search to core tools, which affects what the "all tools" listing should include.

Poem

🐰 A rabbit hops through env and code,
Overrides set the proper mode.
Xenova, transformers — one small call,
Now “local” answers, standing tall.
Tools listed all, the server sings, hooray!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Changes to .mcp.json adding AGENTMEMORY_TOOLS and AGENTMEMORY_FORCE_PROXY are unrelated to the linked issue #395 which focuses on embedding provider configuration. Remove unrelated environment variable configuration changes from .mcp.json and standalone.ts, or provide a linked issue explaining the tools/proxy override functionality.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly matches the main changes: supporting AGENTMEMORY_EMBEDDING_PROVIDER environment variable and xenova/transformers aliases mapped to local provider.
Linked Issues check ✅ Passed The PR addresses both key requirements from issue #395: reading AGENTMEMORY_EMBEDDING_PROVIDER correctly and normalizing xenova/transformers aliases to local provider.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/config.ts (1)

185-191: ⚡ Quick win

Normalize and trim forced provider values before alias mapping.

Current matching only handles exact lowercase strings, so "Xenova" / " transformers " won’t resolve to "local".

Proposed fix
-const forced = source["AGENTMEMORY_EMBEDDING_PROVIDER"] || source["EMBEDDING_PROVIDER"];
+const forcedRaw =
+  source["AGENTMEMORY_EMBEDDING_PROVIDER"] ?? source["EMBEDDING_PROVIDER"];
+const forced = forcedRaw?.trim().toLowerCase();

 if (forced) {
-
   if (forced === "xenova" || forced === "transformers") return "local";
-  
+
   return forced;
 }
🤖 Prompt for 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.

In `@src/config.ts` around lines 185 - 191, The code reads the environment
override into the variable forced but compares it directly, so values like
"Xenova" or " transformers " don't match; normalize by trimming whitespace and
converting to lowercase (e.g., let normalized =
String(forced).trim().toLowerCase()) and use normalized for the alias checks in
the existing block that maps "xenova" or "transformers" to "local" and otherwise
returns the forced provider; ensure you still return the original
normalized/mapped value rather than the unnormalized input.
🤖 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.

Nitpick comments:
In `@src/config.ts`:
- Around line 185-191: The code reads the environment override into the variable
forced but compares it directly, so values like "Xenova" or " transformers "
don't match; normalize by trimming whitespace and converting to lowercase (e.g.,
let normalized = String(forced).trim().toLowerCase()) and use normalized for the
alias checks in the existing block that maps "xenova" or "transformers" to
"local" and otherwise returns the forced provider; ensure you still return the
original normalized/mapped value rather than the unnormalized input.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1da76421-a495-495d-be17-9e395f5832e1

📥 Commits

Reviewing files that changed from the base of the PR and between 7530339 and 1feb490.

📒 Files selected for processing (1)
  • src/config.ts

- standalone.ts: when AGENTMEMORY_TOOLS=all, override remote core list
  with getAllTools() so shim returns full tool surface
- standalone.ts: fix local fallback to return getAllTools() when
  AGENTMEMORY_TOOLS=all instead of filtering to 7 IMPLEMENTED_TOOLS
- plugin/.mcp.json: add AGENTMEMORY_URL, AGENTMEMORY_TOOLS=all,
  AGENTMEMORY_FORCE_PROXY=1 env vars
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/standalone.ts`:
- Around line 389-391: The current condition uses
process.env["AGENTMEMORY_TOOLS"] === "all" && remote.tools.length <
allTools.length which can miss cases where remote.tools has the same length but
wrong or duplicate names; change the check to validate tool names instead of
length: build a set of remote.tools names and verify that every name in allTools
is present (or that the set of names equals the set of allTools), and trigger
the override when any expected tool name is missing or mismatched; reference the
variables remote.tools, allTools and the AGENTMEMORY_TOOLS env check when
applying this replacement.
🪄 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: 9c269539-39ce-4b1d-846e-678a7b5bc770

📥 Commits

Reviewing files that changed from the base of the PR and between 1feb490 and 25d179f.

📒 Files selected for processing (2)
  • plugin/.mcp.json
  • src/mcp/standalone.ts

Comment thread src/mcp/standalone.ts
Comment on lines +389 to +391
process.env["AGENTMEMORY_TOOLS"] === "all" &&
remote.tools.length < allTools.length
) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use name-based completeness validation instead of length-only check.

With AGENTMEMORY_TOOLS=all, comparing only remote.tools.length < allTools.length can miss incomplete remote lists that happen to have equal length (e.g., duplicates or wrong tool names), so the override may not trigger.

Proposed fix
-        if (
-          process.env["AGENTMEMORY_TOOLS"] === "all" &&
-          remote.tools.length < allTools.length
-        ) {
+        if (process.env["AGENTMEMORY_TOOLS"] === "all") {
+          const allNames = new Set(allTools.map((t) => t.name));
+          const remoteNames = new Set(
+            remote.tools
+              .map((t) =>
+                typeof t === "object" && t !== null && "name" in t
+                  ? (t as { name?: unknown }).name
+                  : undefined,
+              )
+              .filter((name): name is string => typeof name === "string"),
+          );
+          const isComplete =
+            remoteNames.size === allNames.size &&
+            [...allNames].every((name) => remoteNames.has(name));
+          if (!isComplete) {
             if (debug) {
               process.stderr.write(
                 `[`@agentmemory/mcp`] tools/list: AGENTMEMORY_TOOLS=all override — returning ${allTools.length} tools instead of ${remote.tools.length} from server\n`,
               );
             }
             return { tools: allTools };
+          }
         }
🤖 Prompt for 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.

In `@src/mcp/standalone.ts` around lines 389 - 391, The current condition uses
process.env["AGENTMEMORY_TOOLS"] === "all" && remote.tools.length <
allTools.length which can miss cases where remote.tools has the same length but
wrong or duplicate names; change the check to validate tool names instead of
length: build a set of remote.tools names and verify that every name in allTools
is present (or that the set of names equals the set of allTools), and trigger
the override when any expected tool name is missing or mismatched; reference the
variables remote.tools, allTools and the AGENTMEMORY_TOOLS env check when
applying this replacement.

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.

Bug: Local embedding stuck at "none" (BM25-only) in v0.9.13 despite correct xenova config

2 participants