Refactor summary generation from session-level to request-level
Changed summary prompts to generate discrete per-request summaries instead of cumulative session summaries. This provides better chronological memory where each summary is a clean unit representing one request/response cycle. Changes: - Renamed buildFinalizePrompt() to buildSummaryPrompt() in src/sdk/prompts.ts - Updated prompt text to focus on "THIS REQUEST" rather than "this session" - Updated all import and function call sites in worker-service.ts and worker.ts - Added IMPORTANT warning to emphasize request-level scope Expected behavior: Each summary will now describe only what happened during that specific request, eliminating cumulative recaps. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+8
-6
@@ -137,19 +137,21 @@ export function buildObservationPrompt(obs: Observation): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build finalization prompt to generate session summary
|
||||
* Build prompt to generate request summary
|
||||
*/
|
||||
export function buildFinalizePrompt(session: SDKSession): string {
|
||||
return `MEMORY PROCESSING SESSION COMPLETED
|
||||
===================================
|
||||
This session has completed. Review the observations you generated and create a session summary.
|
||||
export function buildSummaryPrompt(session: SDKSession): string {
|
||||
return `REQUEST SUMMARY
|
||||
===============
|
||||
Review the observations you generated for THIS REQUEST and create a summary.
|
||||
|
||||
IMPORTANT: Summarize only THIS REQUEST, not the entire session.
|
||||
|
||||
Output this XML:
|
||||
<summary>
|
||||
<request>[What did the user request?]</request>
|
||||
<investigated>[What code and systems did you explore?]</investigated>
|
||||
<learned>[What did you learn about the codebase?]</learned>
|
||||
<completed>[What was accomplished in this session?]</completed>
|
||||
<completed>[What was accomplished in this request?]</completed>
|
||||
<next_steps>[What should be done next?]</next_steps>
|
||||
<notes>[Additional insights or context]</notes>
|
||||
</summary>
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ import { query } from '@anthropic-ai/claude-agent-sdk';
|
||||
import type { SDKUserMessage, SDKSystemMessage } from '@anthropic-ai/claude-agent-sdk';
|
||||
import { SessionStore } from '../services/sqlite/SessionStore.js';
|
||||
import { getWorkerSocketPath } from '../shared/paths.js';
|
||||
import { buildInitPrompt, buildObservationPrompt, buildFinalizePrompt } from './prompts.js';
|
||||
import { buildInitPrompt, buildObservationPrompt, buildSummaryPrompt } from './prompts.js';
|
||||
import { parseObservations, parseSummary } from './parser.js';
|
||||
import type { SDKSession } from './prompts.js';
|
||||
|
||||
@@ -374,7 +374,7 @@ class SDKWorker {
|
||||
this.isFinalized = true;
|
||||
const session = await this.loadSession();
|
||||
if (session) {
|
||||
const finalizePrompt = buildFinalizePrompt(session);
|
||||
const finalizePrompt = buildSummaryPrompt(session);
|
||||
console.error('[claude-mem worker] Yielding finalize prompt to SDK agent', {
|
||||
sessionDbId: this.sessionDbId,
|
||||
sdkSessionId: this.sdkSessionId,
|
||||
|
||||
Reference in New Issue
Block a user