Skip to content

fix(server): skip auto-settlement while user messages are queued - #37517

Closed
dajiaohuang wants to merge 3 commits into
pingdotgg:mainfrom
dajiaohuang:fix/queued-auto-settlement
Closed

dajiaohuang wants to merge 3 commits into
pingdotgg:mainfrom
dajiaohuang:fix/queued-auto-settlement

Conversation

@dajiaohuang

@dajiaohuang dajiaohuang commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 16, 2026
@dajiaohuang
dajiaohuang marked this pull request as ready for review November 16, 2026 06:23
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

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.
Update candidate selection tests
apps/server/src/orchestration-v2/ProjectionSettlement.test.ts
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.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#27058: Updates automatic-settlement eligibility for held queued runs in the same candidate-selection logic.

Suggested labels: bugfix

Suggested reviewers: juliusmarminge, t3dotgg, macroscopeapp

Merge Risk: Minimal · previous review bb7e9

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c1b23e9 and bb7e9f6.

Files selected for processing: 2

  • apps/server/src/orchestration-v2/ProjectionSettlement.test.ts
  • apps/server/src/orchestration-v2/ProjectionStore.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 16, 2026
…ement

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

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.

It stays open for a person to finish or close.

@juliusmarminge juliusmarminge added takeover:blocked Takeover blocked; reason in the PR body takeover:in-progress A takeover lead is working on this PR and removed takeover:in-progress A takeover lead is working on this PR takeover:blocked Takeover blocked; reason in the PR body labels Nov 16, 2026
…ement

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge
juliusmarminge force-pushed the fix/queued-auto-settlement branch from 091a05a to cacdd9b Compare November 16, 2026 15:51
@juliusmarminge juliusmarminge added takeover:needs-julius Takeover done; route gate says Julius decides and removed takeover:in-progress A takeover lead is working on this PR labels Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). takeover:needs-julius Takeover done; route gate says Julius decides vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants