Skip to content

roadmap: make llm-providers a trusted edge resilience layer #118

Open

Description

@stackbilt-admin

Shortest path to an edge resilience library developers choose

Audit date: 2026-10-11. Source: v1.21.0, commit 8a9eda6. This is the coordinating report for ten implementation opportunities, #108–#117. Scope: source/adapters/utilities, test surfaces and fixtures, scripts, package/TS configuration, public docs, release/CI workflows, tracked internal artifacts, and all nine initially open issues. Vendor/competitor statements use primary docs. Adoption predictions are marked [INFERRED].

Verification: TypeScript --noEmit passes; compilation into a temporary directory passes; nine standalone synthetic probes against compiled source pass and confirm the defects below. No live/billable provider calls. Full Vitest and bundle smoke were attempted but blocked by the existing Linux-oriented node_modules on this Windows host (missing Windows Rollup and esbuild binaries). No suite-pass/coverage/bundle-size claim is made. The pre-existing factory.test.ts working-tree modification was preserved; source evidence links refer to the audited commit.

1. Verdict

The project has substantial functionality but lacks a trustworthy, narrow promise outsiders can validate.
Keep graduated recovery, portable fetch adapters and spend provenance; those support the right product.
The biggest liability is that tenant safety, stream lifecycle and budget admission do not match the resilience/governance pitch.
Fix the trust failures, ship a deterministic failure demo, then integrate with the SDK developers already use.
Positioning: “Fetch-native failover and tenant spend policies for edge apps—embedded in your Worker, with no gateway service to operate.”

Evidence: src/providers/base.ts:192, src/utils/circuit-breaker.ts:105, src/types.ts:249, src/factory.ts:253, src/factory.ts:738, src/factory.ts:1580.

Architecture map before judgment

LLMProviders.generateResponse is a facade → factory cache lookup → catalog/provider plan → exhaustion/breaker/rate-counter prechecks → quota hook → provider-specific request → BaseProvider breaker around retry sequence → fetch/binding → per-adapter envelope validation/normalization → hooks → cost/ledger/quota recording → async cache write.

Boundaries matter:

2. Scorecard

Scores are engineering judgments of this revision, not market measurements.

