Skip to content

bug: Kimi Code OAuth shows incorrect Max Output (32K instead of 131K) #1215

Description

@myk1yt

Bug Description

When selecting Settings > Providers > API Provider > Kimi Code > OAuth, the Max Output field shows 32,768 for all Kimi Code models. According to Kimi's official documentation, the correct values are:

  • kimi-k3 (Kimi Code model ID: k3): max_completion_tokens defaults to 131,072, context window 1,048,576 (1M)
  • kimi-k2.7-code (Kimi Code model ID: kimi-for-coding): max output = 256K - prompt_tokens, context window 262,144 (256K)

The Context Window displays correctly (values come from the server's /models API context_length field), but Max Output does not.

Root Cause

Three issues in the codebase:

  1. Hardcoded default: kimiCodeDefaultModelInfo.maxTokens is set to 32_768 instead of 131_072
  2. Missing schema field: The Zod schema in kimiCodeModelSchema doesn't include a max_tokens field, so even if the server returns it, it gets silently stripped
  3. No override logic: mapKimiCodeModel() overrides contextWindow from the server response but does NOT override maxTokens

Impact

All Kimi Code models (kimi-for-coding, k3, k3-256k, kimi-for-coding-highspeed) display incorrect Max Output values. This affects the UI display and potentially the max_tokens parameter sent to the API.

Fix

A fix is ready in branch fix/kimi-code (commit 69f3ce3a8) with the following changes:

  • Update kimiCodeDefaultModelInfo.maxTokens from 32_768 to 131_072
  • Add kimiCodeModelDefaults for per-model fallback values
  • Add max_tokens to kimiCodeModelSchema for server response parsing
  • Override maxTokens in mapKimiCodeModel(): server value > model default > global default
  • Add 4 new tests covering all fallback paths

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions