Skip to content

fix: support DeepSeek V4+ model names in normalization - #15586

Closed
zons-zhaozhy wants to merge 2 commits into
NousResearch:mainfrom
zons-zhaozhy:fix/deepseek-v4-model-normalization
Closed

zons-zhaozhy wants to merge 2 commits into
NousResearch:mainfrom
zons-zhaozhy:fix/deepseek-v4-model-normalization

Conversation

@zons-zhaozhy

Copy link
Copy Markdown

Problem

DeepSeek V4 models (deepseek-v4-pro, deepseek-v4-flash) are unusable. The /model command reports:

Model `deepseek-v4-pro` was not found in this provider's model listing.

Root Cause

_normalize_for_deepseek() assumed DeepSeek only has two model IDs (deepseek-chat and deepseek-reasoner). All other names were forced to deepseek-chat. When a user requests deepseek-v4-pro, it gets mangled to deepseek-chat, which is then rejected by the live API model validator since the API only returns deepseek-v4-pro and deepseek-v4-flash.

Additionally, DeepSeek returns "Insufficient Balance" with HTTP 400 (not the documented 402) when credits are exhausted. This was misclassified as a model-not-found error rather than a billing error, masking the real problem.

Changes

hermes_cli/model_normalize.py — Refactor DeepSeek normalization

  • Before: Whitelist-based (deepseek-chat or deepseek-reasoner only)
  • After: Prefix-based passthrough — any deepseek-* name passes through unchanged
  • Alias resolution for short forms: v3deepseek-chat, r1deepseek-reasoner
  • Reasoner keyword detection and backward-compatible fallback preserved
  • Future DeepSeek models (V5, V6...) work without code changes

agent/error_classifier.py — Add billing pattern

  • Added "insufficient balance" to _BILLING_PATTERNS
  • Ensures DeepSeek credit exhaustion is classified as billing error, not model-not-found

hermes_cli/models.py — Update static catalog

  • Added deepseek-v4-pro and deepseek-v4-flash to the DeepSeek provider model list

tests/hermes_cli/test_model_normalize.py — 14 new test cases

  • Passthrough: 6 models including future-proof deepseek-v5-ultra
  • Short alias resolution: v3, r1
  • Reasoner keyword detection: thinker, cot-model, reasoning-v2
  • Unknown fallback to deepseek-chat
  • Vendor prefix stripping: deepseek/deepseek-v4-prodeepseek-v4-pro

All 69 tests pass (55 existing + 14 new).

Testing

$ pytest tests/hermes_cli/test_model_normalize.py -v
============================== 69 passed in 0.43s ==============================

zzy-git added 2 commits April 24, 2026 14:25
…n waste

Ephemeral per-API-call optimization that compresses old tool results
to one-line summaries before each LLM call. Complements the existing
ContextCompressor (persistent, threshold-triggered).

- _progressive_tool_result_compress: regex-based summary, zero cost
- Config: compression.progressive.* (enabled, recent_tool_keep,
  min_messages, max_compressed_len)
- Respects compression.enabled and protect_last_n as defaults
- 32 unit tests + benchmark script
- Lint clean (ruff)
DeepSeek V4 models (deepseek-v4-pro, deepseek-v4-flash) were unusable
because _normalize_for_deepseek() forced all non-chat/reasoner names
to 'deepseek-chat'. The model validator then rejected the mangled name
as not found in the provider's model listing.

Root cause: the normalize function assumed DeepSeek only has two model
IDs (chat and reasoner). V4 introduced new IDs that need passthrough.

Changes:
- Refactor _normalize_for_deepseek: prefix-based passthrough for any
  'deepseek-*' name, alias resolution for short forms (v3, r1),
  keyword fallback for reasoner keywords, backward-compatible default.
- Add 'insufficient balance' to billing error patterns (DeepSeek returns
  this with HTTP 400 instead of the documented 402).
- Update static model catalog with V4 entries.
- Add 14 parametrized tests covering passthrough, aliases, keywords,
  fallback, and vendor-prefix stripping.

Future DeepSeek model releases (V5, V6...) will work without code
changes thanks to the passthrough design.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard provider/deepseek DeepSeek API labels Apr 25, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

Likely duplicate of #15123 (merged) — same fix: pass DeepSeek V-series IDs through instead of folding to deepseek-chat. Also overlaps with #14946 (closed) and #14911 (closed). The error_classifier billing pattern addition may be the only net-new content.

@teknium1

Copy link
Copy Markdown
Collaborator

Thanks for the contribution! This is an automated hermes-sweeper review.

The core fix described in this PR — DeepSeek V-series passthrough normalization and catalog entries — was already landed on main in commit 4ac731c84 (fix(model-normalize): pass DeepSeek V-series IDs through instead of folding to deepseek-chat), which also covered the _DEEPSEEK_V_SERIES_RE regex and deepseek-v4-pro/deepseek-v4-flash catalog entries in hermes_cli/models.py.

