Skip to content

fix(runtime): preserve billing classification in durable diagnostics - #4765

Open
jiang1997 wants to merge 1 commit into
apache:mainfrom
jiang1997:fix/provider-billing-diagnostic
Open

fix(runtime): preserve billing classification in durable diagnostics#4765
jiang1997 wants to merge 1 commit into
apache:mainfrom
jiang1997:fix/provider-billing-diagnostic

Conversation

@jiang1997

Copy link
Copy Markdown

Summary

Keep durable provider diagnostics consistent with the runtime's canonical
provider-error classification.

classifyProviderFacts() already recognizes billing failures from structured
provider codes such as insufficient_quota and insufficient_balance, as well
as explicit plan-limit wording behind HTTP 401/403 responses. However,
durableProviderErrorClass() subsequently remapped those failures from their
HTTP status alone:

  • HTTP 401/403 became Auth
  • HTTP 429 became RateLimit

As a result, the runtime could report ProviderBilling while Usage and Trace
persisted a different error class for the same provider failure.

This change treats the upstream ProviderBilling classification as
authoritative, matching the existing handling of ContextLength and
ProviderCapacity. Regression assertions cover structured billing codes
behind HTTP 401/403/429 and plan-limit wording behind HTTP 401/403.

Verification

Passed:

  • npm --workspace @maka/runtime run build
  • node --test packages/runtime/dist/__tests__/provider-error-classification.test.js packages/runtime/dist/__tests__/model-adapter.test.js
    • 54 tests passed
  • npm --workspace @maka/runtime run typecheck
  • npx biome format packages/runtime/src/provider-error-classification.ts packages/runtime/src/__tests__/provider-error-classification.test.ts
  • npx biome lint packages/runtime/src/provider-error-classification.ts packages/runtime/src/__tests__/provider-error-classification.test.ts
  • git diff --check

The full Runtime suite was also attempted locally. Five unrelated
filesystem-worker-smoke tests could not start the worker because the macOS
sandbox blocked the Nix Node binary from loading libz.dylib; the remaining
3,218 tests passed.

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope:

Codex reviewed the provider classification paths, identified the inconsistent
durable remapping, implemented the focused fix, added regression assertions,
and ran the reported verification commands.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@github-actions github-actions Bot added the effort/XS Under 10 readable lines label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XS Under 10 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant