hermes - ✅(Solved) Fix [Bug]: Anthropic Messages 适配器对顶层 `model` 字段做了点号转连字符,导致后端模型解析不到 [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#14528Fetched 2026-04-24 06:16:44
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×3cross-referenced ×1

Error Message

Additional Logs / Traceback (optional)

Root Cause

Root Cause Analysis (optional)

Fix Action

Fixed

PR fix notes

PR #14544: fix: preserve dots in model names for custom provider and third-party…

Description (problem / solution / changelog)

… anthropic-compatible endpoints

When using a custom provider with an Anthropic-compatible endpoint (e.g. antchat.alipay.com/api/anthropic), model names like GLM-5.1 were incorrectly converted to GLM-5-1 by normalize_model_name(). This adds 'custom' to the provider whitelist and 'anthropic' to the base_url matching rules in _anthropic_preserve_dots() so that dots are preserved for these third-party endpoints.

What does this PR do?

Anthropic Messages 适配器对顶层 model 字段做了点号转连字符,导致后端模型解析不到

Related Issue https://github.com/NousResearch/hermes-agent/issues/14528

Fixes #

Type of Change

<!-- Check the one that applies. -->
  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

<!-- List the specific changes. Include file paths for code changes. -->

How to Test

<!-- Steps to verify this change works. For bugs: reproduction steps + proof that the fix works. -->

Checklist

<!-- Complete these before requesting review. -->

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: <!-- e.g. Ubuntu 24.04, macOS 15.2, Windows 11 -->

Documentation & Housekeeping

<!-- Check all that apply. It's OK to check "N/A" if a category doesn't apply to your change. -->
  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

<!-- Only fill this out if you're adding a skill. Delete this section otherwise. -->
  • This skill is broadly useful to most users (if bundled) — see Contributing Guide
  • SKILL.md follows the standard format (frontmatter, trigger conditions, steps, pitfalls)
  • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
  • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

Screenshots / Logs

<!-- If applicable, add screenshots or log output showing the fix/feature in action. -->

Changed files

  • run_agent.py (modified, +4/-0)

Code Example

Report     https://paste.rs/YIw8j
agent.log  https://paste.rs/DBAi4

---
RAW_BUFFERClick to expand / collapse

Bug Description

在 run_agent.py:881-888:

1 from hermes_cli.model_normalize import normalize_model_for_provider 2 3 if self.provider not in _AGGREGATOR_PROVIDERS: 4 self.model = normalize_model_for_provider(self.model, self.provider)

此时 provider 仍然是 custom(未被改写),但关键在于 custom 属于 _MATCHING_PREFIX_STRIP_PROVIDERS(model_normalize.py:100),所以规范化函数对 custom provider 只做前缀剥离,原样返回 GLM-5.1

但问题出在 Anthropic Messages 适配器中——当 api_mode == "anthropic_messages" 时,Anthropic SDK 自身会在构建请求时将模型名中的点号替换为连字符(这是 Anthropic API 的命名规范),导致最终发送的请求中 model 字段变成 GLM-5-1。

Steps to Reproduce

触发条件:base_url 以 /anthropic 结尾 → api_mode = "anthropic_messages"

Expected Behavior

不对model进行转换,选择某个模型透传某个模型

Actual Behavior

导致 GLM-5.1 被替换为 GLM-5-1

Affected Component

Agent Core (conversation loop, context compression, memory)

Messaging Platform (if gateway-related)

No response

Debug Report

Report     https://paste.rs/YIw8j
agent.log  https://paste.rs/DBAi4

Operating System

macOS 15.5

Python Version

No response

Hermes Version

No response

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

extent analysis

TL;DR

The issue can be fixed by modifying the normalize_model_for_provider function to handle the custom provider correctly when api_mode is anthropic_messages, preventing the replacement of dots with hyphens in the model name.

Guidance

  • Verify that the api_mode is indeed anthropic_messages when the base_url ends with /anthropic, and that this triggers the incorrect model name replacement.
  • Check the normalize_model_for_provider function in model_normalize.py to see if it can be modified to handle the custom provider differently when api_mode is anthropic_messages.
  • Consider adding a conditional statement to prevent the replacement of dots with hyphens when api_mode is anthropic_messages and the provider is custom.
  • Review the Anthropic SDK documentation to ensure that the model name replacement is indeed a requirement for the Anthropic API.

Example

if self.provider == 'custom' and api_mode == 'anthropic_messages':
    # Do not replace dots with hyphens for custom provider with anthropic_messages api_mode
    return self.model

Notes

The exact fix will depend on the implementation details of the normalize_model_for_provider function and the Anthropic SDK. The provided example is a possible solution, but may need to be adapted to the specific requirements of the project.

Recommendation

Apply workaround: Modify the normalize_model_for_provider function to handle the custom provider correctly when api_mode is anthropic_messages, as described in the guidance section. This will prevent the incorrect replacement of dots with hyphens in the model name.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Bug]: Anthropic Messages 适配器对顶层 `model` 字段做了点号转连字符,导致后端模型解析不到 [1 pull requests, 1 participants]