You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(server): skip auto-settlement while user messages are queued - #37517
Automatic settlement repeatedly attempts to settle idle threads with held user messages. The orchestrator rejects each attempt, but the next sweep selects the same threads again. In a desktop server trace I found 460 rejected dispatches across 13 threads over 73 minutes; a representative sanitized error was:
automatic settlement -> thread.settle
Thread <id> has a queued message. Send it or remove it from the queue before settling.
Exclude threads with queued user-authored runs from the settlement candidate query, while retaining automatic queued messages that settlement already handles. The dispatch-time guard remains in place for races.
Verification:
On base 45dedf2, the extended SQLite projection test failed because the queued-user thread was returned as a candidate. With this change it passes and an agent-created queued message remains eligible.
vp test run apps/server/src/orchestration-v2/ProjectionSettlement.test.ts: 6 passed.
vp run check:changed --concurrency 1: passed, including 68 tests. The first parallel run had a Knip process fail with a Node memory allocation error; the serial run passed both Knip checks.
This changes background server selection and logging; there is no changed web presentation to capture or browser assertion for this failure.
Independent validation on exact head bb7e9f602279ef61d0f2bb0ad9f8bc9f9077327b (GPT-6 Luna high, Codex): Node 26.13.1; vp test run apps/server/src/orchestration-v2/ProjectionSettlement.test.ts passed (6/6); vp run check:changed 45dedf29558eb129d2cf86cbf93a3f484ecf3abe --concurrency 1 passed (format, lint, both Knip checks, GraphQL, three-package typecheck, 68 tests). Lint reported one warning in unchanged code at ProjectionStore.ts:7297.
Code: GPT-6.1 Terra (medium), Codex.
Reviewing files that changed from the base of the PR and between 91c65a0 and cacdd9b.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Settlement candidate selection now distinguishes queued runs by their referenced messages. Tests update the expected candidate set to exclude the user-authored queued thread and include the automatically generated queued thread.
Changes: Settlement candidate selection
Layer / File(s)
Summary
Filter queued runs by message apps/server/src/orchestration-v2/ProjectionStore.ts
getSettlementCandidates checks the referenced message, authorship, and metadata when evaluating a thread with a queued run.
The test expectations distinguish the user-authored queued thread from the automatically generated queued thread. The shell comparison also excludes the user-authored queued thread.
Auto-settlement now skips threads with queued user messages, which stops repeated rejected dispatches. Automatic queued messages remain eligible. The change is tested and has no identified merge-blocking risk.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: automatic settlement is skipped while user-authored messages are queued. The raw summary shows ProjectionStoreV2.getSettlementCandidates now excludes threads with queu…
Description check
The description covers the problem (automatic settlement repeatedly retries idle threads with held user messages, with reproduction evidence and an error excerpt), the change (excluding threads with q…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: automatic settlement is skipped while user-authored messages are queued. The raw summary shows ProjectionStoreV2.getSettlementCandidates now excludes threads with queued user-authored runs, and the tests were updated to match. The title uses the conventional commit form with a clear scope.
Full details: Description check
Explanation
The description covers the problem (automatic settlement repeatedly retries idle threads with held user messages, with reproduction evidence and an error excerpt), the change (excluding threads with queued user-authored runs from the candidate query while keeping automatic queued messages eligible), and verification (specific test commands, results, and an independent validation run). It also addresses the web/UI screenshot requirement by stating there is no changed web presentation. The Scope section is weak: it does not link an issue or explain why no issue is needed, and it does not state whether a maintainer requested the PR. The description also reports a Knip memory failure without explaining it, and the model attribution line is present.
Resolution
Optionally add to the Scope section a link to the bug issue, or a short reason why no issue is needed for this fix. Also state whether a maintainer requested the PR.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The automated pipeline stopped on this pull request and will not merge it:
in the real app the problem is still there, and the rework changed nothing:
No change was needed. The item's own steps show the same final state on both sides: thirteen held user queues kept, those threads unsettled, the idle control settled. That is the expected outcome on base and on the fix, because on base the thread.settle guard (reached through thread.auto-settle) already rejects threads with a queued user message. The fix only stops the sweep from selecting those threads and sending dispatches the guard rejects; it never changes what ends up settled. The item gives no rejected-dispatch counts for either side, so it doesn't show the fix failing at that. I checked on real orchestrator state with a temporary probe in the existing runtime test 'settles past held automatic messages but preserves a held user queue', which builds held queued user and agent messages after a restart. On base, getSettlementCandidates returns the thread, and isAutoSettlementCandidate plus resolveAutoSettlementAt (8 days later, 7-day window) return a settlement time, so the sweep dispatches thread.auto-settle and the guard rejects it. With the fix, getSettlementCandidates returns no threads, so no dispatch is sent. I removed the probe because the existing ProjectionSettlement test already covers this case and fails on base. The head is unchanged; CI was green on it with no review findings.
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
size:S10-29 changed lines (additions + deletions).takeover:needs-juliusTakeover done; route gate says Julius decidesvouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
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.
Automatic settlement repeatedly attempts to settle idle threads with held user messages. The orchestrator rejects each attempt, but the next sweep selects the same threads again. In a desktop server trace I found 460 rejected dispatches across 13 threads over 73 minutes; a representative sanitized error was:
Exclude threads with queued user-authored runs from the settlement candidate query, while retaining automatic queued messages that settlement already handles. The dispatch-time guard remains in place for races.
Verification:
On base
45dedf2, the extended SQLite projection test failed because the queued-user thread was returned as a candidate. With this change it passes and an agent-created queued message remains eligible.vp test run apps/server/src/orchestration-v2/ProjectionSettlement.test.ts: 6 passed.vp run check:changed --concurrency 1: passed, including 68 tests. The first parallel run had a Knip process fail with a Node memory allocation error; the serial run passed both Knip checks.This changes background server selection and logging; there is no changed web presentation to capture or browser assertion for this failure.
Independent validation on exact head
bb7e9f602279ef61d0f2bb0ad9f8bc9f9077327b(GPT-6 Luna high, Codex): Node26.13.1;vp test run apps/server/src/orchestration-v2/ProjectionSettlement.test.tspassed (6/6);vp run check:changed 45dedf29558eb129d2cf86cbf93a3f484ecf3abe --concurrency 1passed (format, lint, both Knip checks, GraphQL, three-package typecheck, 68 tests). Lint reported one warning in unchanged code atProjectionStore.ts:7297.Code: GPT-6.1 Terra (medium), Codex.