fix(acp): preserve persisted session history on save failures#13675
Closed
Junass1 wants to merge 1 commit into
Closed
fix(acp): preserve persisted session history on save failures#13675Junass1 wants to merge 1 commit into
Junass1 wants to merge 1 commit into
Conversation
This was referenced May 5, 2026
teknium1
pushed a commit
that referenced
this pull request
May 5, 2026
ACP's save_session() did a non-atomic clear_messages() + append_message() loop. If any message hit an exception mid-loop (bad tool_call shape, etc.), the DELETE had already committed and the persisted conversation was lost. SessionDB.replace_messages() wraps DELETE + bulk INSERT in a single BEGIN IMMEDIATE transaction that rolls back on any exception, so a bad message can no longer clobber previously-persisted history. Salvages @Awsh1's PR #13675 — uses the existing replace_messages() helper (which covers more message fields than the PR's own copy) instead of adding a duplicate.
teknium1
pushed a commit
that referenced
this pull request
May 5, 2026
ACP's save_session() did a non-atomic clear_messages() + append_message() loop. If any message hit an exception mid-loop (bad tool_call shape, etc.), the DELETE had already committed and the persisted conversation was lost. SessionDB.replace_messages() wraps DELETE + bulk INSERT in a single BEGIN IMMEDIATE transaction that rolls back on any exception, so a bad message can no longer clobber previously-persisted history. Salvages @Awsh1's PR #13675 — uses the existing replace_messages() helper (which covers more message fields than the PR's own copy) instead of adding a duplicate.
RationallyPrime
pushed a commit
to RationallyPrime/hermes-agent
that referenced
this pull request
May 8, 2026
ACP's save_session() did a non-atomic clear_messages() + append_message() loop. If any message hit an exception mid-loop (bad tool_call shape, etc.), the DELETE had already committed and the persisted conversation was lost. SessionDB.replace_messages() wraps DELETE + bulk INSERT in a single BEGIN IMMEDIATE transaction that rolls back on any exception, so a bad message can no longer clobber previously-persisted history. Salvages @Awsh1's PR NousResearch#13675 — uses the existing replace_messages() helper (which covers more message fields than the PR's own copy) instead of adding a duplicate.
RationallyPrime
pushed a commit
to RationallyPrime/hermes-agent
that referenced
this pull request
May 8, 2026
… existing messages on encode failure
nickdlkk
pushed a commit
to nickdlkk/hermes-agent
that referenced
this pull request
May 11, 2026
ACP's save_session() did a non-atomic clear_messages() + append_message() loop. If any message hit an exception mid-loop (bad tool_call shape, etc.), the DELETE had already committed and the persisted conversation was lost. SessionDB.replace_messages() wraps DELETE + bulk INSERT in a single BEGIN IMMEDIATE transaction that rolls back on any exception, so a bad message can no longer clobber previously-persisted history. Salvages @Awsh1's PR NousResearch#13675 — uses the existing replace_messages() helper (which covers more message fields than the PR's own copy) instead of adding a duplicate.
nickdlkk
pushed a commit
to nickdlkk/hermes-agent
that referenced
this pull request
May 11, 2026
… existing messages on encode failure
rmulligan
pushed a commit
to rmulligan/hermes-agent
that referenced
this pull request
May 11, 2026
ACP's save_session() did a non-atomic clear_messages() + append_message() loop. If any message hit an exception mid-loop (bad tool_call shape, etc.), the DELETE had already committed and the persisted conversation was lost. SessionDB.replace_messages() wraps DELETE + bulk INSERT in a single BEGIN IMMEDIATE transaction that rolls back on any exception, so a bad message can no longer clobber previously-persisted history. Salvages @Awsh1's PR NousResearch#13675 — uses the existing replace_messages() helper (which covers more message fields than the PR's own copy) instead of adding a duplicate.
rmulligan
pushed a commit
to rmulligan/hermes-agent
that referenced
this pull request
May 11, 2026
… existing messages on encode failure
JinyuID
pushed a commit
to JinyuID/hermes-agent
that referenced
this pull request
May 11, 2026
ACP's save_session() did a non-atomic clear_messages() + append_message() loop. If any message hit an exception mid-loop (bad tool_call shape, etc.), the DELETE had already committed and the persisted conversation was lost. SessionDB.replace_messages() wraps DELETE + bulk INSERT in a single BEGIN IMMEDIATE transaction that rolls back on any exception, so a bad message can no longer clobber previously-persisted history. Salvages @Awsh1's PR NousResearch#13675 — uses the existing replace_messages() helper (which covers more message fields than the PR's own copy) instead of adding a duplicate.
JinyuID
pushed a commit
to JinyuID/hermes-agent
that referenced
this pull request
May 11, 2026
… existing messages on encode failure
jsboige
pushed a commit
to jsboige/hermes-agent
that referenced
this pull request
May 14, 2026
ACP's save_session() did a non-atomic clear_messages() + append_message() loop. If any message hit an exception mid-loop (bad tool_call shape, etc.), the DELETE had already committed and the persisted conversation was lost. SessionDB.replace_messages() wraps DELETE + bulk INSERT in a single BEGIN IMMEDIATE transaction that rolls back on any exception, so a bad message can no longer clobber previously-persisted history. Salvages @Awsh1's PR NousResearch#13675 — uses the existing replace_messages() helper (which covers more message fields than the PR's own copy) instead of adding a duplicate.
jsboige
pushed a commit
to jsboige/hermes-agent
that referenced
this pull request
May 14, 2026
… existing messages on encode failure
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
ACP's save_session() did a non-atomic clear_messages() + append_message() loop. If any message hit an exception mid-loop (bad tool_call shape, etc.), the DELETE had already committed and the persisted conversation was lost. SessionDB.replace_messages() wraps DELETE + bulk INSERT in a single BEGIN IMMEDIATE transaction that rolls back on any exception, so a bad message can no longer clobber previously-persisted history. Salvages @Awsh1's PR NousResearch#13675 — uses the existing replace_messages() helper (which covers more message fields than the PR's own copy) instead of adding a duplicate.
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
… existing messages on encode failure
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
ACP's save_session() did a non-atomic clear_messages() + append_message() loop. If any message hit an exception mid-loop (bad tool_call shape, etc.), the DELETE had already committed and the persisted conversation was lost. SessionDB.replace_messages() wraps DELETE + bulk INSERT in a single BEGIN IMMEDIATE transaction that rolls back on any exception, so a bad message can no longer clobber previously-persisted history. Salvages @Awsh1's PR NousResearch#13675 — uses the existing replace_messages() helper (which covers more message fields than the PR's own copy) instead of adding a duplicate.
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
… existing messages on encode failure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SessionDB.replace_messages()to atomically rewrite a session's messages.Why
ACP session persistence previously cleared stored messages before appending the current in-memory history. If one of the later appends failed, for example because structured tool call data could not be serialized, the already persisted conversation was lost. That could break session restore after an editor/server restart.
The new path pre-serializes message fields before the write transaction, then deletes and inserts messages in one transaction. Bad input now leaves the previously persisted conversation intact.
Test Plan
uv run --extra dev python -m pytest tests/acp/test_session.py::TestPersistence::test_save_session_preserves_existing_messages_on_append_failure -quv run --extra dev python -m pytest tests/acp/test_session.py -qgit diff --check -- acp_adapter/session.py hermes_state.py tests/acp/test_session.py