Fix checkpoint data not pushed when agent commits and pushes in same turn#303
Open
danielweinmann wants to merge 4 commits intoentireio:mainfrom
Open
Fix checkpoint data not pushed when agent commits and pushes in same turn#303danielweinmann wants to merge 4 commits intoentireio:mainfrom
danielweinmann wants to merge 4 commits intoentireio:mainfrom
Conversation
…turn When an AI agent commits and pushes in the same turn, PostCommit defers condensation (ACTIVE → ACTIVE_COMMITTED) but PrePush has already pushed the stale entire/checkpoints/v1 branch. Condensation only runs at turn-end, after the push is long gone. Record the push remote in session state during PrePush, then push again at turn-end after condensation completes. Clear PendingPushRemote on new prompt start for Ctrl-C recovery. Ref entireio#275 Entire-Checkpoint: adb31abc2a46
…ndense Extract flushPendingPush helper and use defer to guarantee PendingPushRemote is cleared on all exit paths, not just the happy path after condensation. Entire-Checkpoint: 919ada5b9e3e
Entire-Checkpoint: 9624f3b6a506
a218081 to
1a885de
Compare
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
When an AI agent commits and pushes in the same turn, the session checkpoint data on
entire/checkpoints/v1is never included in that push — it's always one push behind.Root cause: PostCommit sees the session in
ACTIVEstate and defers condensation (ACTIVE → ACTIVE_COMMITTED, setsPendingCheckpointID). Condensation only happens later at turn-end (HandleTurnEnd). But by then, PrePush has already pushed the staleentire/checkpoints/v1branch.Timeline before this fix:
entire/checkpoints/v1entire/checkpoints/v1(too late)Approach: Instead of condensing mid-session (which would split session data and interfere with ongoing agent work), we record the push remote in session state during PrePush, then push again at turn-end after condensation completes. This preserves the existing condensation timing and works for both scenarios:
Changes
session/state.go: AddPendingPushRemotefield toStatestruct (follows same pattern asPendingCheckpointID)strategy/manual_commit_push.go: PrePush callsrecordPendingPushRemote()to record the remote on ACTIVE_COMMITTED sessions.flushPendingPush(called viadeferinhandleTurnEndCondense) pushes the metadata branch and clears the field on all exit paths.strategy/manual_commit_hooks.go: ClearsPendingPushRemoteinInitializeSessionon new prompt start (Ctrl-C recovery).strategy/manual_commit_push_test.go: 7 tests covering recording, skipping, full flow, cleanup, and the early-return regression.Ref #275
Test plan
entireon a test repo with a remote, start an agent session, have the agent commit and push in the same turn — verifyentire/checkpoints/v1is pushed with the condensed data (not stale)PendingPushRemoteis cleared and doesn't trigger a stale pushpush_sessionsin settings prevents the turn-end push (the setting is checked insidepushSessionsBranchCommon)