hermes - ✅(Solved) Fix [Bug]: kimi-k2.5 on api.moonshot.cn fails with "invalid temperature: only 1 is allowed [1 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

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#12835Fetched 2026-04-20 12:16:45
View on GitHub
Comments
2
Participants
3
Timeline
4
Reactions
0
Timeline (top)
commented ×2closed ×1cross-referenced ×1

Error Message

When using kimi-k2.5 model with api.moonshot.cn (Moonshot China endpoint), all API calls fail with HTTP 400 error: Error code: 400 - {'error': {'message': 'invalid temperature: only 1 is allowed for this model', 'type': 'invalid_request_error'}} 3. Observe 400 error: invalid temperature: only 1 is allowed for this model

Root Cause

The _fixed_temperature_for_model() function in agent/auxiliary_client.py only checks for api.moonshot.ai but not api.moonshot.cn:

Current code (line 158-159):

# Public Moonshot API has a stricter contract for some models than the
# Coding Plan endpoint — check it first so it wins on conflict.
if base_url and "api.moonshot.ai" in base_url.lower():

Missing: api.moonshot.cn endpoint support.

According to the comment on line 157, the code should "Support both .ai (international) and .cn (China) endpoints", but the implementation only checks for .ai.

Fix Action

Fixed

PR fix notes

PR #12861: fix(kimi): include api.moonshot.cn in public temperature override

Description (problem / solution / changelog)

Salvage of #12806 by @kagura-agent onto current main.

Summary

  • extend the public Moonshot temperature override to api.moonshot.cn as well as api.moonshot.ai
  • preserve the existing Coding Plan behavior on api.kimi.com/coding
  • add direct-call regression coverage for the China endpoint in run_agent and the trajectory compressor paths

Why

Current main already routes api.moonshot.cn as a Moonshot/Kimi provider in other places, but _fixed_temperature_for_model() only treated api.moonshot.ai as the public endpoint. That left China users on api.moonshot.cn/v1 still hitting:

invalid temperature: only 1 is allowed for this model

Validation

  • targeted pytest: 7 passed
    • tests/agent/test_auxiliary_client.py
    • tests/run_agent/test_run_agent.py
    • tests/test_trajectory_compressor.py
    • tests/test_trajectory_compressor_async.py
  • isolated E2E import check:
    • api.moonshot.cn/v1 -> temperature=1.0
    • api.kimi.com/coding/v1 -> temperature=0.6

Contributor authorship preserved via cherry-pick.

Closes #12745 Refs #12835

Changed files

  • agent/auxiliary_client.py (modified, +1/-1)
  • tests/agent/test_auxiliary_client.py (modified, +2/-0)
  • tests/run_agent/test_run_agent.py (modified, +10/-0)
  • tests/test_trajectory_compressor.py (modified, +24/-0)
  • tests/test_trajectory_compressor_async.py (modified, +29/-0)

Code Example

Error code: 400 - {'error': {'message': 'invalid temperature: only 1 is allowed for this model', 'type': 'invalid_request_error'}}

---

# Public Moonshot API has a stricter contract for some models than the
# Coding Plan endpoint — check it first so it wins on conflict.
if base_url and "api.moonshot.ai" in base_url.lower():

---

model:
  default: kimi-k2.5
  provider: custom
  base_url: https://api.moonshot.cn/v1
  api_key: sk-...

---

hermes config set model.base_url https://api.moonshot.cn/v1
   hermes config set model.default kimi-k2.5

---

if base_url and "api.moonshot.ai" in base_url.lower():

---

if base_url and ("api.moonshot.ai" in base_url.lower() or "api.moonshot.cn" in base_url.lower()):

---

if "moonshot.ai" in url or "moonshot.cn" in url or "api.kimi.com" in url:
      return "kimi-coding"
RAW_BUFFERClick to expand / collapse

Bug Description

When using kimi-k2.5 model with api.moonshot.cn (Moonshot China endpoint), all API calls fail with HTTP 400 error:

Error code: 400 - {'error': {'message': 'invalid temperature: only 1 is allowed for this model', 'type': 'invalid_request_error'}}

Root Cause Analysis

The _fixed_temperature_for_model() function in agent/auxiliary_client.py only checks for api.moonshot.ai but not api.moonshot.cn:

Current code (line 158-159):

# Public Moonshot API has a stricter contract for some models than the
# Coding Plan endpoint — check it first so it wins on conflict.
if base_url and "api.moonshot.ai" in base_url.lower():

Missing: api.moonshot.cn endpoint support.

According to the comment on line 157, the code should "Support both .ai (international) and .cn (China) endpoints", but the implementation only checks for .ai.

Configuration to Reproduce

model:
  default: kimi-k2.5
  provider: custom
  base_url: https://api.moonshot.cn/v1
  api_key: sk-...

Reproduction Steps

  1. Configure Hermes to use Moonshot China endpoint:
    hermes config set model.base_url https://api.moonshot.cn/v1
    hermes config set model.default kimi-k2.5
  2. Start a conversation with Hermes
  3. Observe 400 error: invalid temperature: only 1 is allowed for this model

Expected Behavior

The _fixed_temperature_for_model() function should recognize api.moonshot.cn and force temperature=1.0 for kimi-k2.5, just like it does for api.moonshot.ai.

Proposed Fix

File: agent/auxiliary_client.py
Line: 159

Change from:

if base_url and "api.moonshot.ai" in base_url.lower():

To:

if base_url and ("api.moonshot.ai" in base_url.lower() or "api.moonshot.cn" in base_url.lower()):

This matches the intent described in the comment and fixes the issue for China users.

Verification

I applied this fix locally and confirmed:

  • kimi-k2.5 on api.moonshot.cn now works correctly
  • ✅ Temperature is correctly forced to 1.0
  • ✅ No regression for other models or endpoints

Environment

ComponentVersion
Hermes Agentv0.10.0
Modelkimi-k2.5
Providercustom (api.moonshot.cn)
OSWSL (Ubuntu)

Related

  • Similar fix was applied for trajectory_compressor.py which correctly checks both endpoints:

    if "moonshot.ai" in url or "moonshot.cn" in url or "api.kimi.com" in url:
        return "kimi-coding"
  • Issue #9125: Related temperature issues with kimi models

  • Issue #11764: kimi-for-coding temperature issues

extent analysis

TL;DR

Update the _fixed_temperature_for_model() function in agent/auxiliary_client.py to support both api.moonshot.ai and api.moonshot.cn endpoints.

Guidance

  • Modify the condition in agent/auxiliary_client.py to check for both api.moonshot.ai and api.moonshot.cn in the base_url.
  • Verify the fix by testing the kimi-k2.5 model with the api.moonshot.cn endpoint and checking that the temperature is correctly forced to 1.0.
  • Review related issues (#9125 and #11764) for similar temperature issues with kimi models.
  • Consider applying a similar fix to other parts of the code that may have the same endpoint check.

Example

if base_url and ("api.moonshot.ai" in base_url.lower() or "api.moonshot.cn" in base_url.lower()):

Notes

The proposed fix only addresses the specific issue with the kimi-k2.5 model and api.moonshot.cn endpoint. Additional testing may be necessary to ensure that the fix does not introduce any regressions for other models or endpoints.

Recommendation

Apply the proposed fix to update the _fixed_temperature_for_model() function to support both api.moonshot.ai and api.moonshot.cn endpoints, as it directly addresses the root cause of the issue and has been verified to work correctly.

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