Skip to content

Fix checkpoint data not pushed when agent commits and pushes in same turn#303

Open
danielweinmann wants to merge 4 commits intoentireio:mainfrom
danielweinmann:fix/push-checkpoint-data-same-turn
Open

Fix checkpoint data not pushed when agent commits and pushes in same turn#303
danielweinmann wants to merge 4 commits intoentireio:mainfrom
danielweinmann:fix/push-checkpoint-data-same-turn

Conversation

@danielweinmann
Copy link

Summary

When an AI agent commits and pushes in the same turn, the session checkpoint data on entire/checkpoints/v1 is never included in that push — it's always one push behind.

Root cause: PostCommit sees the session in ACTIVE state and defers condensation (ACTIVE → ACTIVE_COMMITTED, sets PendingCheckpointID). Condensation only happens later at turn-end (HandleTurnEnd). But by then, PrePush has already pushed the stale entire/checkpoints/v1 branch.

Timeline before this fix:

  1. Agent commits → PostCommit: ACTIVE → ACTIVE_COMMITTED (deferred)
  2. Agent pushes → PrePush: pushes stale entire/checkpoints/v1
  3. Turn ends → HandleTurnEnd: condenses to entire/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:

  • Agent commits + pushes in same turn
  • Human pushes in separate tab while agent is active

Changes

  • session/state.go: Add PendingPushRemote field to State struct (follows same pattern as PendingCheckpointID)
  • strategy/manual_commit_push.go: PrePush calls recordPendingPushRemote() to record the remote on ACTIVE_COMMITTED sessions. flushPendingPush (called via defer in handleTurnEndCondense) pushes the metadata branch and clears the field on all exit paths.
  • strategy/manual_commit_hooks.go: Clears PendingPushRemote in InitializeSession on 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

  • Enable entire on a test repo with a remote, start an agent session, have the agent commit and push in the same turn — verify entire/checkpoints/v1 is pushed with the condensed data (not stale)
  • Verify that a normal human workflow (commit in one terminal, push later) is unaffected — PendingPushRemote stays empty for IDLE sessions
  • Simulate Ctrl-C after a push but before turn-end, then start a new prompt — verify PendingPushRemote is cleared and doesn't trigger a stale push
  • Verify that disabling push_sessions in settings prevents the turn-end push (the setting is checked inside pushSessionsBranchCommon)

@danielweinmann danielweinmann requested a review from a team as a code owner February 12, 2026 13:57
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants