OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[v0.4.8] _extract_abstract_from_summary returns markdown heading instead of real abstract

Open njuboy11 opened this issue 4 months ago • 2 comments

Environment

  • Version: v0.4.8 (also present in main as of 2026-07-11)
  • File: openviking/session/session.py:2165 _extract_abstract_from_summary()
  • Affected paths: .abstract.md written under every history/archive_XXX/ directory

Reproduction

  1. Run any session that produces archive summaries. The _generate_archive_summary_async() calls _extract_abstract_from_summary() at line 1349 to write .abstract.md.
  2. _read_archive_abstract() at line 1984 also calls the same method for recall queries.

Observed: 97/97 .abstract.md files contain # Working Memory (16 bytes) — the first line of the structured markdown overview, which is a heading, not a real abstract.

Expected: The abstract should be a meaningful one-sentence summary, e.g. "OV archive count verification + post-reset pending token investigation" (from the ## Session Title line or first real paragraph below the headings).

Root Cause

When no **Key**: value pattern matches in the summary, the fallback is:

first_line = summary.split("\n")[0].strip()
return first_line if first_line else ""

For structured markdown overviews that look like:

# Working Memory

## Session Title
Some actual title...

## Current State
...

The first line is literally # Working Memory — the top-level heading. This means every single archive gets the same heading as its abstract, making .abstract.md useless for recall/semantic search.

Impact

Scope Before fix After fix
97 archive .abstract.md # Working Memory (16B, identical) OV archive count verification + post-reset... (meaningful)
Empty archives "" (0B) "" (0B, no regression)
Legacy **Key**: value format unchanged unchanged
recall search quality abstracts are noise (all identical) abstracts are actual content summaries

This directly impacts:

  • Recall quality: .abstract.md is indexed for vector search; 97 identical "# Working Memory" entries add noise instead of signal
  • Directory-level semantics: semantic_processor.py collects child abstracts to build parent abstract trees; all-identical abstracts break the semantic tree

Fix

Skip markdown headings (#), horizontal rules (---), and blank lines. Take the first real paragraph line (>3 characters) as the abstract.

-        first_line = summary.split("\n")[0].strip()
+        # Skip markdown headings, separators, and blank lines;
+        # return the first meaningful content line.
+        for line in summary.split("\n"):
+            stripped = line.strip()
+            if not stripped or stripped.startswith("#") or stripped.startswith("---"):
+                continue
+            if len(stripped) > 3:
+                return stripped[:200]
+
+        # Fallback: strip heading markers from the first line
+        first_line = summary.split("\n")[0].strip().lstrip("#").strip()

Change: 1 file, +11 −1 lines in openviking/session/session.py

Related

  • In a production deployment (v0.4.8 with ~240K messages across 97 archives), this bug was confirmed: 97/97 .abstract.md are either empty (0B) or contain only # Working Memory (16B). After applying the fix and re-extracting, all 97 archives got meaningful abstracts.

njuboy11 avatar Jul 10 '26 14:07 njuboy11

Can we please get this prioritized. It makes the L0 basically absent. @ZaynJarvis @ehz0ah in case you didn't notice the issue and #3139 that fixes it. Thank you!

timeleft-- avatar Jul 31 '26 10:07 timeleft--

Confirming this is still live on main today (2026-08-24) and adding a corpus-scale measurement, because it changes which of the three open PRs should land.

main's _extract_abstract_from_summary (session.py:4024-4034) is byte-identical to the v0.4.8 code quoted above, and to the v0.4.15 wheel we run.

Corpus

3,555 archive directories (sessions/*/history/archive_*/), ~1 month of real sessions, generated by compression.ov_wm_v2. Every .overview.md is intact on disk, so this is purely an extraction problem — reproducing the abstract needs zero LLM calls.

Method: call each candidate implementation directly on every .overview.md, then classify the returned string. Classifier is self-tested on 7 fixed cases before it measures anything.

shipped reproduces the on-disk .abstract.md for 3,555 / 3,555 files, which confirms the diagnosis: the fallback is the only thing that ever runs.

Benchmark of the three open PRs

candidate usable guidance text turn-count stub heading italic median bytes
shipped (main) 32 (0.9%) 1 166 3356 0 16
PR #3137 3268 (91.9%) 59 166 0 62 49
PR #3140 3388 (95.3%) 1 166 0 0 49
PR #1868 3325 (93.5%) 1 166 62 0 49

#3140 is the strongest of the three. Two findings that apply to all of them:

1. The legacy **Key**: value regex still runs first, and it misfires on 4.7%

All three PRs keep

match = re.search(r"^\*\*[^*]+\*\*:\s*(.+)$", summary, re.MULTILINE)
if match:
    return match.group(1).strip()

ahead of the new logic. In our corpus that branch fires on 166 archives (4.7%) and returns 4 turns, 17 messages.

Those 166 are not WM v2 documents. Their entire .overview.md is three lines:

# Session Summary

**Overview**: 4 turns, 17 messages

which is the VLM-unavailable / WM-generation-failure fallback emitted at session.py:4157, 4168, 4230 and 4429. So for these the extractor is behaving correctly — the material is a stub. Worth separating in the fix: an extractor change cannot help them, and a # Session Summary + turn-count body is arguably better detected and reported than silently indexed. (Those failures are swallowed with logger.warning, so nothing surfaces them today.)

2. The v2 template asks the model to echo the italic guidance, which #3137 then returns

prompts/templates/compression/ov_wm_v2.yaml:50:

- All 7 section headers and italic descriptions must appear unchanged.

59 of 3,555 archives complied and kept _A short and distinctive 5-10 word descriptive title for the session. Info-dense, no filler._ as the first line under ## Session Title, with the real title on the next line. #3137 returns that guidance string as the abstract; #3140 and #1868 skip it correctly.

An extractor that skips _..._ lines is sufficient here (#3140 drops guidance leakage from 59-64 to 1), so the template does not have to change for this issue — but the two are coupled, and a fix that does not skip italics will regress on any session where the model follows the template.

Adjacent defect (separate from this issue)

The session-level .abstract.md (not history/archive_*/) is written by _generate_abstract() (session.py:5217), which is not an LLM summary at all:

if not self._messages:
    return ""
return f"{turn_count} turns, starting from '{first[:50]}...'"

At commit time the live buffer is normally already archived, so self._messages is empty. Measured: 719 of 754 session-level .abstract.md files are 0 bytes; the remaining 35 hold the turn-count string. I can open that as its own issue if useful.

Suggestion

Land #3140, and additionally either drop the legacy **Key**: value branch or gate it so it cannot match a turn-count stub — otherwise 4.7% of archives keep a useless abstract after the fix.

Happy to re-run the benchmark against any revised patch.

devstar-korea avatar Aug 23 '26 18:08 devstar-korea