Skip to content

ExpenseSyncBot: HF fallback slot answers 402 (no Inference credits) on prod and stage #180

Open

Description

@alex-mextner

What

Re-filed from the startup tracker, where it was created by mistake (was HYP-1667, deleted 2026-10-20).

The last slot of every AI chain in ExpenseSyncBot (smart: the HF_MODEL Qwen3-235B; also fast and OCR) cannot answer: the Hugging Face router returns 402 'You have no remaining credits. Purchase pre-paid credits to continue using Inference Providers.' Either top up HF Inference credits or drop the HF slot (and its env vars) from the chains in streaming.ts.

Why (motivation)

Live smoke on odroidn2 with the stage env (same HF_TOKEN as prod), 2026-10-12, while hardening HYP-1665: 8 of 8 calls to HF_MODEL got 402 in 190-340 ms, both plain and with tools + tool_choice none.

User impact

When Groq, z.ai, Claude and Gemini all fail, a user question in the bot ends in the generic AI error instead of an HF answer; receipt OCR has no working fallback when Gemini fails, so the user gets no parsed receipt.

Cost of inaction

The chain silently has one fewer fallback than the code and docs claim; outages of the other providers turn into user-visible errors sooner.

Acceptance criteria

  • A live call through hfClient() with the prod/stage HF_TOKEN returns a completion, OR the HF slot is removed from the smart, fast and OCR chain builders with tests updated
  • Prod logs show no 402 from HF for a week

Screenshots

(none)

Deploy

Deployed: no

Links

  • (none)

Skipped gates

  • post-merge-acceptance: Neither criterion is verifiable pre-merge: HF needs a credits top-up to answer, and 'no 402 for a week' needs a week of prod logs. This PR demotes a 402 provider for 1h (tests in streaming.test.ts) so the chain stops leading with it.
  • screenshots: backend/API finding, no UI

Activity

  1. mikemikimike commented on Nov 11, 2026

    @mikemikimike

    Implemented in #251.

    The default smart and fast fallback chains no longer call Hugging Face Router, so depleted HF credits cannot take production or staging requests through the default path. HF remains available when explicitly selected in AI_SMART_CHAIN or AI_FAST_CHAIN; HF settings are optional for default startup; and OCR remains Claude-only.

    Regression coverage includes default chain order, missing-key behavior, explicit HF opt-in, 402 fallback and breaker behavior, request construction, configuration loading, and usage reporting. Validation passed for bun x tsc --noEmit, the focused AI/config/usage tests, modified-file Biome checks, and git diff --check.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions