Skip to content

fix(consolidation): default ON when LLM provider is configured (#612)#696

Merged
rohitg00 merged 2 commits into
mainfrom
fix/consolidation-default-on
May 28, 2026
Merged

fix(consolidation): default ON when LLM provider is configured (#612)#696
rohitg00 merged 2 commits into
mainfrom
fix/consolidation-default-on

Conversation

@rohitg00
Copy link
Copy Markdown
Owner

@rohitg00 rohitg00 commented May 28, 2026

Summary

Users with an LLM provider configured (Anthropic / OpenAI / OpenAI-compatible local endpoint via OPENAI_BASE_URL / OpenRouter / Gemini / Minimax / agent-sdk) were silently getting zero graph nodes, lessons, and crystals because CONSOLIDATION_ENABLED defaulted to false. The auto-consolidate pipeline only fires when the flag is true, so 100+ session corpora sat unprocessed unless the user knew to flip the flag manually.

Reported in discussion #612:

I am running this local, have over 100 sessions but still no graph nodes, lessons, crystals. I thought today's update might resolve issues so I did a fresh install - still broken. […] I got an openai compatible URL from Open WebUI and connected my local model. Served through vllm and it handles all compression / summarization perfectly fine.

Compression worked (it's wired via PostToolUse and only needs the provider). Consolidation didn't fire (gated behind the flag). Classic DX landmine pattern flagged in the feature-flag-visibility lesson — disabled-by-default LLM features that produce empty tabs.

Changes

  • src/config.tsisConsolidationEnabled() now treats unset as "on when a non-noop LLM provider is detectable from env". Detection: any of ANTHROPIC_API_KEY / OPENAI_API_KEY / OPENROUTER_API_KEY / GEMINI_API_KEY / GOOGLE_API_KEY / MINIMAX_API_KEY / OPENAI_BASE_URL is set, or AGENTMEMORY_PROVIDER=agent-sdk. Explicit =false / =0 / AGENTMEMORY_PROVIDER=noop still wins.
  • src/functions/consolidation-pipeline.ts — skip-reason text updated from generic "CONSOLIDATION_ENABLED is not set to true" to point users at the env vars they should set.
  • README.md — updated both occurrences of CONSOLIDATION_ENABLED=true so docs reflect the new default.
  • test/consolidation-default.test.ts — 8 new tests covering: no-provider default-off, each supported provider default-on, explicit =false override, explicit =true override, AGENTMEMORY_PROVIDER=noop wins over API-key presence.

Behavior matrix

Env Old default New default
nothing set off off (BM25-only)
ANTHROPIC_API_KEY=… (or any provider key) off on
OPENAI_BASE_URL=… (local OpenAI-compatible) off on
AGENTMEMORY_PROVIDER=agent-sdk off on
AGENTMEMORY_PROVIDER=noop off off
CONSOLIDATION_ENABLED=false off off
CONSOLIDATION_ENABLED=true on on

Test plan

  • npx vitest run test/consolidation-default.test.ts — 8/8 pass
  • npx vitest run test/env-loader.test.ts test/consolidation-pipeline.test.ts — both green (existing assertions still hold)
  • npx vitest run — 1276/1276 pass (integration.test.ts skipped, needs running server, pre-existing)
  • npm run build clean

Closes #612.

Summary by CodeRabbit

  • Documentation
    • Clarified configuration: consolidation is enabled by default when an LLM provider is configured, can be explicitly toggled with CONSOLIDATION_ENABLED (true/false or 1/0), and graph extraction is controlled separately via GRAPH_EXTRACTION_ENABLED.
  • Tests
    • Added comprehensive tests covering consolidation defaults and explicit overrides across various environment configurations.

Review Change Stack

Users with a provider configured (Anthropic / OpenAI / OpenAI-compatible
local endpoint via OPENAI_BASE_URL / OpenRouter / Gemini / Minimax /
agent-sdk) were silently getting zero graph nodes, lessons, and
crystals because CONSOLIDATION_ENABLED defaulted to false. The
auto-consolidate pipeline only fires when the flag is true, so 100+
session corpora sat unprocessed unless the user knew to flip the
flag manually.

The fix:

- `isConsolidationEnabled()` now returns true by default whenever a
  non-noop LLM provider is detectable from env (API key set,
  OPENAI_BASE_URL set, or AGENTMEMORY_PROVIDER=agent-sdk).
- Explicit `CONSOLIDATION_ENABLED=false` or
  `AGENTMEMORY_PROVIDER=noop` still opt out — no behavior change for
  BM25-only / noop users.
- Skip-reason text on the pipeline function updated to point at the
  env vars users should set.

Closes the silent-no-graph case reported in discussion #612
(franklyfresh: 100 sessions, OpenAI-compatible LLM via Open WebUI /
vLLM, summarization working, graph empty).

8 unit tests cover: no-provider default-off, every supported provider
default-on, explicit `=false` override, explicit `=true` override,
and AGENTMEMORY_PROVIDER=noop wins over API-key presence.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agentmemory Ready Ready Preview, Comment May 28, 2026 9:41am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 37e5ab12-bc03-4943-988e-70b638e2a9a5

📥 Commits

Reviewing files that changed from the base of the PR and between 04a6f94 and 2d1bca9.

📒 Files selected for processing (3)
  • src/config.ts
  • src/functions/consolidation-pipeline.ts
  • test/consolidation-default.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/functions/consolidation-pipeline.ts
  • src/config.ts
  • test/consolidation-default.test.ts

📝 Walkthrough

Walkthrough

Consolidation now defaults to enabled when an LLM provider is configured; isConsolidationEnabled() accepts explicit true/false env overrides and otherwise infers provider presence from environment. README, pipeline skip messaging, and tests are updated to match the new behavior.

Changes

Consolidation default enabling

Layer / File(s) Summary
Consolidation default enabling logic
src/config.ts
isConsolidationEnabled() now interprets CONSOLIDATION_ENABLED explicitly ("true"/"1" or "false"/"0") and otherwise calls hasLLMProviderConfigured() to infer enablement from AGENTMEMORY_PROVIDER, provider API keys, OPENAI_BASE_URL, and OPENAI_API_KEY_FOR_LLM.
Consolidation default test coverage
test/consolidation-default.test.ts
New Vitest suite isolates HOME, manipulates env and .agentmemory/.env, reloads the config module, and asserts consolidation is enabled/disabled across provider presence and explicit override scenarios.
User documentation and messaging
README.md, src/functions/consolidation-pipeline.ts
README examples and .env comment flipped to show consolidation is default-on when an LLM provider is configured (opt-out via CONSOLIDATION_ENABLED=false); consolidation pipeline early-exit reason updated to list env vars that enable/configure LLM providers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • rohitg00/agentmemory#321: Overlapping README environment-variable documentation updates for consolidation/graph extraction defaults and examples.

Poem

🐰 I hopped through env and config light,
Found consolidation now takes flight.
If LLM's set, it wakes by default,
Opt out with false — no somersault.
Pipelines hint which keys to alight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: consolidation now defaults ON when an LLM provider is configured, which is the core behavioral change across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/consolidation-default-on

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.


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
Contributor

@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: 2

🧹 Nitpick comments (1)
test/consolidation-default.test.ts (1)

70-104: ⚡ Quick win

Add a regression test for OPENAI_API_KEY_FOR_LLM=false.

This suite should also assert that consolidation stays OFF when only OPENAI_API_KEY is present but LLM usage is explicitly disabled via OPENAI_API_KEY_FOR_LLM=false.

🤖 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 `@test/consolidation-default.test.ts` around lines 70 - 104, Add a regression
test in the same suite (test/consolidation-default.test.ts) that uses writeEnv
to set OPENAI_API_KEY=sk-test-123 and OPENAI_API_KEY_FOR_LLM=false, calls
freshConfig(), and asserts cfg.isConsolidationEnabled() is false; place it
alongside the existing cases (referencing writeEnv, freshConfig, and
isConsolidationEnabled) to ensure consolidation remains off when the
LLM-specific flag disables usage even if OPENAI_API_KEY is present.
🤖 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/config.ts`:
- Around line 333-345: hasLLMProviderConfigured is incorrectly treating
OPENAI_API_KEY as a valid LLM provider even when OPENAI_API_KEY_FOR_LLM is set
to "false"; update hasLLMProviderConfigured to only count OPENAI_API_KEY when
env["OPENAI_API_KEY_FOR_LLM"] !== "false" (case-insensitive), leaving other keys
(ANTHROPIC_API_KEY, OPENROUTER_API_KEY, GEMINI_API_KEY, GOOGLE_API_KEY,
MINIMAX_API_KEY, OPENAI_BASE_URL) and provider === "agent-sdk" unchanged, and
keep the noop provider behavior the same so detection aligns with
detectProvider/detectLlmProviderKind.

In `@src/functions/consolidation-pipeline.ts`:
- Line 53: Update the skip reason returned by the consolidation pipeline so it
lists all actual supported enablement paths; modify the return object in the
consolidation pipeline (the line returning { success: false, skipped: true,
reason: ... } in consolidation-pipeline.ts) to include GOOGLE_API_KEY,
OPENAI_BASE_URL and AGENTMEMORY_PROVIDER=agent-sdk alongside the existing LLM
provider keys (ANTHROPIC_API_KEY / OPENAI_API_KEY / OPENROUTER_API_KEY /
GEMINI_API_KEY / MINIMAX_API_KEY) and the CONSOLIDATION_ENABLED flag to keep
guidance accurate and consistent with the provider detection logic.

---

Nitpick comments:
In `@test/consolidation-default.test.ts`:
- Around line 70-104: Add a regression test in the same suite
(test/consolidation-default.test.ts) that uses writeEnv to set
OPENAI_API_KEY=sk-test-123 and OPENAI_API_KEY_FOR_LLM=false, calls
freshConfig(), and asserts cfg.isConsolidationEnabled() is false; place it
alongside the existing cases (referencing writeEnv, freshConfig, and
isConsolidationEnabled) to ensure consolidation remains off when the
LLM-specific flag disables usage even if OPENAI_API_KEY is present.
🪄 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: 0b587e81-251c-405b-baee-a2aa4bd0f813

📥 Commits

Reviewing files that changed from the base of the PR and between a0da02b and 04a6f94.

📒 Files selected for processing (4)
  • README.md
  • src/config.ts
  • src/functions/consolidation-pipeline.ts
  • test/consolidation-default.test.ts

Comment thread src/config.ts
Comment thread src/functions/consolidation-pipeline.ts Outdated
Review fixes on #696:

1. hasLLMProviderConfigured() now scopes OPENAI_API_KEY to LLM use the
   same way detectProvider() does: the key only counts when
   OPENAI_API_KEY_FOR_LLM is not "false" (case-insensitive). Without
   this, a user who explicitly scoped their OpenAI key to embeddings
   only would still get consolidation enabled by default. Other keys
   (ANTHROPIC, OPENROUTER, GEMINI, GOOGLE, MINIMAX, OPENAI_BASE_URL)
   and AGENTMEMORY_PROVIDER=agent-sdk unchanged.

2. consolidation-pipeline skip-reason text now lists every env path
   that flips the default: ANTHROPIC_API_KEY / OPENAI_API_KEY /
   OPENROUTER_API_KEY / GEMINI_API_KEY / GOOGLE_API_KEY /
   MINIMAX_API_KEY / OPENAI_BASE_URL / AGENTMEMORY_PROVIDER=agent-sdk.
   Aligns with the actual detection logic so users see all valid
   ways to enable when they hit the skipped result.

3. Regression test in test/consolidation-default.test.ts asserts
   OPENAI_API_KEY=sk-... + OPENAI_API_KEY_FOR_LLM=false →
   isConsolidationEnabled() === false. Pairs with the existing
   OPENAI_API_KEY-on-by-default case to lock the contract.
@rohitg00 rohitg00 merged commit fcb6694 into main May 28, 2026
7 checks passed
@rohitg00 rohitg00 deleted the fix/consolidation-default-on branch May 28, 2026 10:17
@rohitg00 rohitg00 mentioned this pull request May 28, 2026
5 tasks
rohitg00 added a commit that referenced this pull request May 28, 2026
Bumps version across 9 files + adds CHANGELOG entry summarizing the
18 commits since v0.9.22.

Highlights:
- GitHub Copilot CLI first-class support (#534) — plugin + hooks +
  MCP with LSP-style Content-Length framing on the standalone stdio
  transport.
- Five new MCP adapters: Warp, Cline, Continue, Zed, Droid (#677);
  ADAPTERS count 11 → 17.
- Three silent DX bugs fixed: graph extraction never fired on
  session end (#666 / #698), status reported zero memories (#666),
  consolidation defaulted off even with an LLM provider configured
  (#612 / #696).
- Nine telemetry hooks switched to fire-and-forget so they don't
  block Claude Code's next-prompt boundary (#573 / #688).
- Hook project field now sends repo basename instead of full
  filesystem path so auto-injected context isn't silently filtered
  out (#474 / #687).
- Local-LLM docs: Ollama / LM Studio / vLLM section added (#671 /
  #697).

Version-bump files: package.json, plugin/.claude-plugin/plugin.json,
plugin/plugin.json, plugin/.codex-plugin/plugin.json,
packages/mcp/package.json, src/version.ts, src/types.ts,
src/functions/export-import.ts, test/export-import.test.ts.
rohitg00 added a commit that referenced this pull request May 28, 2026
* chore(release): v0.9.23

Bumps version across 9 files + adds CHANGELOG entry summarizing the
18 commits since v0.9.22.

Highlights:
- GitHub Copilot CLI first-class support (#534) — plugin + hooks +
  MCP with LSP-style Content-Length framing on the standalone stdio
  transport.
- Five new MCP adapters: Warp, Cline, Continue, Zed, Droid (#677);
  ADAPTERS count 11 → 17.
- Three silent DX bugs fixed: graph extraction never fired on
  session end (#666 / #698), status reported zero memories (#666),
  consolidation defaulted off even with an LLM provider configured
  (#612 / #696).
- Nine telemetry hooks switched to fire-and-forget so they don't
  block Claude Code's next-prompt boundary (#573 / #688).
- Hook project field now sends repo basename instead of full
  filesystem path so auto-injected context isn't silently filtered
  out (#474 / #687).
- Local-LLM docs: Ollama / LM Studio / vLLM section added (#671 /
  #697).

Version-bump files: package.json, plugin/.claude-plugin/plugin.json,
plugin/plugin.json, plugin/.codex-plugin/plugin.json,
packages/mcp/package.json, src/version.ts, src/types.ts,
src/functions/export-import.ts, test/export-import.test.ts.

* chore(release): add #701 + #709 to v0.9.23 CHANGELOG
@Yoshimit
Copy link
Copy Markdown

Hmmm...
I don't know @rohitg00 .
I'm using 0.9.22 with flags GEMINI_API_KEY and GEMINI_MODEL defined
and AGENTMEMORY_AUTO_COMPRESS, AGENTMEMORY_INJECT_CONTEXT, CONSOLIDATION_ENABLED, GRAPH_EXTRACTION_ENABLED and AGENTMEMORY_REFLECT all defined to true

but no graph or consolidation happens using Hermes or Open Code
So, I'm not sure if the problem is only the flag defaulted to false on .env file.

I'm using Linux.

I'll wait the 0.9.23v to see if something changes.

Thank you!

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.

2 participants