Skip to content

fix(UB-178): make Claude primary and keep HF last - #252

Merged
alex-mextner merged 2 commits into
mainfrom
fix/ub-178-claude-primary
Nov 13, 2026
Merged

alex-mextner merged 2 commits into
mainfrom
fix/ub-178-claude-primary

Conversation

@alex-mextner

@alex-mextner alex-mextner commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Why

Text routing currently prefers z.ai even though Claude is the intended primary. Configured chains and health-based reordering can bring HF ahead of the priority providers. The reserve model examples are also outdated.

Claude 5.5 was added on October 10, before the November 8 retired-model calls reported by Anthropic. The available evidence does not identify ExpenseSyncBot as their source.

Changes

  • Make Claude Sonnet 5.5 primary for smart requests and Haiku 5.5 primary for fast requests. Preserve Claude → HF vision for OCR.
  • Normalize selected custom/role chains so Claude comes first and HF last. Keep health-based reordering within the priority providers; configured OpenRouter runs before HF.
  • Remove remaining Gemini references from active code/configuration and fixtures.
  • Refresh the DeepSeek preset and HF smart/fast/vision examples. Apply model-specific HF reasoning settings: low effort plus an output allowance for Qwen 3.8 2.4T, and disabled thinking for Flash-Next FP8.
  • Preserve credential failover, visible provider errors and explicit failure when the chain is exhausted.
  • Make both diagnostic probes use the same existing HF parameter helper as runtime. Regression tests execute the scripts and check their serialized requests, including that HF controls never leak to OpenRouter or Claude.

Verification

Current head: 97bcc3c70fa41c2cd7a611ea641887ac94c05f78

  • Stage Bot 43388857849 passed repository-wide typecheck, lint, 6087 tests across 253 files, and stage deployment.
  • Trusted Stage QA 43389023197 passed 7 real Telegram cases against @ExpenseSyncStageBot on this exact head. The normal read-only stage QA gate returned green for 97bcc3c70fa4 cases=7. These command/redirect cases do not exercise inference.
  • The two new diagnostic request-shape tests first reproduced the missing HF controls, then passed with the repair. All 6 script-probe tests / 31 assertions passed. Changed-file lint and the required home-offloaded typecheck also passed; the latter used CI's Bun 1.4.2 and a frozen dependency install.
  • The full change and follow-up received native reviews with three Opus 5.5 roles. Confirmed defects were fixed. The follow-up had no correctness/security findings; two optional refactor suggestions were deferred, and a missing breaker-documentation sentence was restored. The normal commit hooks passed; no review stamps or hooks were altered. Separate release gates still apply.

Claude inference evidence, scoped to the earlier head

On 5ab0968916400cbd0972cf85e7a6dad5b1c61e51, the existing scripts/verify-claude-usage.ts ran on stage with its credentials and an owned temporary SQLite database. All three real calls passed: Sonnet 5.5 smart text, Haiku 5.5 fast text, and Sonnet 5.5 OCR of a synthetic receipt. Each produced a Claude ok usage row with reported input/output tokens. No other provider request was sent; the temporary database was removed afterward.

The current head has identical Git blobs for the Claude clients, credential pools, request parameters, chain/round/slot implementation, breaker, usage recorder and inference-probe script (16 checked files). The follow-up only changes diagnostic requests, examples, comments and the existing HF helper's public export, so it does not warrant repeating the paid stage calls. The production verification below covers the final deployed revision.

The initial patch also passed 252 focused tests across 10 files. A scan of 568 tracked source/configuration files found no Gemini matches. Both configured credentials match Calendar's working pair; the same-key HTTP 200 checks were four shared calls across Haiku and Sonnet, not independent calls per bot. Successful HF inference was not verified: the current account returned 402 and remains an optional reserve.

Production result — 2026-11-13

The normal gh ship path, including the genuine approved quorum hatch, merged this PR as c1a609cc3942586b2c7aa98085e3d7deccfb282a. The official production deployment 43410582480 succeeded for that exact main/push commit. The running checkout independently matches it.

At 16:45 Europe/Belgrade, one isolated probe used the deployed code, the running process environment plus its actual environment file, and the normal configured provider chains. No provider, endpoint, model or credential override was supplied.

Route Actual provider/model Synthetic result Reported input/output tokens
Smart Claude Sonnet 5.5 Four. 22 / 5
Fast Claude Haiku 5.5 Four. 20 / 5
OCR Claude Sonnet 5.5 TOTAL 12.50 470 / 11

All three calls produced successful Claude usage rows. There were zero attempts to other providers. Successful API response status codes are not retained in these usage rows; the proof is the actual returned answer and reported usage, rather than a claimed captured HTTP status.

The effective smart/fast order is Claude → z.ai → HF; OCR is Claude → HF. HF remains the final reserve and its account was not repaired or funded. The scan of active source, scripts and the environment example found no Gemini references, and the effective probe/process environment had no Gemini configuration.

Both PM2 processes remained online with unchanged process IDs and restart counters during verification. Health returned HTTP 200 before and after. The production environment file remained unchanged by the probe, and its temporary database and script were removed. This proves deployed inference through the normal route; it does not claim Telegram end-to-end coverage or inspection of PM2's private in-memory circuit state.

The first automatic production probe stopped before Bun or any API call: its inherited application PATH did not contain /usr/sbin, so the launcher could not resolve runuser. Its original failed receipt and one-run marker are retained. A separate recorded recovery used the observed absolute /usr/sbin/runuser path and the unchanged inference probe; it passed. No application change, second deployment, restart or environment change was needed for this diagnostic correction.

Refs UB-178

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

🔁 PR closed. Stage bot switched back to main.

@alex-mextner
alex-mextner merged commit c1a609c into main Nov 13, 2026
16 checks passed
@alex-mextner
alex-mextner deleted the fix/ub-178-claude-primary branch November 13, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant