# feat\(server\): t3_thread_launch takes clientRequestId · PR \#16654 · pingdotgg/t3code

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

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

Visibility: public

State: open

Source repository: pingdotgg/t3code

Source branch: t3code/peer/launch-request-key

Target branch: t3code/peer/mode-limit-header

Head commit: 071e6616495613844a1ff062446e41b4fc586d22

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

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

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

## Description

---

Replacement: [#21459](https://github.com/pingdotgg/t3code/pull/21459), based on main. This original is closed in favor of the replacement. GitHub refused its base change while it remained in its pre-existing stack.

A retried `t3_thread_launch` allocated another thread when the first response was lost. Optional `clientRequestId` now derives caller-scoped command, thread, and message identities so the existing launch receipt replays the original result. Omitting the key still creates a new launch.

The caller/key tuple is JSON-encoded before SHA-256 hashing, preserving lone UTF-16 surrogates without merging them with the replacement character. Bounded IDs avoid long-key failures when naming Scratch folders. Workspace preflight uses the accepted receipt so a retry survives removal of its original base branch or existing worktree. A changed worktree path still undergoes membership validation. Accepted retries use the stored model even after the project default changes; new launches still require a valid workspace and model. Agent initial-message dispatch also enforces the requested runtime and interaction limits under the command lock: a retry cannot start work on an existing thread with broader modes.

Maintainer replacement of juliusmarminge’s [#16654](https://github.com/pingdotgg/t3code/pull/16654). GitHub prevents retargeting that PR while it belongs to its existing 13-PR stack, and unstacking would affect unrelated PRs. This one-layer replacement is based on main and excludes the inherited mode-header feature. Its source tree is byte-for-byte identical to the reviewed and live-tested takeover head [42210fc516](https://github.com/pingdotgg/t3code/commit/42210fc51661a31ff03727acd38446be84334765); only branch ancestry changed. The original PoC request-key encoding changed, so receipts created by that unreleased encoding are not replay-compatible.

Focused suites: **86 → 88 passing tests** across the existing handler and launch-service files. Tests cover caller-scoped retry identity, lone-surrogate keys, long-key Scratch folders, narrower agent retries, and accepted workspace retries after the original branch/worktree disappears. Two mocked preflight tests were replaced by integrated receipt-replay cases, and an existing cross-project test now also covers caller-supplied IDs. Server, contracts, and provider-core typechecks, scoped lint and formatting pass (one pre-existing lint warning). Three adjacent MCP suites also pass: 97 tests.

Live proof on headless Linux used HTTP MCP, two isolated OAuth clients, and disposable state. Same-key retries returned the same thread; separate keys, callers, and omitted keys remained distinct. A lone surrogate key retried successfully and stayed distinct from the replacement character. The database contained thirteen unique resulting threads with one accepted creation receipt each and zero provider runs. Both 255-character Scratch keys with the same suffix succeeded. Accepted retries still returned the original thread after deleting a base branch or removing an existing worktree; new invalid launches were rejected. Clearing the project default preserved the original thread/model on retry while a fresh launch failed. Retrying with a changed path outside the project worktrees was rejected. No initial messages were sent.

[Before: retry allocates a second thread](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/ae504cb34697f4a7/sidebar08-16654-live-before.json) · [After: key replay and fresh launches](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/78d0712e66c47c92/sidebar08-16654-live-after.json) · [Caller and Unicode boundaries](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/431fb66e337073d3/sidebar08-16654-live-boundaries.json) · [Persisted receipts and zero runs](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/100aede9c766c406/sidebar08-16654-live-receipts-final.json)

Scratch: [before](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/33df90657ff5a982/sidebar08-16654-scratch-before.json) / [after](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/05569a70883dfeab/sidebar08-16654-scratch-after.json). Deleted base: [before](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/8ffd6399f4e41048/sidebar08-16654-worktree-before.json) / [after](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/1c1618e709a02259/sidebar08-16654-worktree-after.json). [Removed existing worktree](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/3edc5d2ae282e287/sidebar08-16654-existing-after.json).

Default model: [before](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/9880f01d856d68b3/sidebar08-16654-default-before.json) / [after](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/793cd7afea92a33e/sidebar08-16654-round2-after.json). Changed workspace: [before](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/a1c1276a5d76916b/sidebar08-16654-changed-workspace-before.json) / [after](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/793cd7afea92a33e/sidebar08-16654-round2-after.json).

Independent full-diff reviews: three paired rounds with Claude Opus 5.5 and GPT-6 Sol, followed by a fresh Sol clarification review. Confirmed findings fixed: malformed/long keys, workspace checks before accepted replay, the cleared model default, and changed-worktree validation. Final reviewers found no code blockers. The changed-payload objection was withdrawn because retries explicitly require the same payload; no persistent payload manifest was added.

Not verified in this pass: peer forwarding across two environments, relay/tunnel transport, actual provider turns, macOS, Windows, iOS, Android, or Electron desktop. Dispatch-mode protection is covered by the focused service regression, not a live provider run.

Implementation: GPT-6.1 Sol through the Codex harness in T3 Code; tests: GPT-6 Astra; reviews: Claude Opus 5.5 and GPT-6 Sol.

