# fix\(claude\): reconcile stopped tasks after session replacement · PR \#21725 · pingdotgg/t3code

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

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

Visibility: public

State: open

Source repository: pingdotgg/t3code

Source branch: claude-13/claude-task-receipts

Target branch: claude-13/native-task-reconciliation

Head commit: 7d26aae48cf644526eff70b6d4ae0bdcd57b6620

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

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

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

## Description

---

## Problem

Claude resume transcripts and raw SDK task notifications can report a stopped subagent that is absent from the replacement process’s registry. Those receipts currently disappear, leaving the durable task and thread showing running work.

## Change

Emit [#21724](https://github.com/pingdotgg/t3code/pull/21724)’s native-task terminal receipt for unregistered task notifications, including synthetic transcript XML. Keep known shell tasks on their existing path and continue normal handling of the original source frame, preserving prompt echoes, goal feedback, and wake buffering. Ignore parsed transcript outcomes for registered agents, whose raw SDK lifecycle is authoritative, so a stale replay cannot cancel resumed work.

Rebuilt from @luke2x’s [original contribution](https://github.com/pingdotgg/t3code/pull/17921), with author credit in both replacement PRs and Co-authored-by attribution in the carried commits. Please preserve Luke’s release-note credit when this lands.

## Scope and approval

Addresses the accepted session-replacement gap in [#18877](https://github.com/pingdotgg/t3code/issues/18877), which prompted the maintainer to [reopen the original PR](https://github.com/pingdotgg/t3code/pull/17921#issuecomment-6136282276). Stop without a terminal receipt remains outside scope. Live authenticated handoff and native-client verification remain outstanding; the evidence below is integrated SDK replay. Prepared for review, unmerged. The foundation layer still requires human approval for its orchestration lifecycle changes; previous bot approval is not a substitute for that decision.

## Verification

[Current-head CI results](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/71a7cdb74d324a24/17921-final-ci-proof.json): latest complete validation passed on both heads; CodeRabbit completed, with all actionable threads fixed or explained and resolved. The upper layer has an older superseded run whose aggregate check failed solely because its dependencies were cancelled. Scoped optional jobs were skipped; cancelled duplicates are not reported as passing. Human lifecycle approval remains outstanding.

- [Full focused stack: 448 passed](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/fbe2f552990911cc/17921-implementation-r2-integrated-tests.log); server typecheck, targeted lint and formatting passed. Both layers were reviewed independently and together.
- [Before-fix SDK replay](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/06b720844bdc7b04/17921-top-red.log): both raw and synthetic stopped receipts reach a following persisted SDK milestone, then fail immediately because the durable task remains running.
- [Primary after proof](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/dfaca8b99084e334/17921-proof-final.json): both receipt forms pass through the production Claude adapter, session manager, ingestor, orchestrator/effect worker and SQLite after runtime replacement. Assertions check the task stays running before a terminal receipt and then settles with its parent/child work, original owner, result, and timestamps. Adapter coverage retains source-frame handling and excludes quoted user text and known shell tasks. A mutation restoring the historical early return fails that regression.
- [Registered replay regression before the fix](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/ab1940808e463d9c/17921-test-r2-final-red.log): raw stop, authoritative resume, then two XML replays incorrectly add two cancelled updates. The existing source-frame case now proves resumed work stays running until a new raw terminal event.
- Five added cases plus one strengthened existing case replace eight original cases, with all main cases preserved; the one-off integration file is removed. This is a backend correction, so screenshots are not applicable. The external SDK stream is stubbed; no live authenticated Claude handoff or macOS, Windows, Electron desktop, iOS, Android, or remote/tunnel verification was performed.

Models/harness: GPT-6 Astra for test reduction, GPT-6.1 Sol for implementation/integration (Codex); three independent full-stack review rounds by Claude Opus 5.5 (Claude Code) and GPT-6 Sol (Codex); both final reviewers found no code issues, including the replay and browser-test fixes.

