Skip to content

[upstream #16436] upstream PR #16436 follow-up: the disconnect snapshot save can reopen a just-settled turn #174

Description

@berry-13

Split out of the review of LibreChat-AI#16436 (local review on head f3e160f).

What happens

When the last SSE subscriber disconnects concurrently with the run settling (completion, error, or abort), the disconnect snapshot save in api/server/controllers/agents/request.js re-reads the job record and skips when isSettledJobRecord reports a settled status. That guard is a stale read: the settling path can transition the job and write the terminal row between the guard's read and the snapshot's saveMessage, and the snapshot then lands last, reopening the settled row as unfinished: true with marker-only content.

Expected

The snapshot write is conditional at the storage layer (for example, a filtered update that only applies while the row is not already settled), or the two writers are serialized, so a settled compaction turn cannot be reopened by a late disconnect snapshot.

Why it is out of scope for LibreChat-AI#16436

The guard shipped there covers the common ordering and documents the residual window; the atomic fix needs conditional updates in the shared message persistence layer (~/models saveMessage), which every writer uses and which LibreChat-AI#16436 does not touch.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: apireviewctl followups statearea: packagesreviewctl followups statebugSomething isn't workingreadyreviewctl followups state

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions