mirror of
https://github.com/thedotmack/claude-mem
synced 2026-04-25 17:15:04 +02:00
fix: update test expectations for observation salvage (intentional #1908 behavior change)
- Update test: parseSummary with <observation> tags now returns salvaged summary object instead of null, matching the intentional #1908 behavior - Fix docstring: salvageSummaryFromObservationTags extracts from all observations, not just the first - Add explanatory comment in test linking #1360 → #1908 behavior change Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -206,7 +206,8 @@ export function parseSummary(text: string, sessionId?: number): ParsedSummary |
|
||||
/**
|
||||
* Salvage a ParsedSummary from <observation> tags when the LLM failed to
|
||||
* emit <summary> tags. Extracts title → request, narrative → learned,
|
||||
* and facts → investigated/completed fields from the first observation.
|
||||
* and facts → investigated/completed fields from all observations,
|
||||
* joining multiple values with semicolons or double newlines.
|
||||
* Returns null only if the observation content is completely empty. (#1908)
|
||||
*/
|
||||
function salvageSummaryFromObservationTags(text: string, sessionId?: number): ParsedSummary | null {
|
||||
|
||||
@@ -8,8 +8,19 @@ import { describe, it, expect } from 'bun:test';
|
||||
import { parseSummary } from '../../src/sdk/parser.js';
|
||||
|
||||
describe('parseSummary', () => {
|
||||
it('returns null when no <summary> tag present', () => {
|
||||
expect(parseSummary('<observation><title>foo</title></observation>')).toBeNull();
|
||||
// Intentional behavior change from #1908: parseSummary now salvages data from
|
||||
// <observation> tags when no <summary> tags are present, rather than discarding
|
||||
// the output. Previously this returned null (see #1360), but #1908 determined
|
||||
// that discarding observation-tagged output loses valuable session data.
|
||||
it('salvages summary from <observation> tags when no <summary> tag present (#1908)', () => {
|
||||
const result = parseSummary('<observation><title>foo</title></observation>');
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.request).toBe('foo');
|
||||
expect(result?.investigated).toBeNull();
|
||||
expect(result?.learned).toBeNull();
|
||||
expect(result?.completed).toBeNull();
|
||||
expect(result?.next_steps).toBeNull();
|
||||
expect(result?.notes).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null when <summary> has no sub-tags (false positive — fix for #1360)', () => {
|
||||
|
||||
Reference in New Issue
Block a user