Two items worth noting for follow-up:

  1. insufficient balance billing pattern — this string is not yet in _BILLING_PATTERNS (agent/error_classifier.py line 90). A focused one-line PR or issue to add it would be welcome.
  2. Progressive compression feature (commit 48400a7) — this is a substantial unrelated feature bundled into this PR. If you'd like to contribute it, please open a separate PR focused on that work.

@teknium1 teknium1 closed this Apr 27, 2026
teknium1 pushed a commit that referenced this pull request Apr 28, 2026
DeepSeek API returns HTTP 400 with 'Insufficient Balance' message when
account funds are depleted. This pattern was not in _BILLING_PATTERNS,
causing the error to be misclassified instead of triggering billing
exhaustion handling (e.g., fallback to alternate provider).

Suggested by teknium1 in PR review of #15586.
cluricaun28 referenced this pull request in cluricaun28/Logos Apr 28, 2026
DeepSeek API returns HTTP 400 with 'Insufficient Balance' message when
account funds are depleted. This pattern was not in _BILLING_PATTERNS,
causing the error to be misclassified instead of triggering billing
exhaustion handling (e.g., fallback to alternate provider).

Suggested by teknium1 in PR review of #15586.
donald131 pushed a commit to donald131/hermes-agent that referenced this pull request May 2, 2026
DeepSeek API returns HTTP 400 with 'Insufficient Balance' message when
account funds are depleted. This pattern was not in _BILLING_PATTERNS,
causing the error to be misclassified instead of triggering billing
exhaustion handling (e.g., fallback to alternate provider).

Suggested by teknium1 in PR review of NousResearch#15586.
@zons-zhaozhy
zons-zhaozhy deleted the fix/deepseek-v4-model-normalization branch May 4, 2026 16:35
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
DeepSeek API returns HTTP 400 with 'Insufficient Balance' message when
account funds are depleted. This pattern was not in _BILLING_PATTERNS,
causing the error to be misclassified instead of triggering billing
exhaustion handling (e.g., fallback to alternate provider).

Suggested by teknium1 in PR review of NousResearch#15586.
dannyJ848 pushed a commit to dannyJ848/hermes-agent that referenced this pull request May 17, 2026
DeepSeek API returns HTTP 400 with 'Insufficient Balance' message when
account funds are depleted. This pattern was not in _BILLING_PATTERNS,
causing the error to be misclassified instead of triggering billing
exhaustion handling (e.g., fallback to alternate provider).

Suggested by teknium1 in PR review of NousResearch#15586.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
DeepSeek API returns HTTP 400 with 'Insufficient Balance' message when
account funds are depleted. This pattern was not in _BILLING_PATTERNS,
causing the error to be misclassified instead of triggering billing
exhaustion handling (e.g., fallback to alternate provider).

Suggested by teknium1 in PR review of NousResearch#15586.
Seven74AI pushed a commit to Seven74AI/hermes-agent that referenced this pull request Jun 13, 2026
DeepSeek API returns HTTP 400 with 'Insufficient Balance' message when
account funds are depleted. This pattern was not in _BILLING_PATTERNS,
causing the error to be misclassified instead of triggering billing
exhaustion handling (e.g., fallback to alternate provider).

Suggested by teknium1 in PR review of NousResearch#15586.
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
DeepSeek API returns HTTP 400 with 'Insufficient Balance' message when
account funds are depleted. This pattern was not in _BILLING_PATTERNS,
causing the error to be misclassified instead of triggering billing
exhaustion handling (e.g., fallback to alternate provider).

Suggested by teknium1 in PR review of NousResearch#15586.
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
DeepSeek API returns HTTP 400 with 'Insufficient Balance' message when
account funds are depleted. This pattern was not in _BILLING_PATTERNS,
causing the error to be misclassified instead of triggering billing
exhaustion handling (e.g., fallback to alternate provider).

Suggested by teknium1 in PR review of NousResearch#15586.
prmartinow pushed a commit to prmartinow/hermes-agent that referenced this pull request Aug 26, 2026
DeepSeek API returns HTTP 400 with 'Insufficient Balance' message when
account funds are depleted. This pattern was not in _BILLING_PATTERNS,
causing the error to be misclassified instead of triggering billing
exhaustion handling (e.g., fallback to alternate provider).

Suggested by teknium1 in PR review of NousResearch#15586.
melon-xf added a commit to melon-xf/hermes-agent that referenced this pull request Sep 3, 2026
DeepSeek API returns HTTP 400 with 'Insufficient Balance' message when
account funds are depleted. This pattern was not in _BILLING_PATTERNS,
causing the error to be misclassified instead of triggering billing
exhaustion handling (e.g., fallback to alternate provider).

Suggested by teknium1 in PR review of NousResearch#15586.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists provider/deepseek DeepSeek API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants