Skip to content

Re-sync Router Core to upstream 2cd5a10 - #87

Merged
VickyXAI merged 2 commits into
mainfrom
chore/router-core-2cd5a10
Oct 20, 2026
Merged

VickyXAI merged 2 commits into
mainfrom
chore/router-core-2cd5a10

Conversation

@VickyXAI

Copy link
Copy Markdown
Contributor

Ports BlockRunAI/router-core e38958b..2cd5a10 into blockrun_llm/router_core/. No version bump.

Ported

  • tokens.py (new): estimate_tokens sizes CJK at about 1 token per char (exported). scan_limit / sample_for_scan moved here from strategy.py.
  • rules.py: keywords match whole words. Short ASCII keywords take graded inflections, digits stay exact, Cyrillic stems stay open-ended, and CJK/Hangul/Arabic keep the substring test. Upstream's \p{Script=Latin|Cyrillic|Greek}\p{N} boundary class is embedded as code-point ranges taken from Node 22 (Unicode 16).
  • strategy.py: structured output comes only from requires_structured_output. A system prompt that mentions JSON or a schema no longer lifts the tier.
  • portfolio.py: stakes, latency and language cues read only the user turn. A CamelCase error class counts as code and as a debug task. A debug or code_edit turn with a code artifact is floored at MEDIUM. A stale speed probe fades toward 0.5. The eleven tool-verified models join tool-required chains as fallbacks, only when the live catalog prices them, and cheapest first outside premium. One shared RulesStrategy instance, and eligibility is computed once.
  • selector.py: a model with no price reports 0 savings.
  • model_capabilities.py: regenerated from upstream's 2026-10-20 snapshot. It now has 89 models (+deepseek-v4.1-flash, gpt-6.1-sol, mistral-large-4, muse-glimmer-30b, laguna-s-2.1, qwen3.8-max, hy4-preview). Eleven models flip to supports_tools=True.
  • Host glue: router.classify_by_rules now defaults to estimate_tokens.
  • Tests: ported the new upstream cases from model-capabilities, portfolio, rules, selector, strategy and tokens. router_core_decisions.snapshot.json is re-copied from upstream.

Results

  • pytest tests/unit: 1342 passed (Python 3.13). The CI 3.9 command gives 1105 passed, 12 skipped, 4 deselected.
  • black --check ., ruff check . and node scripts/sync-brand-numbers.mjs --check are clean.
  • The decision snapshot reproduces 88/88 upstream decisions.
  • A differential fuzz of the keyword matcher against the TS implementation (790 keywords × 6000 texts) showed 0 mismatches on 3.9 and 3.13.

1bcMax added 2 commits October 20, 2026 10:53
Port router-core e38958b..2cd5a10 into blockrun_llm/router_core:

- tokens.py (new): estimate_tokens counts CJK at ~1 token per char;
  scan_limit / sample_for_scan move here from strategy.py
- rules.py: keywords match whole words with graded inflections
  (Latin/Cyrillic/Greek/digit boundary, CJK/Hangul/Arabic keep substring)
- strategy.py: structured output only from requires_structured_output,
  never inferred from the system prompt
- portfolio.py: stakes/latency/language read the user turn only;
  CamelCase error classes count as code; debug/code_edit with a code
  artifact floor at MEDIUM; stale speed fades toward 0.5; eleven
  probe-verified models join tool chains as priced, cost-ordered fallbacks
- selector.py: an unpriced model reports 0 savings, not 100%
- model_capabilities.py: regenerated from the 2026-10-20 catalog (89 models)
- router.classify_by_rules defaults to estimate_tokens

Tests: port the new upstream vitest cases and re-copy the decision
snapshot fixture (88/88 decisions reproduce).
@VickyXAI
VickyXAI merged commit e2992b2 into main Oct 20, 2026
6 checks passed
@VickyXAI VickyXAI mentioned this pull request Oct 20, 2026
@VickyXAI
VickyXAI deleted the chore/router-core-2cd5a10 branch October 20, 2026 17:01
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