Area /10 Justification / evidence
Correctness and resilience 4 Good primitives, but tenant/cache isolation and streaming lifecycle failures undermine the core promise (src/factory.ts:253, src/factory.ts:738, src/factory.ts:1623).
API design and DX 5 Useful fromEnv facade; dual request conversion and optional-field detection lose identity (src/index.ts:305, src/canonical.ts:264).
Provider freshness 3 Runtime allowlists reject modern OpenAI IDs, Claude IDs are undocumented dated constructions, and legacy prices are wrong (src/providers/openai.ts:139, src/providers/anthropic.ts:152, src/providers/cloudflare.ts:324).
Performance and bundle 6 Zero runtime dependencies and no eager WASM; one export barrel/all-provider registry, eager ranking, and no size baseline (package.json:74, src/factory.ts:366, src/model-catalog.ts:1262, scripts/worker-import-smoke.mjs:6).
Testing and reliability engineering 6 Real schema/failure and deterministic breaker tests; no Workers execution gate or concurrent/cancel lifecycle matrix (src/tests/circuit-breaker.test.ts:16, src/tests/schema-drift.test.ts:1046, vitest.config.ts:7).
Docs and positioning 4 902-line reference-heavy README; quickstart mixes Node and Workers, with no runnable examples in the tracked tree (README.md:40, README.md:800).
OSS hygiene and releases 6 Pinned actions, OIDC provenance and semver policy are strengths; tracked archives, unresolved sourcemaps and backlog staleness reduce polish (.github/workflows/publish.yml:14, .github/workflows/publish.yml:29, .agent-memory/status.json:2, #94).
Ecosystem fit 3 Hooks/tool executor/gateway metadata are seams; no AI SDK adapter and plain-text streams cannot carry full tool events (src/types.ts:294, src/types.ts:535, src/index.ts:102).

3. Hypotheses

Hypothesis Result Evidence / interpretation
H1: stale OpenAI coverage CONFIRMED Five GPT-4/3.5-era IDs only, with strict rejection of others (src/providers/openai.ts:139, src/providers/base.ts:353). Official current model catalog covers newer families. The problem is executable coverage, not only README copy.
H2: two shapes should converge CONFIRMED Canonical is converted back to legacy; optional-field discrimination loses metadata-only identity (src/canonical.ts:196, src/canonical.ts:264). Use additive explicit entry points now, one execution contract in the major.
H3: Workers state adapter differentiates PARTIAL Per-isolate limitation is already documented and snapshots exist (README.md:283, src/utils/credit-ledger.ts:523). The missing feature is atomic coordination, not serialization. KV snapshots are unsuitable for enforceable budgets; KV docs explain overwritten concurrent writes. [INFERRED] A first-party durable adapter earns adoption only if real users need app-owned policy.
H4: reference manual as landing page CONFIRMED Canonical contract appears immediately after quickstart, reference begins at line 800; runtime-specific launch path is absent (README.md:67, README.md:800). The conversion impact is [INFERRED]; verify with novice-user tests.
H5: internal artifacts hurt credibility PARTIAL Tracked archive/retry and corpus files are objective facts; perceived harm is [INFERRED], confirm through contributor onboarding. Preserve useful charter policy rather than deleting by directory name (.agent-memory/status.json:2, .charter/config.json:2, CONTRIBUTING.md:24).
H6: resilience + governance is the moat PARTIAL It is the strongest product direction, supported by graduated breaker + ledger (src/utils/circuit-breaker.ts:105, src/utils/credit-ledger.ts:226). It is not unique today: AI Gateway dynamic routing already has fallbacks/budgets. [INFERRED] Win on embedded portable policy, proven behavior and ecosystem fit; validate with users.

4. Top ten opportunities

Ordered by urgency and attainable impact/effort; larger efforts are split into a small first PR.

# Opportunity Category Impact Effort Risk Evidence / filed issue
1 Tenant-safe complete response-cache identity Correctness H S Cache misses after key-version bump src/factory.ts:253 · #108
2 Separate tenant denial; add atomic reservations Governance H S first / M–L durable Accounting semantics src/factory.ts:738 · #109
3 Repair byte streaming, cancellation and terminal accounting Resilience H M Stream terminal semantics src/providers/cloudflare.ts:1403 · #110
4 Scope state and honor resilience switches Resilience/DX H M Major default-state migration src/providers/base.ts:306 · #111
5 Verify catalog IDs, prices and custom-model escape hatch Coverage H M Alias/lifecycle compatibility src/providers/anthropic.ts:152 · #112
6 Canonical identity + one planner for inspection/dispatch API H M Major convergence src/canonical.ts:264 · #113
7 Failure lab, focused README and public repo cleanup Product/OSS H [INFERRED] M Low README.md:40 · #114
8 Explicit artifacts/subpaths and measured bundle budgets Bundle/DX H S–M Module resolution/support floor package.json:29 · #115
9 Fault contracts, deadlines and non-interfering telemetry Reliability H M Retry/accounting policy src/factory.ts:605 · #116
10 Optional AI SDK adapter + focused provider registration Ecosystem H [INFERRED] M Peer API/version maintenance src/types.ts:294 · #117

5. Bugs and risks: defects, not preferences

Severity Trigger / observed behavior Fix sketch / evidence
High, potentially critical in shared caches Tenant/system changes hit another request's cache entry; verified one-fetch synthetic repro Versioned complete tenant-scoped key, policy bypass; src/factory.ts:253, #108.
High Tenant quota denial marks provider exhausted for unrelated callers; verified Local terminal QuotaDeniedError, separate account exhaustion; src/factory.ts:1654, src/factory.ts:738, #109.
High Zero monetary budget still spends; rpm=1 admits two concurrent calls; verified Atomic reserve/settle, enforce configured scope; src/factory.ts:1838, src/utils/credit-ledger.ts:226, #109.
High Workers AI byte SSE produces empty output; verified synthetic byte fixture Incremental byte decoder plus workerd/live-shaped contract fixture; src/providers/cloudflare.ts:1413, #110.
High Streaming error/cancel bypasses accounting; wrapper cannot propagate cancel and eagerly drains Pull-based lifecycle, abort propagation, settle every terminal path; src/factory.ts:1580, src/factory.ts:1623, #110.
High Stream success/failure does not update execution breaker; verified stats Same streaming admission and terminal reporting; src/providers/openai.ts:495, #110.
High Client breaker “disabled” still runs; other clients share named health; verified Inject context into adapter + planner; src/providers/base.ts:196, src/providers/base.ts:306, #111.
High Throwing success hook causes another provider call; verified Isolate telemetry outside provider failure classification, record charge first; src/factory.ts:605, #116.
High Unsupported Claude/Cerebras wire IDs and material underpricing Source-verified provider-aware catalog; src/providers/anthropic.ts:152, src/providers/cerebras.ts:141, src/providers/cloudflare.ts:324, #112.
Medium Minimal canonical input loses tenant identity; verified Explicit shape entry points; src/canonical.ts:264, #113.
Medium Schema-error stream branches never resolve usage Terminal finally resolves usage/completion; src/providers/openai.ts:550, #110.
Medium Body can stall after headers; retries ignore cancellation/deadline Request-wide abort/deadline; src/providers/base.ts:176, src/utils/retry.ts:89, #116.
Medium Quota/cache persistence can be dropped after Worker response Await required settlement or expose completion for waitUntil; src/factory.ts:1688, src/factory.ts:676, #109/#116.
Medium KV recipe overwrites concurrent snapshots and can hit per-key write limits Durable atomic operations; README.md:299, KV constraints, #109.

Deliberate limits are not defects: no transparent mid-answer fallback; probabilistic recovery is not a single-probe lock; in-memory counters themselves do not lose synchronous increments. Authentication fail-fast is an existing policy with tests, though README's 401 fallback claim is wrong (src/factory.ts:1294, src/tests/factory.test.ts:1031, README.md:554).

6. PR-ready specs for the top three

The implementation issues contain actual TypeScript proposals, acceptance tests, semver/migration impact and README snippets:

  1. #108: deterministic Web Crypto cache identity, tenant/application namespace and request strategy.
  2. #109: concrete QuotaDeniedError and QuotaCoordinator reserve/settle contracts; immediate patch separated from durable enforcement.
  3. #110: concrete ManagedTextStream/StreamCompletion API and pull/cancel/settle wrapper; byte decoder and transport contract tests.

All proposed exports are labeled proposed. They are not descriptions of currently published APIs. Core constraints remain zero runtime deps, fetch-only, Workers-first and Apache-2.0.

7. Roadmap

Now, ≤2 weeks (solo-maintainer realistic):

Next, v-next minor:

Later, next major (batch breaking changes):

  • Single canonical execution request/client; remove legacy request aliases and duplicate convenience surface.
  • Client-local state default; explicit shared account context.
  • Explicit admission/enforced-budget behavior and known/unknown pricing semantics.
  • Typed stream events for tools/reasoning/finish/usage; retain a text projection helper.
  • Remove already deprecated ImageProvider; retain vision analysis.
  • Explicit model provider/endpoint identity and capability requirements; support-floor changes only here.

A enterprise gateway control plane, every provider/auth system, resumable tool streams and full MCP hosting is team-scale. Defer until adoption funds maintenance.

8. Growth and competitive strategy

Feature breadth is not the opening. The shortest path is proving one useful promise in public.

Alternative Why it wins today Plausible opening for this library
Vercel AI SDK Integrated generation/tools/UI and established provider contracts Optional model adapter that adds policy/failover without replacing the application framework
LiteLLM Broad endpoints, routing/cooldowns and distributed usage support Embedded portable TS Worker path with no Python/server deployment
Portkey Managed configuration and mature gateway fallback behavior Local programmable policy under application ownership, without another required service
OpenRouter Aggregated provider access/routing and a single access surface Coordinate direct keys, a Workers AI binding and local/custom endpoints under one application policy
Cloudflare AI Gateway Already provides routing, quotas/fallbacks and platform observability Complement it with app-owned portable policy and deterministic testing; do not sell its existing features as uniquely yours

These openings are [INFERRED] adoption hypotheses. Confirm with three external integrations and onboarding tests. The comparison is architectural, not an unsupported latency/cost benchmark.

Killer demo: one Worker, two tenants, three routes, live timeline. Turn primary 503/429 on; watch degradation/fallback/recovery. Run simultaneous requests into a small reservation budget; only the affected tenant stops. Cancel a slow stream and prove upstream stops/partial usage settles. Default fake mode costs nothing; live mode uses verified IDs and optional user keys. Demo/recording acceptance is #114.

README above the fold: outcome sentence → 3 concrete benefits → runtime-specific 15-line quickstart → demo/GIF → “when to use” comparison → honest guarantees → links to reference guides. Markdown docs first; avoid a docs-site maintenance project before traction.

Three launch channels: Cloudflare Developers Discord/forum with deployable Worker; Show HN with deterministic outage demo; AI SDK community/provider directory after adapter works. Publish measured reproducible results, not invented superiority claims.

Five good first issues to split from scoped work: standalone Node quickstart; move API reference into linked guide; fixture provenance manifest; missing public config-type export audit; inline sourcemaps under #94. Keep each bounded to one deliverable and clear acceptance tests.

Provider/API adoption ranking [INFERRED]: modern OpenAI + Responses first; Gemini API-key text second; generic OpenAI-compatible registration/OpenRouter third; then DeepSeek direct/xAI/Mistral/Ollama based on actual requests. Vertex enterprise auth and Cohere follow sponsored demand. Existing #79/#78/#80 remain the provider parents. Rankings are product bets, not measured market share.

Backlog hygiene: #95 reasoning is present (src/types.ts:235, CHANGELOG.md:48); #90 Cloudflare Claude lane exists (src/model-catalog.ts:591). They need maintainer reconciliation/validation, not duplicate implementation. #85 partly shipped; #87 remains the canonical parent; #94 is still applicable. No existing issue was closed or overwritten by this review.

9. Open maintainer decisions

  1. Are budgets soft routing signals or enforceable tenant spend policies? What happens with unknown prices/partial usage?
  2. Is state scoped to client, tenant, provider account or an explicitly shared policy domain?
  3. Is AI SDK interoperability the first external-user path, or are downstream gateway maintainers the primary audience?
  4. Which current providers/models are exercised by real users, and who can supply sanitized live contract fixtures?
  5. Should authentication/content-filter/provider-specific invalid requests ever fall back? Which constraints are mandatory across providers?
  6. What Node minimum/ESM-CJS support is a maintained promise?
  7. Can archive/corpus artifacts leave the public tree while charter policy remains documented?
  8. Are already implemented feat: add LLMResponse.reasoning field — separate reasoning tokens from message for thinking-model support #95/Add Cloudflare-managed Anthropic Claude Opus 4.8 catalog lane #90 ready to close after validation? What remains in Clarify AI Gateway response-cache contract and metadata #85/Harden provider contracts for Worker-backed agent routing #87?
  9. Can you recruit five novice users and three external adopters before expanding breadth?

The central decision: ship verifiable tenant-safe, cancel-safe failover and accounting, then let people adopt it inside their existing SDK. More adapter count alone will not create the obvious choice.

Activity

  1. added
    enhancement
    on Oct 11, 2026
  2. stackbilt-admin commented on Oct 13, 2026

    @stackbilt-admin
    MemberAuthor

    Local implementation checkpoint — 2026-10-12

    This work is uncommitted/unpushed on main, based on 8a9eda6c058d63f0ec08332f6a408aaf409232cf, and is not merged or released. Keep this issue open pending review/integration. The local handoff is docs/maintenance/issue-sweep.md; it will travel with the code.

    Current local checkpoint:

    Issue Progress Remaining scope
    #94 Embedded JavaScript sourcemap sources + artifact verification Review/CI/integration
    #108 Tenant/namespace/semantic cache identity, bypass/validation, quota-gated historical hits Review/integration + Workers runtime crypto test
    #109 Terminal local-denial classification and awaited streaming settlement Atomic reservations, physical attempt admission and durable coordination
    #110 Shared decoder, cancellation/deadlines, partial accounting, managed completion, stream health Pre-output retries, absolute execution deadlines, recorded fixtures/workerd
    #111 Opt-in client state/shared context, breaker switches/decay/error policy Next-major defaults, strict retry policy decision, latency/cost rule semantics
    #113 Explicit normalization, system semantics, configured-host introspection/client planner, failed diagnostic flag Canonical execution + hard requirements/fallback/capability convergence
    #85/#87 Related cache/router docs and public surfaces Their complete acceptance contracts remain open
    #115 Related maps + packed export check; local Windows tooling repaired ESM/CJS/subpaths/minimum-version/size/startup work
    #116 Streaming/quota observer safety and fault tests Non-streaming telemetry replay and broader deadline/error/event work
    #114 Contract/reference and resume docs Failure demo, focused README and public cleanup

    Next order: #112 vendor model IDs/pricing audit; #109 atomic reservations. The remaining non-streaming hook-replay defect in #116 is a valuable smaller intervening task. #117, #77 and new-provider proposals are untouched; #90/#95 were not re-audited for closure.

    All code is still local, with package version 1.21.0 unchanged. New public APIs require a minor release when integrated. Preserve the pre-existing line-ending-only factory-test change. The local checkpoint documents exact files and verification commands; no GitHub checkbox/closure should imply the code is shipped.

    Validation for the combined local sweep: 605 tests pass across 27 files, TypeScript typecheck passes, Worker-targeted bundle/import smoke passes. Packed entrypoint exports/client methods and all 33 JavaScript sourcemaps were checked on Windows with Node 24.19.0/npm 11.17.0. No live/billable providers or workerd execution; this does not prove minimum Node-version compatibility.

  3. stackbilt-admin commented on Oct 15, 2026

    @stackbilt-admin
    MemberAuthor

    Docs sweep update — 2026-10-15

    The 2026-10-12 checkpoint comment above described local, unmerged work. That work has now shipped. Release status for this roadmap:

    Release PRs Issues addressed (first phases; see the checkpoint for remaining scope)
    1.22.0 #119, #120, release #121 #94 sourcemaps, #108 tenant-safe cache identity, #109 local quota denial (QuotaDeniedError), #110 streaming lifecycle, #111 client-scoped resilience state, #113 canonical normalization and preflight routing, #116 hook isolation
    1.22.1 #122 #112 phase 1: corrected Claude IDs and Workers AI / Cerebras prices
    1.23.0 #123 #112 phase 2: current models checked against vendor docs (Workers AI first). Deprecated Workers AI models and OpenAI's 2026-10-23 shutdowns are no longer auto-routed. New optional ModelCatalogEntry.explicitOnly. Fixes JSON mode on Claude 4.6+ and $0 costs for dated OpenAI snapshots.

    All three were published to npm with provenance from the release workflow.

    Opened since: #124. The Anthropic adapter sends tool_result blocks without tool_use_id and drops tool error text, and Claude 5.x thinking blocks are not passed back in tool loops. This is the prerequisite for routing the Claude 5.x models.

    Next targets per the checkpoint (docs/maintenance/issue-sweep.md): #124, then #109 atomic spend reservations (needs a design pass). #114, #115 and #117 are not started. The issues stay open for their remaining scope as listed in the checkpoint table.

    Auto-updated by /docs skill.

  4. stackbilt-admin commented on Nov 6, 2026

    @stackbilt-admin
    MemberAuthor

    Status update — 2026-11-06

    Since the 2026-10-15 update, two more releases shipped. Both were published to npm with provenance from the release workflow.

    Release PRs What shipped
    1.24.0 #139, release #140 Workers AI reasoning control: reasoning.effort mapped per model from Cloudflare docs, reasoningEffort report, reasoning.strict, ReasoningEffortUnsupportedError (closes #135; first part of #136). Pinned-model integrity: allowFallback: false and fallback reports on responses and streams (closes #128); stream completions report the served provider and model (closes #133). Also lengthCause and usage.reasoningTokens.
    1.24.1 #134, release #141 Workers AI responses with null reasoning fields no longer fail schema validation (closes #130).

    How this maps to the roadmap

    Opened since the last update

    Issue Area Status
    #124 Anthropic tool loops (tool_use_id, tool error text, Claude 5.x thinking blocks) Next target; prerequisite for routing the Claude 5.x models
    #127 Workers AI drops json_schema Fix in contributor PR #129, waiting on a rebase onto main
    #131 Workers AI non-streaming timeout ignored Fix in contributor PR #132, waiting on a rebase onto main
    #136 Needs of a Workers-AI-only, governed app (campaign-continuity) Reasoning control shipped in 1.24.0; remaining needs open
    #137 Supply-chain workflow can't run (reusable workflows in a private repo) Open; fails on every commit, not a release blocker
    #138 null reasoning fields in Groq, OpenAI and Cerebras Open; small follow-up to #130

    Next targets: #124, then #109's atomic spend reservations, which need a decision first (§9, question 1: soft routing signals or enforced tenant spend caps). #114, #115 and #117 are still not started. The checkpoint in docs/maintenance/issue-sweep.md is current as of 1.24.1.

  5. stackbilt-admin commented on Nov 7, 2026

    @stackbilt-admin
    MemberAuthor

    Status update: 1.25.0 (2026-11-06)

    1.25.0 (#142, release #143) is published to npm with provenance:

    Next: the remaining #136 needs; then the Claude 5.x routing steps now tracked on #112; then #109 atomic spend reservations (needs a design pass first).

  6. stackbilt-admin commented on Nov 8, 2026

    @stackbilt-admin
    MemberAuthor

    Status update: 2026-11-08

    No release since 1.25.0.

    Contributor PRs, re-reviewed against 1.25.0. Both typecheck and pass the suite, the build and the worker import check.

    PR Fixes Status
    #132 #131: Workers AI non-streaming timeout All code feedback addressed. Waiting on two CHANGELOG/README fixes (name 1.25.1, restore a blank line). Planned as a patch.
    #129 #127: Workers AI json_schema Both blocking items fixed: the request shape is chosen per model (bare schema for Cloudflare's JSON mode models, { name, schema, strict? } for glm-5.3 and glm-5.3-flash), and the flagged models match Cloudflare's JSON mode list. Waiting on factory tests that use the real Cloudflare adapter. Planned as a minor.

    Ready to close. These were re-checked against their acceptance criteria:

    Unchanged: next targets are the remaining #136 needs, then the Claude 5.x routing steps on #112, then #109 (needs a decision on §9 question 1 first). #114, #115 and #117 have not started. #137 (supply-chain workflow) is still open; #77 is closed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions