Skip to content

fix(temperature): add Kimi K2 + Moonshot to default temperature-unsupported list (#2076)#2082

Merged
senamakel merged 2 commits into
tinyhumansai:mainfrom
YOMXXX:fix/temperature-guard-kimi-moonshot
May 19, 2026
Merged

fix(temperature): add Kimi K2 + Moonshot to default temperature-unsupported list (#2076)#2082
senamakel merged 2 commits into
tinyhumansai:mainfrom
YOMXXX:fix/temperature-guard-kimi-moonshot

Conversation

@YOMXXX
Copy link
Copy Markdown
Contributor

@YOMXXX YOMXXX commented May 18, 2026

Summary

  • Moonshot's Kimi K2 family (kimi-k2.6, kimi-k2-instruct, …) only accepts temperature: 1. Sending any other value returns "invalid temperature: only 1 is allowed for this model".
  • The existing temperature_unsupported_models gate already does the right thing for the OpenAI o-series and GPT-5 — Kimi K2 just wasn't on the list.
  • Add three glob patterns (kimi-k2*, moonshot*, moonshotai/*) to default_temperature_unsupported_models so omitting temperature happens automatically. Upstream defaults to 1.0 when the field is absent, which is what these models require.
  • Three new tests: happy path (suppressed for Kimi variants), namespaced gateways (OpenRouter moonshot/... and moonshotai/...), and a negative regression guard (no spillover onto unrelated substring matches).

Closes #2076.

Problem

Sentry OPENHUMAN-TAURI-HB146 events in the last day from users in China hitting:

{"error":{"message":"invalid temperature: only 1 is allowed for this model","type":"invalid_request_error"}}
  • Platform: Windows x86_64 (10.0.26200)
  • Model: kimi-k2.6 via custom_openai provider
  • Version: openhuman@0.53.45

Code path:

  1. The router resolves the user's model name as kimi-k2.6 (no tier alias rewriting because custom_openai doesn't have one for Kimi).
  2. temperature_for_model("kimi-k2.6", 0.7, config) checks config.temperature_unsupported_models — the default list is ["o1*", "o3*", "o4*", "gpt-5*"]. No match → returns Some(0.7).
  3. The OpenAI-compatible serialiser includes temperature: 0.7 in the request body.
  4. Moonshot's upstream API returns 400.

Every agent turn on kimi-k2.6 is completely broken for these users.

Solution

Extend default_temperature_unsupported_models in src/openhuman/config/schema/types.rs with three new globs:

Pattern Covers
kimi-k2* Direct Moonshot API — kimi-k2.6, kimi-k2-instruct, kimi-k2-pro, future K2 variants
moonshot* OpenRouter / Moonshot direct routings — moonshot/..., moonshot-v1-8k, moonshot-v1-32k, …
moonshotai/* Alternate OpenRouter namespacing — moonshotai/kimi-k2-instruct, …

temperature_for_model already handles the suppression: returning None causes skip_serializing_if to omit the temperature field from the JSON body. Upstream defaults to 1.0 when absent, which is what Kimi requires.

The existing user-facing override (config.temperature_unsupported_models in config.toml) still wins — users who already worked around this can keep their customisation and the defaults stop being the source of pain for everyone else.

Tests

temperature.rs gains three cases under the // -- #2076 header:

Test Purpose
temperature_suppressed_for_kimi_k2 Direct Moonshot API: kimi-k2.6, kimi-k2-instruct, kimi-k2-pro all return None. Covers the exact reporter variant.
temperature_suppressed_for_moonshot_namespaced_kimi OpenRouter-style routings: moonshot/kimi-k2.6, moonshotai/kimi-k2-instruct, moonshot-v1-8k.
temperature_still_allowed_for_unrelated_models_after_kimi_additions Negative regression guard. Substring-adjacent names like kimichat-legacy, moonshine-asr, claude-sonnet-4.6, gemini-2.5-pro continue to return Some(default). Guards against the new patterns turning into accidental catch-alls.

Submission Checklist

  • Tests added or updated (happy + failure / edge) — 2 happy (direct + namespaced) + 1 negative regression guard.
  • Diff coverage ≥ 80% — every new pattern in default_temperature_unsupported_models is exercised by at least one assertion; the negative guard covers the boundary cases. cargo fmt --check clean.
  • Coverage matrix updated — N/A: extends an existing behaviour list.
  • Affected feature IDs listed under ## RelatedN/A.
  • No new external network dependencies introduced — confirmed.
  • Manual smoke checklist updated if release-cut surfaces are touched — N/A: internal config default.
  • Linked issue closed via Closes #NNN — see Related.

Impact

  • Runtime / platform: none on hot paths — same lookup that already runs for o1/o3/o4/gpt-5.
  • Security / migration / compatibility: zero. Users who explicitly set config.temperature_unsupported_models = [...] keep their customisation; the defaults only fill in when the user hasn't overridden them.
  • User-visible: Kimi K2 users (especially those hitting it through OpenRouter — common in China) stop seeing the 400 "only 1 is allowed" error on every agent turn. The 146 Sentry events / day from the affected users should drop to zero.

Related

Pre-push hook note

Pushed with --no-verify for the pre-existing macOS-arm64 whisper-rs / ggml-cpu build script issue (clang++: error: unsupported argument 'native' to option '-mcpu='). This PR touches only src/openhuman/config/schema/types.rs and src/openhuman/inference/provider/temperature.rs; cargo fmt --manifest-path Cargo.toml -- --check clean.


AI Authored PR Metadata (required for Codex/Linear PRs)

Human-authored PR — fields marked N/A.

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: fix/temperature-guard-kimi-moonshot
  • Commit SHA: 527a7a98

Validation Run

  • pnpm --filter openhuman-app format:checkN/A: no app/* files changed.
  • pnpm typecheckN/A.
  • Focused tests: 3 new cases in temperature.rs. CI will run cargo test --lib openhuman::inference::provider::temperature::tests.
  • Rust fmt/check (if changed): clean.
  • Tauri fmt/check (if changed): N/A.

Validation Blocked

  • command: full cargo test --lib on Apple Silicon macOS
  • error: clang++: error: unsupported argument 'native' to option '-mcpu=' in whisper-rs / ggml-cpu build script
  • impact: Pre-existing macOS-arm64 voice toolchain issue, unrelated. CI Linux runs the full suite.

Behavior Changes

  • Intended behavior change: 3 new glob patterns added to the default temperature_unsupported_models list — Kimi K2 + Moonshot models now get their temperature field omitted by default.
  • User-visible effect: Kimi K2 users via custom_openai / OpenRouter stop seeing the 400 "only 1 is allowed" error.

Parity Contract

  • Legacy behavior preserved: Yes — existing patterns (o1*/o3*/o4*/gpt-5*) untouched; user overrides of temperature_unsupported_models continue to win.
  • Guard/fallback/dispatch parity checks: Negative regression test pins that unrelated substring-adjacent models stay unsuppressed.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): None known.
  • Canonical PR: This PR.
  • Resolution: N/A.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added proper temperature parameter handling for Moonshot Kimi K2 family models and OpenRouter/third-party gateway variants to ensure compatibility with model requirements.
  • Tests

    • Added comprehensive unit tests verifying temperature suppression for Moonshot Kimi K2 models and regression guards to prevent unintended behavior on similarly-named models.

Review Change Stack

…ported list (tinyhumansai#2076)

Sentry OPENHUMAN-TAURI-HB shows 146 events in the last day from users
in China hitting:

  {error: invalid temperature: only 1 is allowed for this model}

on kimi-k2.6 routed through custom_openai. The Moonshot Kimi K2 family
only accepts temperature=1 (or no temperature field at all); the
existing temperature_unsupported_models gate already does the right
thing for OpenAI o1/o3/o4/gpt-5 — Kimi just wasn't on the list.

Extends default_temperature_unsupported_models with three new glob
patterns covering the realistic naming variants users hit:

* kimi-k2*       — direct Moonshot API (kimi-k2.6, kimi-k2-instruct,
                   kimi-k2-pro, kimi-k2-…).
* moonshot*      — OpenRouter / Moonshot direct routes (moonshot/...,
                   moonshot-v1-8k, …).
* moonshotai/*   — alternate OpenRouter namespacing.

Tests
-----

temperature.rs gains three cases under the 'tinyhumansai#2076' header:

* temperature_suppressed_for_kimi_k2 — covers the exact reporter
  variant (kimi-k2.6) plus instruct / pro siblings.

* temperature_suppressed_for_moonshot_namespaced_kimi — covers
  OpenRouter-style moonshot/... and moonshotai/... routings plus the
  moonshot-v1-8k variant.

* temperature_still_allowed_for_unrelated_models_after_kimi_additions
  — negative regression guard. Adding kimi-k2*/moonshot*/moonshotai/*
  must NOT start suppressing temperature for unrelated model names
  that share substrings (kimichat-legacy, moonshine-asr, claude-…,
  gemini-…).

Local: cargo fmt --check clean.
@YOMXXX YOMXXX requested a review from a team May 18, 2026 09:43
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0e0f83ff-b0d7-4387-b4fd-b2c5104d2228

📥 Commits

Reviewing files that changed from the base of the PR and between 579addf and 527a7a9.

📒 Files selected for processing (2)
  • src/openhuman/config/schema/types.rs
  • src/openhuman/inference/provider/temperature.rs

📝 Walkthrough

Walkthrough

This PR extends temperature suppression for models that only accept fixed temperature values (temperature = 1 or no parameter). The configuration now covers Kimi K2-family models and their OpenRouter/third-party gateway namespaced variants, with complete test coverage validating the patterns and preventing regressions.

Changes

Kimi K2 temperature suppression

Layer / File(s) Summary
Kimi K2 temperature suppression patterns and validation
src/openhuman/config/schema/types.rs, src/openhuman/inference/provider/temperature.rs
Extended default_temperature_unsupported_models() to add glob patterns for kimi-k2*, moonshot*, and moonshotai/* alongside existing OpenAI o-series and GPT-5 patterns. Tests verify suppression for Kimi K2 model IDs and their namespaced variants (moonshot/..., moonshotai/...), plus a regression guard ensuring unrelated models with partial substring matches (e.g., kimichat-*, moonshine-*) are not incorrectly suppressed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes


🐰 A rabbit hops through config gates,
Kimi's K2 temperature awaits,
No more "only one" errors in sight,
Patterns suppressed, the models stay right! 🎯

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR addresses issue #2076 by adding temperature suppression for Kimi K2 and Moonshot models, preventing 'only 1 is allowed' errors. However, it does not address issue #2079 regarding abstract tier name translation for custom providers. Address issue #2079 by implementing validation/translation of abstract tier names (e.g., reasoning-v1) for custom_openai providers to prevent invalid model names from being forwarded to upstream APIs.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding Kimi K2 and Moonshot models to the temperature-unsupported list, directly matching the code modifications in both files.
Out of Scope Changes check ✅ Passed All changes are directly scoped to adding Kimi K2 and Moonshot patterns to temperature suppression logic, with supporting tests. No out-of-scope modifications were introduced.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@YOMXXX
Copy link
Copy Markdown
Contributor Author

YOMXXX commented May 18, 2026

Heads-up — the lone red Rust Core Coverage check on this PR is the same flaky test on main I flagged on #2042 (comment).

The failure is:

openhuman::composio::action_tool::tests::factory_routes_through_direct_when_mode_is_direct
  panicked at src/openhuman/composio/action_tool.rs:480:9
  7603 passed; 1 failed

This PR only edits src/openhuman/config/schema/types.rs (a default-list addition) and src/openhuman/inference/provider/temperature.rs (new test cases). No path by which it could influence composio::action_tool.

Same evidence pattern as #2042: the parallel test / Rust Core Tests + Quality job on the same commit passed; only Rust Core Coverage (cargo-llvm-cov) fails. Different harness, same test code = flaky.

@senamakel — would you be able to re-trigger this run when convenient? I don't have rerun rights on the upstream actions for fork PRs.

The Rust Core Coverage check is currently gated by a flaky upstream
test (composio::action_tool::tests::factory_routes_through_direct_when_mode_is_direct)
that intermittently fails when run via cargo-llvm-cov but passes in
the parallel 'test / Rust Core Tests + Quality' job on the same
commit. Evidence: see comment at
tinyhumansai#2082 (comment)

Empty commit to nudge CI to re-run. No code change.
@senamakel senamakel merged commit aa10206 into tinyhumansai:main May 19, 2026
22 checks passed
mtkik pushed a commit to mtkik/openhuman-meet that referenced this pull request May 21, 2026
CodeGhost21 pushed a commit to CodeGhost21/openhuman that referenced this pull request May 22, 2026
AusAgentSmith pushed a commit to AusAgentSmith/openhuman that referenced this pull request May 23, 2026
…ported list (tinyhumansai#2076) (tinyhumansai#2082)

Co-authored-by: 李冠辰 <liguanchen@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants