A second externalize_group pass re-externalizes an already externalized source read and shrinks its recorded size and digest

Aperta
#7,432 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Kiko0301 ci sta già lavorando.

Dal 11/11/2026.

  • #7420 di @Kiko0301 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
ai, backend

Direzione di ricerca

Read openviking/session/tool_output_externalizer.py, especially externalize_group, _rewrite_source_read_tool_output, and hydrate_for_extraction, then inspect the regression test described in the issue. Reproduce the second-pass rewrite and verify the original size and digest remain intact and hydration retrieves the full referenced output. PR #7420 is already open against this issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

A second externalize_group pass re-externalizes an already externalized source read

Bug Description

A session externalizes tool output twice for the same messages: Session.add_messages_async calls externalize_group when messages are added, and the commit path calls it again over build_turns(self._messages) for Turn-wide retention. ToolOutputExternalizer.externalize_group (openviking/session/tool_output_externalizer.py:313) runs _rewrite_source_read_tool_output() before checking the already-externalized guard (if part.tool_output_ref and part.tool_output_truncated: continue).

For an openviking_tool_result_read part, the first pass replaces the full read output with a preview and records the real size and digest in tool_output_original_chars / tool_output_sha256. On the second pass part.tool_output is already that preview, so _rewrite_source_read_tool_output (tool_output_externalizer.py:185) renders a preview of the preview and overwrites those fields:

  • tool_output_original_chars becomes the preview length instead of the full read size (this also shrinks group_original_chars, which recomputes from the same field);
  • tool_output_sha256 becomes the digest of the preview, not of the referenced content.

hydrate_for_extraction uses tool_output_original_chars as the read limit for source reads (tool_output_externalizer.py:139-148), so memory extraction is hydrated with only the first preview-sized slice of the original tool output while the stub digest claims to match it.

Steps to Reproduce

  1. Add an assistant Turn containing an openviking_tool_result_read part whose tool_output is a long tool result (e.g. 20,000 characters).
  2. Call externalize_group once (message add path) and then again over the same messages (commit path).
  3. Inspect tool_output_original_chars and tool_output_sha256, then hydrate the part.

Expected Behavior

The second pass leaves the part unchanged: the original size and digest still describe the full referenced tool output.

Actual Behavior

The second pass rewrites the preview; tool_output_original_chars equals the preview length and tool_output_sha256 is the preview digest, so hydration reads back only the preview-sized slice.

Environment

  • OS: Windows 11
  • OpenViking version/commit: main @ 95d96162

Additional Context

Fix submitted as PR #7420: the already-externalized guard runs before any rewrite, and the source-read rewrite is a no-op when tool_output_source_ref already points at the same reference (which also covers short reads where the first pass leaves truncated false). The regression test fails on unmodified main.

Lingua principale
Python
Stelle
41.8k
Fork
3.4k
Merge medio
19h 29m
PR unite (30g)
500

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di volcengine/OpenViking

Tutte le issue di volcengine/OpenViking

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.