Skip to content

effect: decide 402 → QuotaExhaustedError and carrying raw usage #323

Closed

Description

@ThomasK33

Two error/usage gaps in @coder/ai-sdk-effect were left out of the publishing PR because each one changes behavior and needs a design choice. RateLimitError.retryAfter did ship there.

  1. 402 → QuotaExhaustedError. Today HTTP 402 maps to RateLimitError, classifyError returns rate-limit, and isTransient returns true. Effect 4's QuotaExhaustedError exists for exhausted quota, but its isRetryable is false (effect/ai/AiError). Mapping 402 to it is inconsistent with isTransient: true, unless we also change the classification (a new quota reason, or rate-limit but not transient). That changes the public ErrorReason / isTransient contract, so it needs a decision.
  2. Carry usage.raw. LanguageModelV4Usage has provider-raw usage, but Effect 4.0.3's Response.Usage has no raw field. Carrying it needs a new home, for example the finish part's metadata.coder, which is a public metadata shape.

Acceptance: a decision for each item, then a PR with unit tests and README updates (the error-reason table in packages/effect/README.md).


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

Activity

  1. self-assigned this
    on Oct 12, 2026
  2. ThomasK33 commented on Oct 12, 2026

    @ThomasK33
    MemberAuthor

    Decisions (owner, 2026-10-12)

    1. 402 handling: Option A. HTTP 402 maps to Effect 4's QuotaExhaustedError. classifyError gets a new quota value, and isTransient returns false for it. 429 stays a transient rate-limit, including retryAfter.
    2. Raw usage: Option A. The provider's raw usage is carried as metadata.coder.rawUsage on the finish part, but only when the provider sends it.

    Implementation is in progress on branch issue-323-quota-raw-usage. It merges before the effect 0.1.0 release (#325), so both changes ship in 0.1.0.


    Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: medium

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions