fix: expose summaryStored in session status to detect silent summary loss (#1633)
Stop hook polled queueLength===0 as a proxy for summary success, but the queue empties regardless of whether the LLM produced valid <summary> tags. Added lastSummaryStored tracking on ActiveSession, surfaced via the /api/sessions/status endpoint, and emit a logger.warn in the Stop hook when summaryStored===false. Generated by Claude Code Vibe coded by ousamabenyounes Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -683,4 +683,47 @@ describe('ResponseProcessor', () => {
|
||||
).rejects.toThrow('Cannot store observations: memorySessionId not yet captured');
|
||||
});
|
||||
});
|
||||
|
||||
describe('lastSummaryStored tracking (#1633)', () => {
|
||||
it('should set lastSummaryStored=true when storage returns a summaryId', async () => {
|
||||
mockStoreObservations.mockImplementation(() => ({
|
||||
observationIds: [],
|
||||
summaryId: 42,
|
||||
createdAtEpoch: 1700000000000,
|
||||
} as StorageResult));
|
||||
|
||||
const session = createMockSession();
|
||||
const responseText = `
|
||||
<summary>
|
||||
<request>user asked to fix bug</request>
|
||||
<investigated>looked at auth module</investigated>
|
||||
<learned>JWT tokens were expiring</learned>
|
||||
<completed>fixed expiry check</completed>
|
||||
<next_steps>write tests</next_steps>
|
||||
</summary>
|
||||
`;
|
||||
|
||||
await processAgentResponse(responseText, session, mockDbManager, mockSessionManager, mockWorker, 0, null, 'TestAgent');
|
||||
|
||||
expect(session.lastSummaryStored).toBe(true);
|
||||
});
|
||||
|
||||
it('should set lastSummaryStored=false when storage returns summaryId=null (silent loss path, #1633)', async () => {
|
||||
// Simulate the silent failure: agent returns no parseable <summary> tags,
|
||||
// storeObservations skips summary and returns summaryId=null.
|
||||
mockStoreObservations.mockImplementation(() => ({
|
||||
observationIds: [],
|
||||
summaryId: null,
|
||||
createdAtEpoch: 1700000000000,
|
||||
} as StorageResult));
|
||||
|
||||
const session = createMockSession();
|
||||
// Response with no <summary> block — LLM failed to produce structured output
|
||||
const responseText = '<skip_summary/>';
|
||||
|
||||
await processAgentResponse(responseText, session, mockDbManager, mockSessionManager, mockWorker, 0, null, 'TestAgent');
|
||||
|
||||
expect(session.lastSummaryStored).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user