Bail cleanly on concurrent push to PR branch#2564
Merged
hiroshinishio merged 2 commits intomainfrom Apr 20, 2026
Merged
Conversation
On non-fast-forward push (racer advanced the branch), git_commit_and_push now returns GitCommitResult(concurrent_push_detected=True) instead of SystemExit. Tool wrappers propagate via FileWriteResult/FileMoveResult/FileDeleteResult, chat_with_agent surfaces via AgentResult and short-circuits remaining tool calls, handlers break the agent loop and skip the final empty commit so the racer's push owns CI. Handlers still run normal cleanup (update_usage, slack, accurate PR comment).
Follow-up to the previous commit: three test files still had stale assertions that didn't match the new dataclass return or the actual slack/workflows-block messages. Partial-assertion hook also required stricter exact-match checks in test_search_and_replace.py.
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
Adds concurrent-push detection to GitAuto's agent loop so that when another commit lands on a PR branch while GitAuto is working, GitAuto stops cleanly instead of continuing on stale state.
git_commit_and_pushreturns a newGitCommitResultdataclass; on non-fast-forward push it setsconcurrent_push_detected=Truewrite_and_commit_file,apply_diff_to_file,search_and_replace,move_file,delete_file) surface the flag viaFileWriteResult/FileMoveResult/FileDeleteResultchat_with_agentreads the flag on any tool result, sets it onAgentResult, and short-circuits remaining tool calls in the current turncheck_suite_handler,review_run_handler,new_pr_handlerbreak their agent loop on the flag, skip the forcedverify_task_is_completeand the final empty commit (racer's push already triggers CI), then run normal cleanup (usage record, slack, PR comment)get_branch_head_authorfetches the racer's author for log linesFinal PR comment reflects the race: "Another commit landed on `` while I was working. Their push triggers CI on its own, so I'm stopping here — your push stands."
Social Media Post (GitAuto)
Agent now detects a concurrent push to a PR branch and stops cleanly
Social Media Post (Wes)
When two webhooks hit the same PR branch close together, the second agent would happily keep editing on state the first push had already moved past. Added a typed race signal: the commit function flags it, every file-edit tool propagates it, the agent loop breaks the turn, the handler runs its normal finalize. Fewer confused PR statuses, no wasted tokens racing a push that already landed.