Skip to content

Re-extracting a document takes back the described things it made, so an unchanged document adds no second copy of them or their statements - #1568

Merged
WaylandYang merged 2 commits into
devfrom
fix/reextract-reuses-described
Dec 2, 2026
Merged

WaylandYang merged 2 commits into
devfrom
fix/reextract-reuses-described

Conversation

@WaylandYang

Copy link
Copy Markdown
Contributor

Fixes the accumulation reported in #1534 (follow-up of #1532).

Why

One extraction run already reuses one entity per description across a document's chunks (described in extraction_open). A re-extraction started that map empty, so each round over an unchanged document made a new described entity for every description, plus a new statement pointing at it, because fact dedup keys on the object id. alitrack measured 12 → 53 described entities over six rounds of one 308-character contract, with 15 distinct descriptions.

What changes

  • resolution::described_entities_of_document returns the described things this document's live facts sit on, followed through merges to the survivor, one per exact description (the earliest made).
  • apply_open_extraction seeds described from it, so a description the model lists again is taken back instead of created anew.
  • Described things stay out of the prompt's known list and out of name recall, so a description still never crosses documents.
  • docs/design/extraction.md notes it next to the 文档处理过程中可重复触发抽取,导致大量重复实体,以及抽取进度和性能问题 #1513 seed.

Tests

  • reextracting_an_unchanged_document_reuses_what_it_described: two runs over the same replies keep one the harbour office and the same live fact count, and the rerun prompt still doesn't list it. It fails on dev with "re-extract made another harbour office: 2".
  • the_described_seed_is_this_documents_own: the same description made elsewhere in the base isn't seeded.
  • utopia-server: 830 passed against Postgres (UTOPIA_TEST_REQUIRE_DB=1); fmt and clippy -D warnings are clean.

🤖 Generated with Claude Code

…an unchanged document adds no second copy of them or their statements

One run already reuses one entity per description across a document's chunks. A re-extraction
started that map empty, so every round of an unchanged document made a new described entity
for each description and a new statement pointing at it (#1534: 12 -> 53 described entities
over six rounds). The map now starts from the described things this document's live facts sit
on, followed through merges, keyed by their exact description. They stay out of the prompt's
known list and out of name recall, so a description still never crosses documents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Wayland Yang <wayland@WaylanddeMacBook-Pro.local>
@WaylandYang
WaylandYang merged commit 380311f into dev Dec 2, 2026
6 checks passed
@WaylandYang
WaylandYang deleted the fix/reextract-reuses-described branch December 2, 2026 21:33
gedaiu added a commit to re-cinq/utopia that referenced this pull request Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant