From cbeddef2d7c233f8aacdef1e6513bb468bcfa728 Mon Sep 17 00:00:00 2001 From: Alex Newman Date: Sat, 18 Apr 2026 14:42:15 -0700 Subject: [PATCH] fix: update test expectations for observation salvage (intentional #1908 behavior change) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update test: parseSummary with 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) --- src/sdk/parser.ts | 3 ++- tests/sdk/parse-summary.test.ts | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/sdk/parser.ts b/src/sdk/parser.ts index 29fe8ac6..1e4d2585 100644 --- a/src/sdk/parser.ts +++ b/src/sdk/parser.ts @@ -206,7 +206,8 @@ export function parseSummary(text: string, sessionId?: number): ParsedSummary | /** * Salvage a ParsedSummary from tags when the LLM failed to * emit 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 { diff --git a/tests/sdk/parse-summary.test.ts b/tests/sdk/parse-summary.test.ts index 76e2174c..d8042125 100644 --- a/tests/sdk/parse-summary.test.ts +++ b/tests/sdk/parse-summary.test.ts @@ -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 tag present', () => { - expect(parseSummary('foo')).toBeNull(); + // Intentional behavior change from #1908: parseSummary now salvages data from + // tags when no 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 tags when no tag present (#1908)', () => { + const result = parseSummary('foo'); + 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 has no sub-tags (false positive — fix for #1360)', () => {