Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): a mid-turn usage update no longer hides a failed probe #15116

Mergedandrewwbuilds(GitHub profile, opens in a new tab)merged 7 commits intomain fromrefs/pull/15116/headmerged by juliusmarminge View on GitHub

A failed limits probe could appear successful after a turn streamed one usage window. The partial list could then survive later failed probes as though it were a complete account read.

Sparse updates now preserve the failed-probe marker and message, including when no snapshot exists yet. Unchanged updates preserve snapshot identity, avoiding repeated publication on token-usage ticks. A successful full probe clears the marker through the existing refresh path. The change is shared by the Claude and Codex adapters; web, desktop, and mobile already interpret that marker.

Fixes #12170. Maintainer takeover of this PR, with credit to @andrewwbuilds for the original diagnosis and fix. Contributor commits are preserved and current main was merged into the branch.

Verification:

  • PR-added tests reduced from three to two in the existing usage-limits and managed-provider suites; 19 tests pass.
  • Without the fix, both regressions fail and the other 17 tests pass. With it, the real managed-provider service preserves the failure message, suppresses unchanged updates, handles another failed probe, and recovers on a full successful probe.
  • Changed-file lint and formatting, plus the provider-core typecheck, pass.
  • Independent full-diff review: Claude Opus 5.5 and GPT-6-Sol both found no blockers in round one at 18b3ef8a0e.

This is a server-state correction with no visual change. Verification used the actual managed-provider service headlessly with deterministic probe results. Live provider credentials/failures, Electron, macOS, Windows, iOS, and Android were not exercised.

Tests: GPT-6-Astra; implementation: GPT-6.1-Sol; independent reviews: Claude Opus 5.5 and GPT-6-Sol. Codex and Claude harnesses through T3 Code.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 18b3ef8

      Macroscope's review found this PR approvable — This is a narrowly scoped server-state bug fix with regression tests: failed or partial usage probes remain visibly unavailable instead of being presented as complete limits, while successful probes still recover normally. It does not alter schemas, defaults, deployment behavior, or static-analysis configuration.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. juliusmarminge added labelsmacroscope-review

    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      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: Advanced
      • Run ID: 8619f12c-87b3-41fe-9130-ea348daf32d8
      📥 Commits

      Reviewing files that changed from the base of the PR and between 95ef0daa31893a5c058a98419188e17ef7093dbf and 702bb7a17f5f5285bf9837cfc89d3fc1fdc7fbae.

      📒 Files selected for processing (1)
      • packages/provider-core/src/server/managedProvider.test.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.

      📝 Walkthrough

      Usage limit updates now retain probeFailed when streamed windows are merged into a failed or absent snapshot. Tests cover unchanged updates, repeated failed probes, and a later successful probe.

      Changes: Usage limit updates

      Layer / File(s)Summary
      Sparse usage update handling
      packages/provider-core/src/server/usageLimits.ts, packages/provider-core/src/server/usageLimits.test.ts, packages/provider-core/src/server/managedProvider.test.ts
      Changed windows retain the previous unavailable status, or receive probeFailed when no snapshot exists. Unchanged updates return the existing snapshot. Tests cover streamed updates after failed probes and later probe results.

      Priority: ➖ Normal

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

      Change: Bug fix · Severity of issue fixed: Medium

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to 702bb

      This change keeps a failed usage-limit read marked as failed when streamed windows arrive mid-turn, instead of showing a partial list as complete. It is narrow and tested, and I found no merge-blocking risk.

      Security Architecture Review

      Security architecture risk: ⚪ Minimal · up to 702bb

      The change preserves failure status and prevents partial usage data from appearing complete. The reviewed implementation introduces no new access path or privileges and leaves account-switch protections intact.

      Retained concerns No architecture-level concerns identified.

      Security review details

      Security Blast Radius

      • inferred — The demonstrated changed outcome is provider usage-status publication and downstream account-limit presentation. The modified helper does not introduce an identity transition, credential operation, tool execution, or new privileged sink.

      Trust Boundaries and Controls

      • observed — The runtime-update API carries no account or workspace provenance. Its existing caller merges into the current snapshot, while account-switch checks apply to probe results. Delayed-event attribution remains an unverified pre-existing limitation, not an introduced or worsened boundary change established by this review.

      Resilience and Maintainability Implications

      • observed — Refresh serialization and enrichment-generation checks remain in place. Snapshot mutation precedes publication, so strict externally observed ordering during overlapping refresh and runtime updates is not established by the inspected tests; this ordering mechanism is unchanged.
      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Linked Issues checkPassedIssue #12170 requires a streamed Claude usage update after a failed probe to remain unavailable instead of appearing as a complete window list. The change preserves previous.unavailable, marks a spa…
      Out of Scope Changes checkPassedThe changes are limited to usage-limit merge behavior, its documentation, and focused tests. These changes directly support issue #12170. No unrelated client, contract, or product behavior is added.
      Title checkPassedThe title is concise, uses the conventional commit format, and clearly identifies the server fix for failed-probe handling during mid-turn usage updates.
      Description checkPassedThe description explains the problem, fix, scope, linked issue, approval context, focused verification, broader test results, and known limitations. It does not use the template headings, but it provi…
      Full details: Linked Issues check

      Explanation

      Issue #12170 requires a streamed Claude usage update after a failed probe to remain unavailable instead of appearing as a complete window list. The change preserves previous.unavailable, marks a sparse update with no previous snapshot as probeFailed, and keeps unchanged snapshots intact. The added unit and managed-provider tests cover these cases. Restart hydration is related background in the issue and is not required for this fix.

      Full details: Description check

      Explanation

      The description explains the problem, fix, scope, linked issue, approval context, focused verification, broader test results, and known limitations. It does not use the template headings, but it provides the required information in a complete and relevant form.

      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    5. Note

      Written by claude-opus-5-5 on behalf of Maria

      Hi! We are cleaning up open PRs, and this one does not say which model or harness was used to create it. If this change is really important, we recommend rebuilding the PR with a newer model and noting the model and harness in the PR description.

    6. maria-rcks closed this

    7. Note

      Written by claude-opus-5-5 on behalf of Maria

      Reopening, this was closed by mistake. Sorry for the noise!

    8. maria-rcks reopened this

    9. juliusmarminge assignedjuliusmarminge

    10. Taking over this one as maintainer for usage-billing-03. I will preserve the failed-probe behavior, rebuild against current main, and run focused regression tests and independent reviews. Credit to @andrewwbuilds for the original fix.

    11. juliusmarminge merged this3279826

    12. juliusmarminge closed this

Sign in to join this conversation.