Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(claude): preserve subagent task context snapshots #21644

Openjuliusmarmingewants to merge 2 commits intoclaude-context/client-support fromclaude-context/claude-adapteropened View on GitHub

juliusmarmingecommented

Claude task frames report context usage, but the adapter drops it before clients can display it. This layer maps the latest plain-task snapshot from progress and completion frames, including completion while the parent is idle. Empty-description progress can update usage without erasing text. Both ordinary resume and buffered-wake reopening clear stale snapshots; absent completion usage preserves the last report.

Depends on the client/contract layer #21643. Rebuilt from Gigioxx’s #15446, preserving its snapshot mapping and both reset paths while adapting to current idle-completion handling. Workflow lifetime totals remain separate and never appear as context snapshots. No cumulative sum, cost or maximum-window denominator is introduced. Related #15429 remains open.

Verification: adapter definitions 176→177 (expanded cases 286→287). One rebuilt lifecycle case and an extended existing two-variant wake case fail on main, then pass here: snapshots decrease, zero is retained, missing usage preserves it, both reopen paths clear it, and idle completion is captured. An existing workflow case was extended to catch context/lifetime conflation in active and idle progress; it failed before the review fix. All nine focused adapter cases pass (278 skipped); scoped server typecheck, targeted lint/format and diff checks pass with existing diagnostics only. Two fresh whole-stack review rounds by Claude Opus 5.5 and GPT-6 Sol completed; both reviewers found no blockers in the second round. Round one caught workflow lifetime totals mislabeled as context and stale lineage context beside a newer finished child run; both were reproduced and fixed. Reviewers also ran 50 selected adapter cases successfully (237 skipped).

Headless Linux proof uses the actual adapter harness with current SDK frame types, not a live Claude invocation. Integrated web proof is in #21643. No fresh provider/account, live workflow, macOS, Windows, iOS, Android, Electron desktop or remote/relay/tunnel execution was verified; those remain human verification limits.

Implemented with GPT-6.1 Sol through the Codex harness; tests by GPT-6 Astra; adversarial reviews by Claude Opus 5.5 and GPT-6 Sol through T3 Code delegation.

    1. juliusmarminge changed the title

    2. juliusmarminge added labelsmacroscope-review

    3. Approvability

      Verdict: Approved at 93c22b6

      Macroscope's review found this PR approvable — This is a narrowly scoped Claude adapter bug fix that populates an existing subagent context-usage field while preserving snapshot and resume semantics. Targeted tests cover idle completion, stale snapshot clearing, decreasing values, zero values, and separation from workflow totals.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire—5.0 KiB—6.8 KiB✅
      CodexThread snapshot wire—3.8 KiB—4.9 KiB✅
      CodexLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      CodexLive turn WebSocket decoded—20.9 KiB—29.3 KiB✅
      CodexLive turn messages—2—8✅
      ClaudeTotal thread wire—5.0 KiB—6.8 KiB✅
      ClaudeThread snapshot wire—3.8 KiB—4.9 KiB✅
      ClaudeLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      ClaudeLive turn WebSocket decoded—21.2 KiB—29.3 KiB✅
      ClaudeLive turn messages—2—8✅

      Baseline: unavailable · PR result: 93c22b6 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    5. Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Team
      • Run ID: 6898c358-69eb-4ae4-896b-55a33cbf74a1
      📥 Commits

      Reviewing files that changed from the base of the PR and between 90df6f1425d462c234423abeab9b51783340ed0e and 93c22b64a6ef44dd0a6b714a1cbcb40e317be9d0.

      📒 Files selected for processing: 2
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts

      Limit details: You’ve used all 10 included reviews currently available.

      📝 Walkthrough

      The Claude adapter now forwards usage totals from subagent progress and completion updates, clears usage when tasks are reopened, and updates workflow totals from workflow snapshots without assigning usage to workflow coordinators.

      Changes: Claude usage tracking

      Layer / File(s)Summary
      Subagent usage lifecycle
      apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
      Subagent progress and completion updates store token and tool-use counts. Reopened tasks clear previous progress and usage. Tests cover usage updates, empty progress descriptions, and resumed tasks.
      Workflow usage totals
      apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
      Workflow completion forwards usage, and workflow snapshot tests verify updated workflow totals while coordinator usage remains undefined.

      Priority: ⬇️ Low

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

      Change: Feature

      Suggested reviewers: maria-rcks

      Merge Risk: ⚪ Minimal · up to 93c22

      This change forwards subagent context usage and clears it on reopen. No actionable merge-blocking issues remain.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly identifies the main change: preserving Claude subagent task context snapshots.
      Description checkPassedThe description explains the problem, implementation, scope, dependencies, verification results, review coverage, and verification limits. It does not use the template headings or provide explicit mai…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Description check

      Explanation

      The description explains the problem, implementation, scope, dependencies, verification results, review coverage, and verification limits. It does not use the template headings or provide explicit maintainer approval, but the required information is substantially present.

      ✨ Finishing Touches
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Usage-based review receipt

      Note

      This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

      Comment `@coderabbitai help` to get the list of available commands.
    6. Validated current head 93c22b6 over #21643: current-head CI is green, with normal skipped jobs. The cancelled native fingerprint job was superseded by a successful run of the same workflow/head. Macroscope approved this head; CodeRabbit found no actionable comments, and there are no review threads. Both independent second-round full-stack reviews are clean. Provider/native/remote verification limits are explicit in the description. Ready for maintainer review; unmerged.

Sign in to join this conversation.