Skip to content

fix: resolve commitInFlight 404 bug and assistant role data loss#1167

Open
Boes-man wants to merge 1 commit intovolcengine:mainfrom
Boes-man:fix/openviking-memory-plugin-bugs
Open

fix: resolve commitInFlight 404 bug and assistant role data loss#1167
Boes-man wants to merge 1 commit intovolcengine:mainfrom
Boes-man:fix/openviking-memory-plugin-bugs

Conversation

@Boes-man
Copy link
Copy Markdown

@Boes-man Boes-man commented Apr 2, 2026

Summary

This PR fixes two critical bugs in the OpenCode memory plugin that affect session memory integrity.

Fix #1: commitInFlight not cleared on 404

Issue: When pollCommitTaskOnce() receives a 404 response (commit task not found), the error is caught but commitInFlight is never cleared. This causes auto-commit to stop working permanently for the session.

Fix: Added 404/expired task detection in the catch block to clear commit state via clearCommitState(mapping) so new commits can proceed normally.

Fix #2: Assistant role conditional on finish='stop' causes data loss

Issue: Assistant message roles were only stored when finish === "stop". However, assistant messages with tool calls complete with other finish types (e.g., "tool_calls"). This caused content to be captured in pendingMessages but never flushed to the OpenViking server because flushPendingMessages() requires both content AND role.

Fix: Removed the finish === "stop" condition - assistant roles are now stored regardless of finish value. Added logging for non-stop finish values for debugging.

Impact

Testing

Both fixes have been tested in a live OpenCode environment with OpenViking. The session-map.json showed 15-16 orphaned pendingMessages which were cleared after applying fix #2.

Fix volcengine#1: commitInFlight not cleared on 404
- In pollCommitTaskOnce(), when task not found (404/expired), clear
  commit state so new commits can proceed
- Previously, auto-commit would silently stop working for the session

Fix volcengine#2: assistant role conditional on finish='stop' causes data loss
- Assistant message roles now stored regardless of finish value
- Previously, assistant messages with tool calls (finish='tool_calls')
  had their content captured but role never stored, causing messages
  to be orphaned in pendingMessages and never flushed to OV server

Both fixes address critical bugs affecting session memory integrity.
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


d_n_w seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Failed to generate code suggestions for PR

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants