(feat) Enhanced Memory Management: (1) maintain a rolling cross-sessi…#96
Conversation
…on digest; (2)classify conversations by importance using a two-stage pipeline
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the bot's memory management capabilities by introducing mechanisms for maintaining long-term context and intelligently archiving important conversations. It moves beyond isolated session snapshots to provide a consolidated view of ongoing work and proactively identifies high-value interactions, ensuring critical information is retained and accessible across sessions. This improves the bot's ability to maintain continuity and focus on relevant tasks without explicit prompting. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces two significant new features for memory management: a context-digest hook to create a rolling cross-session summary, and a session-importance hook to classify and archive important conversations. It also fixes a bug that caused a crash during Qveris onboarding due to a missing channel.x binding in the PluginRuntime. However, these new memory management features introduce security risks related to cross-session prompt injection and potential denial of service. Specifically, the automatic injection of summarized conversation history into the system prompt can be exploited to persist malicious instructions across sessions, and reading entire session transcript files into memory without pre-checking their size could lead to memory exhaustion and process crashes. My review also focuses on improving the robustness of configuration handling in the new hook handlers.
…on digest; (2)classify conversations by importance using a two-stage pipeline
Summary
session-memoryhook saves isolated per-session snapshots with no consolidated "recent context" view, andmemory-flushonly saves memory reactively near compaction time — meaning routine chit-chat and critical architecture decisions are treated identically.context-digest,session-importance), shared utilities (transcript-reader.ts,llm-memory-helpers.ts), a System Prompt Anchor (context-digest-anchor.ts), and a hotfix forPluginRuntimemissing itschannel.xbinding (which caused a crash inqverisbot onboardafter configuring Qveris).session-memory,memory-flush,memory_search,memory_get) are completely unchanged. New hooks complement rather than replace existing behavior.Change Type (select all)
channel.xmissing fix is a bug fix)Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
context-digesthook (new, enabled by default): On every/newor/reset, a rolling 7-day cross-session digest is written tomemory/context-digest.md. The digest is topic-organized with sections: Topics Discussed, Key Decisions, Open Items / Action Items, Important Context.session-importancehook (new, enabled by default): On every/newor/reset, the previous session is evaluated by a multi-dimensional scoring engine (code density, message depth, collaboration intensity, keyword signals). Sessions that pass the threshold are classified by LLM (or keyword fallback) and persisted tomemory/important/YYYY-MM-DD-<category>-<slug>.md. Duplicate topic sessions are smart-appended rather than creating new files.## Open Items / Action Itemssection fromcontext-digest.md(≤800 chars) is automatically injected into every session's system prompt, giving the model subconscious awareness of pending tasks without requiring an explicitmemory_searchcall.qverisbot onboardcrash fix: FixedTypeError: Cannot read properties of undefined (reading 'listXAccountIds')that occurred after configuring Qveris during onboarding. ThePluginRuntimeChanneltype andcreateRuntimeChannel()were missing thexproperty entirely.hooks.internal.entries):context-digest.days(default: 7),context-digest.llmDigest(default: true)session-importance.messages(default: 30),session-importance.llmClassify(default: true)Security Impact (required)
/new//resetevent (context-digest and session-importance). Both use the existingrunEmbeddedPiAgentpattern with the user's already-configured model/provider. Both have 20s timeouts and full no-LLM fallback paths, so they degrade gracefully if the model is unavailable.~/.openclaw/agents/main/sessions/*.jsonl(already accessible to the gateway process). They write tomemory/context-digest.mdandmemory/important/*.md(within the existing workspace memory directory). No new file system paths outside existing scope.Yes, explain risk + mitigation:llmDigest: false/llmClassify: falseconfig disables LLM entirely; (3) 20s hard timeout; (4) all calls are fire-and-forget (do not block reply).writeFileWithinRoot(atomic rename, alias-safe) and a Promise-based Mutex preventing concurrent writes to the same digest file.Repro + Verification
Environment
hooks.internal.entries.context-digest.enabled: true,hooks.internal.entries.session-importance.enabled: trueSteps
pnpm qverisbot gateway runor via macOS app)/newto the botExpected
~/.openclaw/workspace/memory/context-digest.mdis created/updated with a structured topic digest~/.openclaw/workspace/memory/important/contains a new.mdfile for important sessions (or nothing for routine ones)[hooks/context-digest] Context digest updated: ...Evidence
src/hooks/llm-memory-helpers.test.ts(evaluateSessionImportance — all 8 probes)src/hooks/bundled/context-digest/handler.test.tssrc/hooks/bundled/session-importance/handler.test.tssrc/auto-reply/reply/context-digest-anchor.test.tspnpm buildpasses with 0 errorspnpm check(lint) passes with 0 errors after fixing 3 unused-variable lint issues in test filescontext-digestrunning on real sessionsHuman Verification (required)
/newtriggerscontext-digestupdate (confirmed viagateway.log)context-digest.mdfile written with correct freshness header and section structuresession-importancecorrectly skips routine conversations (no files written for short/trivial sessions)qverisbot onboardno longer crashes after Qveris config steppnpm qverisbot hooks listshows both new hooks as✓ ready/newfrom two channels → Mutex debounce prevents race condition (unit tested)sessionIdtriggered by bothcommand:newandsession:end→ dedup filter skips second (unit tested)memory/important/→ smart append with timestamp divider (unit tested)VITEST=true)session:endsafety net path from genuine idle timeout (onlycommand:newtested live)Compatibility / Migration
openclaw hooks disable context-digest/openclaw hooks disable session-importance.Failure Recovery (if this breaks)