Skip to content

V2: define typed LLM errors for consumer-owned retry policy #34995

Closed

Description

@rekram1-node

Context

The LLM package should not decide retry policy, but opencode needs useful typed failures to implement its own policy. AI SDK errors are currently hard to interpret, especially for midstream provider failures.

Scope

  • Review packages/llm/src/schema/errors.ts and executor error mapping.
  • Prioritize context overflow, provider/API errors, transport failures, auth/config failures, and midstream provider failures.
  • Preserve raw provider details where useful without hardcoding brittle provider-specific status semantics.
  • Remove retry-policy language from public errors if it implies package-owned retries.

Acceptance Criteria

  • Consumers can distinguish context overflow from generic provider failure.
  • Midstream provider failure is surfaced ergonomically.
  • Errors include enough status/header/body/provider detail for opencode retry policy.
  • No error API implies automatic retries inside @opencode-ai/llm.

Activity

  1. self-assigned this
    on Jul 2, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Jul 2, 2026
  3. opencode-agent commented on Jul 10, 2026

    @opencode-agent
    Contributor

    Audit: several recent PRs chip away at typed LLM/provider failures (#35671 Z.AI overflow classification, #36130 nested OpenAI stream errors, #36163 typed provider/compaction errors), but this still looks like a broader error-contract issue. Keeping open.

  4. neriousy commented on Oct 21, 2026

    @neriousy
    Member

    Done: packages/ai/src/schema/errors.ts now has typed failure reasons (context-overflow classification, auth, rate limit, transport, incomplete-stream midstream failures), each with raw body and HTTP status/headers. Retry policy lives in core (packages/core/src/model-retry.ts); isRetryable is only an advisory helper.

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

Metadata

Metadata

Assignees

Labels

2.0coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions