feat(memory): persist auto-memory scratchpad for skill extraction#25873
feat(memory): persist auto-memory scratchpad for skill extraction#25873SandyTao520 merged 16 commits intomainfrom
Conversation
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 enhances the memory system by introducing a persistent 'memory scratchpad' that captures compact workflow hints during sessions. By storing this metadata, the skill extraction process can more effectively identify and route repeated workflows, improving the quality and reliability of extracted skills. The changes include updates to session recording, metadata persistence, and the extraction agent's prompt, supported by new evaluation tools to measure retrieval performance. Highlights
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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces "Memory Scratchpads," which extract lightweight workflow metadata—including tool sequences, touched paths, and validation status—from conversation sessions to improve skill extraction recall. The MemoryService and SkillExtractionAgent are updated to leverage these hints for session prioritization and routing. The PR also adds turn count and duration tracking to agent execution, supports JSONL metadata updates, and includes new evaluation tests for retrieval performance. Feedback identifies a maintainability risk due to duplicated JSONL parsing logic in sessionSummaryUtils.ts and suggests refactoring to use the shared loadConversationRecord function.
Note: Security Review did not run due to the size of the PR.
# Conflicts: # packages/core/src/services/memoryService.test.ts # packages/core/src/services/memoryService.ts # packages/core/src/services/sessionSummaryUtils.test.ts # packages/core/src/services/sessionSummaryUtils.ts
|
Size Change: +13 kB (+0.04%) Total Size: 33.8 MB
ℹ️ View Unchanged
|
|
✅ 55 tests passed successfully on gemini-3-flash-preview. This is an automated guidance message triggered by steering logic signatures. |
Samee24
left a comment
There was a problem hiding this comment.
LGTM! Thanks for addressing the comments.
Summary
Persist an auto-memory
memoryScratchpadinto session metadata so skill extraction can use compact workflow hints without relying only on one-line session summaries.In the 5-trial scratchpad stats eval, the scratchpad path reduced average extractor turns from
13.2to11.0(-16.7%), reduced distractor reads from3.8to2.4(-36.8%), improved precision from0.3467to0.46(+32.7%), kept recall at1.0, and reduced duration from42812.6msto40956.2ms(-4.3%).Details
memoryScratchpadthrough chat recording, session summary refreshes, and memory service session loading.loadConversationRecord()session parser instead of maintaining a second JSONL parser in summary utilities.turnCount,durationMs, andterminateReason) so scratchpad impact can be measured.preflightstays green.GEMINI_CLI_TRUST_WORKSPACE=truefor chained and nightly eval workflows so headless eval runs stay aligned with the workspace trust enforcement added in feat(cli): secure .env loading and enforce workspace trust in headless mode #25814.Related Issues
Closes #25895.
How to Validate
npm run preflight.Expected result: all workspace checks pass.
npm exec -- vitest run packages/core/src/services/sessionSummaryUtils.test.ts packages/core/src/services/memoryService.test.ts packages/core/src/agents/skill-extraction-agent.test.ts.Expected result: focused service and prompt-contract tests pass.
npm exec -- tsc -p packages/core/tsconfig.json --noEmit.Expected result: core typecheck passes.
RUN_EVALS=1 npm exec -- vitest run --config evals/vitest.config.ts -t "Session summary persists memory scratchpad for memory-saving sessions".Expected result: the eval passes and verifies
memoryScratchpadis written into the resumed session log.RUN_EVALS=1 npm exec -- vitest run --config evals/vitest.config.ts -t "memory scratchpad improves repeated-workflow recall versus summary-only index".Expected result: the eval passes and scratchpad-enabled retrieval matches or beats the summary-only baseline for the repeated workflow fixture.
RUN_EVALS=1 RUN_SCRATCHPAD_STATS=1 SCRATCHPAD_STATS_TRIALS=5 npm exec -- vitest run --config evals/vitest.config.ts -t "reports memory scratchpad retrieval statistics".Expected result: the eval passes and writes
evals/logs/skill_extraction_scratchpad_stats.json.GEMINI_MODEL=gemini-3-pro-preview GEMINI_CLI_TRUST_WORKSPACE=true npm exec -- vitest run --config evals/vitest.config.ts evals/save_memory.eval.ts -t "Agent remembers user's favorite color".Expected result: the trusted eval subprocess can call
save_memorysuccessfully.Pre-Merge Checklist