Skip to content

feat(pricing): seed Qwen3.8 Max built-in model pricing - #6053

Merged
farion1231 merged 3 commits into
farion1231:mainfrom
mhy1227:feat/pricing-qwen3.8-max
Aug 3, 2026
Merged

farion1231 merged 3 commits into
farion1231:mainfrom
mhy1227:feat/pricing-qwen3.8-max

Conversation

@mhy1227

@mhy1227 mhy1227 commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add built-in pricing for qwen3.8-max only
  • Prices: 2 / 6 / 0.20 / 0 USD per Mtok (input / output / cache read / cache write)
  • Insert-if-absent only; no schema bump; other model rows untouched

Test plan

  • Launch app on existing DB: Usage pricing list includes qwen3.8-max
  • Confirm hand-edited prices for other models remain unchanged

@mhy1227
mhy1227 requested a review from farion1231 as a code owner August 3, 2026 04:43
@github-actions github-actions Bot added the backend Backend (Rust/Tauri) label Aug 3, 2026
Add insert-if-absent row for qwen3.8-max at 2/6 USD per Mtok input/output with 0.20 cache read.
@mhy1227
mhy1227 force-pushed the feat/pricing-qwen3.8-max branch from 73955a3 to 537638e Compare August 3, 2026 04:45
mhy1227 and others added 2 commits August 3, 2026 15:56
Align cache_write with official explicit context-cache rate (125 percent of input). cache_read stays 0.20 (10 percent hit).

@farion1231 farion1231 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

@farion1231
farion1231 merged commit f38722a into farion1231:main Aug 3, 2026
6 checks passed
biociao added a commit to biociao/cc-switch that referenced this pull request Aug 3, 2026
* chore: drop accidentally committed debug session archive

