Skip to content

fix: remove duplicate memory_compact tool registration#433

Closed
AliceLJY wants to merge 2 commits intomasterfrom
fix/remove-duplicate-memory-compact
Closed

fix: remove duplicate memory_compact tool registration#433
AliceLJY wants to merge 2 commits intomasterfrom
fix/remove-duplicate-memory-compact

Conversation

@AliceLJY
Copy link
Copy Markdown
Collaborator

Summary

Root cause: memory_compact was registered twice — once in tools.ts (proper version) and once in index.ts (old prototype). OpenClaw's tool-name conflict detection logged ERRORs on every gateway start/reload.

Fix: Delete the 88-line prototype block in index.ts. One registration, zero conflicts.

Fixes #431

Test plan

  • openclaw status no longer shows plugin tool name conflict (memory-lancedb-pro): memory_compact ERROR
  • memory_compact tool still works via the tools.ts implementation
  • Auto-compaction at gateway start still triggers when memoryCompaction.enabled: true

🤖 Generated with Claude Code

The memory_compact tool was registered twice:
- Once in src/tools.ts via registerMemoryCompactTool() (the proper
  implementation added in PR #343)
- Once inline in index.ts as a leftover prototype

This caused OpenClaw's tool-name conflict detection to emit ERROR logs
on every gateway start/reload.

Remove the orphaned inline registration in index.ts. The tools.ts
version is the canonical implementation. The auto-compaction hook
at gateway_start (which uses runCompaction directly) is unaffected.

Fixes #431

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
)

PR #391 made selfImprovement.enabled default to true even when the
config block is omitted, which registers appendSelfImprovementNote on
the command:new hook. Three test assertions still expected command:new
to be undefined — update them to accept the self-improvement hook
while still verifying sessionMemory does not register its own /new hook.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
hoh-dev-bot pushed a commit to hoh-dev-bot/memory-lancedb-pro that referenced this pull request Apr 1, 2026
- Restore memory_compact tool registration block in index.ts
  (was unintentionally dropped in previous commits; not related to PR CortexReach#433)
- Remove bun.lock (local artifact, project uses npm)
- Re-enable cwd: sessionDir in Claude Code subprocess options
  (isolated cwd is ready; OAuth auth issue was resolved)
- Replace unsafe type casts in extractTextFromSdkMessage with
  explicit runtime property checks for robustness against SDK changes
@rwmjhb
Copy link
Copy Markdown
Collaborator

rwmjhb commented Apr 1, 2026

Review: REQUEST-CHANGES

Fixing the duplicate memory_compact registration is the right call — the startup ERROR noise is a real problem.

Must fix:

  1. The two implementations are not equivalent — the deleted index.ts version accepted dry_run, min_age_days, similarity_threshold, and scopes, and called runCompaction for progressive summarization. The surviving src/tools.ts version only does exact-duplicate archival via patchMetadata. This isn't deduplication of identical code — it's choosing one feature over another. The openclaw.plugin.json docs (lines 1314-1329) still reference the deleted implementation's parameters.

  2. Rebase needed — build fails due to stale base (stale_base=true), all tests pass. Please rebase onto main.

Worth considering (not blocking):

  • No plugin-level regression test exercises memory_compact through plugin.register() with the surviving contract. test/memory-governance-tools.test.mjs covers the tools.ts path directly, but nothing validates the end-to-end tool invocation after this change.
  • The test assertion changes for command:new (selfImprovement fix: default selfImprovement.enabled to true when config block omitted #391) are scope drift — consider splitting into a separate commit/PR for clarity.

@rwmjhb
Copy link
Copy Markdown
Collaborator

rwmjhb commented Apr 1, 2026

Closing in favor of #441. Both PRs fix the same memory_compact name collision (#431), but the two implementations serve different purposes — src/tools.ts does lightweight dedup, index.ts does progressive compaction with min_age_days/similarity_threshold/scopes. Deleting one loses functionality; renaming to coexist is the better direction. See #441 for details.

@rwmjhb
Copy link
Copy Markdown
Collaborator

rwmjhb commented Apr 1, 2026

Closing: prefer #441 (rename) over deletion to preserve both tool implementations.

@rwmjhb rwmjhb closed this Apr 1, 2026
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.

plugin tool name conflict (memory-lancedb-pro): memory_compact — 工具重复注册导致 ERROR

2 participants