Skip to content

v2.48.0

Choose a tag to compare

@aebrer aebrer released this 31 Jul 02:09
· 45 commits to master since this release
c4f42d9

Kimi OAuth: Auto Context Tier for K3

The k3 model on the Kimi for Coding OAuth endpoint now starts on the cheaper k3-256k wire ID and seamlessly upgrades to the full k3 (1M context) only when the session needs it — instead of paying the premium for every request.

How it works

  • Single selectable k3. OAuth discovery no longer exposes k3-256k as a separate model; you select k3 and dreb handles the wire variant.
  • Starts cheap. Fresh sessions send k3-256k on the wire (256k context window).
  • Upgrades at 245,760 tokens. When context approaches the 256k cutoff, dreb switches to the k3 wire ID and the 1M context window — the Kimi backend upgrades the prompt cache server-side with no loss.
  • Lowered compaction threshold = opt-out. If you lower the compaction threshold below the default, auto-compaction fires first and effectively disables the upgrade, keeping you on k3-256k.
  • Compacted sessions return to cheap. After auto or manual compaction, the tier re-derives from the reduced context and goes back to k3-256k where possible.
  • models.json override respected. A user-overridden k3 context window disables automatic tiering rather than being silently replaced.
  • Scoped to Kimi OAuth only. The k3-256k tier is exclusive to the Kimi for Coding OAuth endpoint; the Moonshot AI Platform and other providers are unaffected.

Technical details

  • New optional Model.wireModelId — the OpenAI-compatible completions provider sends it on the wire while assistant messages keep the stable registry ID (k3).
  • New k3-context-tier.ts module with pure derivation helpers; AgentSession applies the tier at every model set, cycle, refresh, restore, and creation site.
  • New context_window_upgrade session event with interactive-mode status line and footer refresh.

Fixes

  • Disabled-compaction path: K3 upgrade fires even when auto-compaction is disabled, since the upgrade is model-capability management, not context reduction.
  • Overflow recovery: a 256k-tier overflow upgrades and retries; a 1M-tier overflow still falls back to compact-and-retry.

Implemented by Acters in PR #416.