* fix(hermes): use SOUL.md instead of AGENTS.md for Hermes prompt filename (farion1231#5779)

* fix(hermes): use SOUL.md instead of AGENTS.md for Hermes prompt filename

* test(hermes): add regression test for SOUL.md prompt filename

---------

Co-authored-by: mmm-05610 <maoqh@users.noreply.github.com>
Co-authored-by: Jason <farion1231@gmail.com>

* fix(claude): align Kimi for Coding presets with real context windows

Claude Code caps unknown non-Claude model ids at 200K, so Kimi's
Anthropic-protocol presets show the wrong context unless each preset
declares CLAUDE_CODE_MAX_CONTEXT_TOKENS / CLAUDE_CODE_AUTO_COMPACT_WINDOW
explicitly. This commit brings every Kimi Claude Code preset in line with
its actual window so the status bar and compact window match reality.

Claude provider presets (src/config/claudeProviderPresets.ts):
- Kimi (Moonshot, kimi-k2.7-code): pin 262144 — was missing entirely,
  causing Claude Code to display 200K instead of the real 256K.
- Kimi K3 (Moonshot, kimi-k3): new preset, pin 1048576 (1M).
- Kimi For Coding (kimi-for-coding): pin 262144 — was already there.
- Kimi K3 (Kimi Code, k3): new preset, pin 1048576 (1M). k3 is the
  Kimi Code service alias, distinct from kimi-k3 on the Moonshot
  platform; both presets coexist to cover the two subscription channels.
- Kimi K3 256K (Kimi Code, k3-256k): new preset, pin 262144. Half the
  token cost of k3 within 256K, broader tier availability.
- Kimi For Coding HighSpeed (Kimi Code, kimi-for-coding-highspeed):
  new preset, pin 262144. ~5–6× faster output, ~3× token cost.

Live settings pipeline (src-tauri/src/services/provider/live.rs):
- is_kimi_for_coding_provider() now matches both api.kimi.com/coding
  and api.moonshot.cn/anthropic, so apply_kimi_for_coding_context_defaults
  fires for all six Kimi presets.
- Documented accordingly: the 262144 default is the floor; presets
  that need 1M (k3, kimi-k3) win by providing an explicit env value
  in settingsConfig, which the existing 'explicit user values always
  win' branch already routes through.

Model IDs and context windows are sourced from
https://www.kimi.com/code/docs/kimi-code/models.

* feat(claude-science): serve /claude-science/v1/models via proxy to bypass OAuth

Claude Science reads ANTHROPIC_BASE_URL and calls /v1/models through the
cc-switch proxy. The route was missing (404), so the Science model dropdown
showed "Couldn't load the full model list" and Fable never appeared.

Register GET /claude-science/v1/models alongside the existing messages route
and answer it with model_list_response() from the current claude-science
provider, so the model list is served from cc-switch config (no Anthropic
OAuth involved) and Fable tier shows up when configured.

* fix(proxy): repair orphan tool_use/tool_result pairing for non-official endpoints

Strict Anthropic-compatible gateways (e.g. DeepSeek's official /anthropic
endpoint with deepseek-v4-flash/v4-pro, MiniMax, Kimi for Coding) reject
message histories where an assistant tool_use has no matching tool_result
in the immediately following message:
  "tool_use ids were found without tool_result blocks immediately after:
   call_00_..."
This happens when a turn is interrupted after the tool_use block is
persisted, or with DeepSeek V4's parallel tool calls whose results did not
all arrive.

For non-official endpoints, repair both directions:
- orphan tool_use -> inject a synthetic error tool_result into the following
  user message (creating one when the turn ends at the assistant message);
- orphan tool_result -> downgrade to a text block.

Matching is count-based rather than set-based so parallel/concurrent
tool_uses that share an id (or whose results partially arrived) are each
covered by a synthetic result. Properly paired history and official
api.anthropic.com traffic pass through untouched.

* fix(proxy): count-based orphan tool_use repair for DeepSeek parallel calls

DeepSeek's official /anthropic endpoint validates tool_use/tool_result
pairing one-for-one and rejects any leftover tool_use with
"tool_use ids were found without tool_result blocks immediately after"
(seen with deepseek-v4-flash in Claude Science). The kimi/orphan repair
matched by HashSet membership, so parallel tool_uses sharing an id — or
whose results partially arrived — were treated as answered and no
synthetic result was injected.

Switch pass 1 to count-based matching and inject one synthetic error
tool_result per unanswered tool_use (in emission order).

* fix(proxy): improve GitHub Copilot compatibility with modern Claude Code (farion1231#5832)

* 修复 Copilot 与新版 Claude Code 的兼容问题

* docs(proxy): correct Copilot placeholder rationale to the real mechanism

Claude Code (verified on 2.1.220) does not format-validate ANTHROPIC_API_KEY
against sk-ant-*: in headless mode the placeholder is sent upstream as-is.
The actual failure mode is the interactive custom-API-key approval prompt,
which defaults to "No (recommended)" — following the default ignores the
key and lands users in "Not logged in". Also drop the farion1231#3289 citation,
which describes a missing-placeholder scenario, not key validation.

---------

Co-authored-by: Jason <farion1231@gmail.com>

* feat(pricing): seed Qwen3.8 Max built-in model pricing (farion1231#6053)

* feat(pricing): seed Qwen3.8 Max built-in model pricing

Add insert-if-absent row for qwen3.8-max at 2/6 USD per Mtok input/output with 0.20 cache read.

* fix(pricing): set qwen3.8-max cache write to 2.50

Align cache_write with official explicit context-cache rate (125 percent of input). cache_read stays 0.20 (10 percent hit).

* fix(pricing): correct qwen3.8-max cache read price

---------

Co-authored-by: Jason <farion1231@gmail.com>

* fix(claude-desktop): allow aggregate providers (no env/base_url)

聚合供应商的占位 settings_config 是空对象,meta.claudeDesktopMode
默认 Direct,过去会被 validate_direct_provider 用 settings_config.env
校验拦截,触发「缺少 env 配置」错误。

修复:
- provider_mode 对聚合供应商恒返回 Proxy(聚合只能在代理模式工作)
- validate_provider 对聚合早退放行,与官方供应商一致
- apply_provider_to_paths_inner 对聚合只写 deployment_mode/meta,
  不要求 claudeDesktopModelRoutes
- 新增 2 个单元测试覆盖上述路径

* fix(claude): gate Moonshot kimi context fallback on the configured model

The Moonshot endpoint (api.moonshot.cn/anthropic) now serves both K2.7
(256K) and K3 (1M). The endpoint-only fallback in
apply_kimi_for_coding_context_defaults was forcing every Moonshot provider
to the 262144 K2.7 default even when ANTHROPIC_MODEL targeted kimi-k3, so
existing/custom providers (and any user who edited the model on the
original Kimi preset) would still compact at 256K. The new K3 preset only
worked around this by explicitly storing the 1M env values.

Inspect the configured model slots (ANTHROPIC_MODEL plus the per-tier
defaults) on the Moonshot endpoint and pick the K3 1M default when every
set slot targets kimi-k3; fall back to 262144 otherwise. The Kimi Code
endpoint (api.kimi.com/coding) keeps the 256K default unconditionally —
K3 is not served there. Explicit user values still win on either endpoint.

Addresses codex P2 review feedback on farion1231#6038.

---------

Co-authored-by: mao qinghui <2760376727@qq.com>
Co-authored-by: mmm-05610 <maoqh@users.noreply.github.com>
Co-authored-by: Jason <farion1231@gmail.com>
Co-authored-by: Xu Lei <312251702@qq.com>
Co-authored-by: mhy1227 <zsmy1227@outlook.com>
biociao added a commit to biociao/cc-switch that referenced this pull request Aug 3, 2026
Moonshot Kimi context-window fallback now follows the configured model
(kimi-k3 gets the 1M window instead of the K2.7 256K clamp), and
upstream's Qwen3.8 Max built-in pricing (farion1231#6053) is merged in.
See CHANGELOG [3.19.1+ciao.5].

Also corrects the version fields, which ciao.4's release-notes commit
left at +ciao.3.
Qfbxz pushed a commit to Qfbxz/cc-switch that referenced this pull request Aug 12, 2026
Integrates official v3.19.2 (upstream/main @ 413c09e) on top of local
customizations. All 4 open PRs (farion1231#5763, farion1231#5764, farion1231#5765, farion1231#5772) remain
unmerged upstream; their changes are preserved on this branch.

Upstream v3.19.2 highlights:
- Codex interleaved-counter usage fix (farion1231#5854)
- Six security hardening caps (farion1231#5919)
- MCP/Skills panel search & bulk toggles (farion1231#5967)
- Per-account Codex OAuth usage in Auth Center (farion1231#4887)
- OMO unified config + runtime models (farion1231#6011, farion1231#5522)
- Backup batch dump/restore (farion1231#6122), Codex reimport ~3x faster
- Copilot compat with new Claude Code (farion1231#5832)
- Hermes SOUL.md filename fix (farion1231#5779)
- Skill source-dir anchor (farion1231#4153), skills.sh README fix (farion1231#6119)
- Qwen3.8 Max built-in pricing (farion1231#6053)

No file overlap between upstream changes and local customizations;
merge is conflict-free.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend (Rust/Tauri)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants