Skip to content

fix(hindsight): clear _session_turns after retain to stop transcript duplication - #29555

Closed
AndyZHENG0715 wants to merge 1 commit into
NousResearch:mainfrom
AndyZHENG0715:fix/hindsight-sync-turn-clear-session-turns
Closed

fix(hindsight): clear _session_turns after retain to stop transcript duplication#29555
AndyZHENG0715 wants to merge 1 commit into
NousResearch:mainfrom
AndyZHENG0715:fix/hindsight-sync-turn-clear-session-turns

Conversation

@AndyZHENG0715

Copy link
Copy Markdown

The sync_turn() method appends each turn to _session_turns and, when the retain interval fires, constructs content from all accumulated turns before enqueueing the async retain. However _session_turns was never cleared after enqueue, so every subsequent retain re-sent every prior turn - causing quadratic transcript duplication over the session lifetime.

Fix: clear self._session_turns = [] immediately after enqueueing. The async writer thread uses frozen snapshot variables captured in the _do_retain closure, so clearing the source list has no effect on the in-flight retain.

Closes #23724

…duplication

The sync_turn() method appends each turn to _session_turns and, when
the retain interval fires, constructs content from all accumulated
turns before enqueueing the async retain. However _session_turns was
never cleared after enqueue, so every subsequent retain re-sent every
prior turn — causing quadratic transcript duplication over the session
lifetime.

Fix: clear self._session_turns = [] immediately after enqueueing.
The async writer thread uses frozen snapshot variables (content,
metadata_snapshot, num_turns) captured in the _do_retain closure, so
clearing the source list has no effect on the in-flight retain.

Closes: NousResearch#23724 (transcript duplication)
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers labels May 21, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #27280 — identical fix (clearing _session_turns after building retain content). Also competes with #23755 (same approach) and #27472 (more comprehensive delta-based fix). All target #23724.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hindsight plugin: sync_turn resends full session transcript on every retain, duplicating content with update_mode=append

2 participants