feat(openclaw-nowledge-mem): make thread truncation configurable#102
Conversation
📝 WalkthroughWalkthroughAdds a configurable Changes
Sequence Diagram(s)sequenceDiagram
participant Admin as Admin/UI
participant Plugin as OpenClaw Plugin
participant Capture as Capture Handler
participant Storage as Thread Storage
Admin->>Plugin: set maxThreadMessageChars (config / env)
Plugin->>Plugin: resolve config (file → pluginConfig → env → default)
Capture->>Plugin: capture event (agent_end / before_reset)
Plugin->>Capture: provide resolved maxThreadMessageChars
Capture->>Capture: normalize messages (truncate using maxThreadMessageChars)
Capture->>Storage: appendOrCreateThread(persist truncated messages)
Plugin->>Status: expose maxThreadMessageChars and source
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 the current code and only fix it if needed.
Inline comments:
In `@nowledge-mem-openclaw-plugin/src/config.js`:
- Around line 237-252: ALLOWED_KEYS currently omits "maxThreadMessageChars" so
plugin configs using that key are rejected and the parsed value isn't exposed
because it's not included in the returned config object; add the string
"maxThreadMessageChars" to the ALLOWED_KEYS array (where other keys like
maxContextTokens are listed) and add a property maxThreadMessageChars:
maxThreadMessageChars to the object returned by the config function so the
computed value (and its source in _sources.maxThreadMessageChars) is exposed as
cfg.maxThreadMessageChars at runtime.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a08b1837-e049-4a5d-85f4-78a5c901f134
📒 Files selected for processing (5)
nowledge-mem-openclaw-plugin/README.mdnowledge-mem-openclaw-plugin/openclaw.plugin.jsonnowledge-mem-openclaw-plugin/src/config.jsnowledge-mem-openclaw-plugin/src/hooks/capture.jsnowledge-mem-openclaw-plugin/src/tools/status.js
|
@blessonism thanks! |
16ec0a3 to
7c4c044
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
nowledge-mem-openclaw-plugin/src/hooks/capture.js (1)
379-389: Rename_cfgtocfgsince it's now used.The underscore prefix conventionally signals an intentionally unused parameter, but
_cfgis now accessed on line 388. This is inconsistent withbuildAgentEndCaptureHandlerwhich usescfgdirectly.♻️ Suggested fix for naming consistency
-export function buildBeforeResetCaptureHandler(client, _cfg, logger) { +export function buildBeforeResetCaptureHandler(client, cfg, logger) { return async (event, ctx) => { const reason = typeof event?.reason === "string" ? event.reason : undefined; await appendOrCreateThread({ client, logger, event, ctx, reason, - maxMessageChars: _cfg?.maxThreadMessageChars, + maxMessageChars: cfg.maxThreadMessageChars, }); }; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@nowledge-mem-openclaw-plugin/src/hooks/capture.js` around lines 379 - 389, The parameter name _cfg in buildBeforeResetCaptureHandler is misleading because it implies the argument is unused while the function reads _cfg.maxThreadMessageChars; rename the parameter to cfg (matching buildAgentEndCaptureHandler) and update all references inside buildBeforeResetCaptureHandler (e.g., _cfg?.maxThreadMessageChars) to use cfg?.maxThreadMessageChars to restore naming consistency.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@nowledge-mem-openclaw-plugin/src/hooks/capture.js`:
- Around line 379-389: The parameter name _cfg in buildBeforeResetCaptureHandler
is misleading because it implies the argument is unused while the function reads
_cfg.maxThreadMessageChars; rename the parameter to cfg (matching
buildAgentEndCaptureHandler) and update all references inside
buildBeforeResetCaptureHandler (e.g., _cfg?.maxThreadMessageChars) to use
cfg?.maxThreadMessageChars to restore naming consistency.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 05610cb7-ae54-42aa-ac75-801f650f2dca
📒 Files selected for processing (5)
nowledge-mem-openclaw-plugin/README.mdnowledge-mem-openclaw-plugin/openclaw.plugin.jsonnowledge-mem-openclaw-plugin/src/config.jsnowledge-mem-openclaw-plugin/src/hooks/capture.jsnowledge-mem-openclaw-plugin/src/tools/status.js
🚧 Files skipped from review as they are similar to previous changes (3)
- nowledge-mem-openclaw-plugin/openclaw.plugin.json
- nowledge-mem-openclaw-plugin/src/config.js
- nowledge-mem-openclaw-plugin/README.md
|
@wey-gu 已按你的建议把分支 rebase 到最新的 upstream/main,并解决了所有冲突(README / openclaw.plugin.json / src/config.js / src/tools/status.js)。 同时保留了 main 上新增的 刚刚已 force-push 更新 PR,麻烦你这边再看下 CI/Review,谢谢! |
|
THANKS a lot @blessonism ! |
Motivation
The plugin currently hard-truncates each captured OpenClaw thread message to 800 chars before persistence. This makes Nowledge thread history much less useful for reviewing long OpenClaw conversations, especially when inbound messages include envelope metadata or injected memory context.
What this change does
maxThreadMessageChars800openclaw.plugin.jsonconfigSchemanowledge_mem_statusSuggested defaults
800200-20000Files changed
src/config.jssrc/hooks/capture.jssrc/tools/status.jsopenclaw.plugin.jsonREADME.mdValidation already done locally
maxThreadMessageCharsis read from pluginConfigmaxThreadMessageChars: 4000Notes for reviewers
This change intentionally does not remove truncation entirely. It only converts the current hard-coded limit into a documented config option so users can tune fidelity vs noise/storage for their own OpenClaw workflows.
Closes #101
Summary by CodeRabbit
New Features
Documentation