Repository navigation
Conversation
This branch has not been deployed
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.
What does this PR do?
When a foreground turn preempts a managed-local background review, the old worker may unwind after the foreground turn has queued its updated conversation. The old worker's retry then overwrites that newer pending review. The next reviewer receives the old conversation and misses the latest correction, contrary to the queue's documented newest-snapshot-wins contract.
Carry an internal monotonic snapshot creation timestamp through dispatch and requeue. Reject an incoming older snapshot when a newer item is already pending, while preserving the existing age-out timestamp and normal coalescing behavior.
Related Issue
Fixes #108539
Type of Change
Changes Made
agent/review_idle_queue.pyrun_agent.pytests/agent/test_review_requeue_order.pyHow to Test
Base:
7469c0f2a52baf70c574b110af0772b81bf84227.bash scripts/run_tests.sh tests/agent/test_review_requeue_order.py tests/agent/test_review_idle_queue.py tests/run_agent/test_background_review.py tests/run_agent/test_background_review_cache_parity.py --file-retries 0 -j 3 -q python -m ruff check . python scripts/check_compat_pointers.py python scripts/check-windows-footguns.py agent/review_idle_queue.py run_agent.py tests/agent/test_review_requeue_order.py git diff --checkNew regression on unmodified main: 2 failed, 1 passed (the already-correct opposite arrival order). With the fix: all 3 passed. Final related suite: 44 passed; additional session/memory/toolset regression: 29 passed.
Ruff, compatibility-pointer checks, changed-file Windows checks and whitespace checks passed. No effective test was removed or skipped to obtain a passing result.
Compatibility and limitations
The test drives the real queue and AIAgent requeue method in both arrival orders, plus an actual worker thread for timestamp propagation; the managed-endpoint classifier and model execution are substituted. This protects a newer pending item and does not claim to serialize every reviewer or cross-session memory write.
Duplicate check
Searched all states for
_maybe_requeue_preempted_review, background review/requeue, and review/snapshot/stale. #108260 addresses queue memory bounds. #101074 fixes shallow snapshot aliasing. #9055 / #39806 guard memory/skill writes against live-state changes; they do not prevent the queue from discarding the newer pending review. This change is confined to pending-item selection, not a global stale-write guard.Checklist
scripts/run_tests.sh.