# fix\(server\): subagent threads settle with their parent instead of sweeping on their own · PR \#19665 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/19665)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: open

Source repository: Unavailable fork

Source branch: fix/subagent-settle-with-parent

Target branch: main

Head commit: 1ba181e4212606109d6dfe4ae22fd1aee5dea4a9

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/19665)

[Commits](https://git.cafe/pingdotgg/t3code/pull/19665/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/19665/diffs?format=markdown)

## Description

---

Hidden subagent threads were swept independently, including redundant pull-request lookups, while empty children could remain unsettled indefinitely. They now wait for their parent to settle, archive, disappear or be deleted, then settle once idle. Manual parent settlement also drains children when automatic settlement is disabled.

The SQL and memory candidate stores share the parent lifecycle rule. Children bypass inactivity and pull-request decisions while keeping busy checks, pins and per-thread opt-outs. Settlement/archive/delete events wake the worker; a service-local pending flag combines full-sweep bursts. Shared-parent-worktree children close idle terminals and skip the settle script; children in their own worktree keep the script. Only missing-parent read errors are recovered.

Fixes [#19657](https://github.com/pingdotgg/t3code/issues/19657), following the [accepted maintainer direction](https://github.com/pingdotgg/t3code/issues/19657#issuecomment-6180625268).

Maintainer takeover of [#19665](https://github.com/pingdotgg/t3code/pull/19665), crediting @mikeohuo for the parent-based candidate filter and cleanup rule. Their commits are preserved and main was merged. The takeover completes manual settlement with automation off and avoids repeated full sweeps during cleanup bursts.

Validation on the final implementation:

Two fresh adversarial review rounds by Claude Opus 5.5 and GPT-6-Sol; the first found repeated full sweeps during cleanup bursts, and the second found no blockers after coalescing.

- 90 tests passed in ProjectionSettlement.test.ts, ThreadSettlementService.test.ts and ProjectionStore.test.ts. Targeted four-file lint/format, server typecheck and git diff --check passed.
- PR-added tests: 4 → 6 cases, with two distinct missing behaviors added. The original merged implementation produced 88 passes and one failure for manual settlement globally off; that regression now passes. Temporarily reverting production to main produced five failures before implementation; all production files were restored afterward.
- A service event-stream test with 234 cleanup events plus child settlement produced 236 candidate reads before coalescing and three afterward; the child still settled and made no PR lookups.
- SQL/memory runtime tests cover active, settled, archived, deleted and missing parents. Worker runtime tests use real projection filtering and cover empty/recent children, busy retry, opt-outs, manual settlement, and shared/own-worktree cleanup. Dispatch and process boundaries are mocked.

[Before/after runtime proof](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/776441ff370db0d4/sidebar-threads-09-19665-proof.txt) · [Final focused test output](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/ec86b4df266c728a/sidebar-threads-09-19665-proof-final.log).

No screenshot applies to this hidden server lifecycle. A full app session with a fresh live provider/subagent spawn was not verified. macOS, Windows, iOS, Android and Electron desktop were not launched. No wire contract or client implementation changes are required. The pre-existing independent PR poller is outside this change.

Model: GPT-6.1-Sol. Harness: Codex in T3 Code. Tests: GPT-6-Astra. Independent adversarial reviews: Claude Opus 5.5 and GPT-6-Sol.

