fix(providers): set qwen cache_read to the documented 20% implicit-cache rate

Alibaba Model Studio's context-cache doc bills cached input tokens at 20% of the
input price (implicit hits, International endpoint). Most of the qwen catalog
already used 20%; align the outliers and guard against future drift.

- qwen3.7-max 1.25 -> 0.5, qwen3.7-plus 0.2 -> 0.08: corrects an earlier change
  that read a "50% discount" off the model-pricing page; the authoritative rate
  is 20%, so the original 0.5 for qwen3.7-max was already correct.
- qwen3.6-{max-preview,plus,flash}, qwen3.5-{plus,flash}: 10% -> 20% stale
  outliers, with matching config.yml agent-price updates.

Add TestAgentConfigPricesMatchCatalog: GetPriceInfoForType returns the agent
price with no catalog fallback, so config.yml drift silently mis-prices cost.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Sergey Kozyrenko
2026-06-26 05:04:13 +07:00
parent 2f9e86391e
commit ebeddf4e76
3 changed files with 78 additions and 15 deletions
@@ -0,0 +1,63 @@
package providers
import (
"testing"
"pentagi/pkg/providers/deepseek"
"pentagi/pkg/providers/glm"
"pentagi/pkg/providers/kimi"
"pentagi/pkg/providers/minimax"
"pentagi/pkg/providers/openai"
"pentagi/pkg/providers/pconfig"
"pentagi/pkg/providers/qwen"
)
// The default agent config (config.yml) carries its own per-agent price, and
// GetPriceInfoForType returns it verbatim (no catalog fallback), so a drift from
// the model catalog silently mis-prices cost telemetry for the default config.
func TestAgentConfigPricesMatchCatalog(t *testing.T) {
t.Parallel()
providers := []struct {
name string
config func() (*pconfig.ProviderConfig, error)
models func() (pconfig.ModelsConfig, error)
}{
{"deepseek", deepseek.DefaultProviderConfig, deepseek.DefaultModels},
{"glm", glm.DefaultProviderConfig, glm.DefaultModels},
{"kimi", kimi.DefaultProviderConfig, kimi.DefaultModels},
{"minimax", minimax.DefaultProviderConfig, minimax.DefaultModels},
{"openai", openai.DefaultProviderConfig, openai.DefaultModels},
{"qwen", qwen.DefaultProviderConfig, qwen.DefaultModels},
}
for _, p := range providers {
cfg, err := p.config()
if err != nil {
t.Fatalf("%s: DefaultProviderConfig() error: %v", p.name, err)
}
models, err := p.models()
if err != nil {
t.Fatalf("%s: DefaultModels() error: %v", p.name, err)
}
catalog := make(map[string]*pconfig.PriceInfo, len(models))
for i := range models {
catalog[models[i].Name] = models[i].Price
}
for _, opt := range pconfig.AllAgentTypes {
ac := cfg.AgentConfigForType(opt)
if ac == nil || ac.Model == "" || ac.Price == nil {
continue
}
cat, ok := catalog[ac.Model]
if !ok || cat == nil {
continue
}
if *ac.Price != *cat {
t.Errorf("%s/%s model %q: config.yml price %+v != catalog price %+v", p.name, opt, ac.Model, *ac.Price, *cat)
}
}
}
}
+8 -8
View File
@@ -30,7 +30,7 @@ simple:
price:
input: 0.1
output: 0.4
cache_read: 0.01
cache_read: 0.02
simple_json:
model: "qwen3.5-flash"
@@ -43,7 +43,7 @@ simple_json:
price:
input: 0.1
output: 0.4
cache_read: 0.01
cache_read: 0.02
primary_agent:
model: "qwen3.6-plus"
@@ -56,7 +56,7 @@ primary_agent:
price:
input: 0.5
output: 3.0
cache_read: 0.05
cache_read: 0.10
assistant:
model: "qwen3.6-plus"
@@ -69,7 +69,7 @@ assistant:
price:
input: 0.5
output: 3.0
cache_read: 0.05
cache_read: 0.10
generator:
model: "qwen3.7-max"
@@ -120,7 +120,7 @@ reflector:
price:
input: 0.1
output: 0.4
cache_read: 0.01
cache_read: 0.02
searcher:
model: "qwen3.5-flash"
@@ -132,7 +132,7 @@ searcher:
price:
input: 0.1
output: 0.4
cache_read: 0.01
cache_read: 0.02
enricher:
model: "qwen3.5-flash"
@@ -144,7 +144,7 @@ enricher:
price:
input: 0.1
output: 0.4
cache_read: 0.01
cache_read: 0.02
coder:
model: "qwen3-coder-plus"
@@ -177,4 +177,4 @@ pentester:
price:
input: 0.5
output: 3.0
cache_read: 0.05
cache_read: 0.10
+7 -7
View File
@@ -6,7 +6,7 @@
price:
input: 0.4
output: 1.6
cache_read: 0.2
cache_read: 0.08
- name: qwen3.7-max
description: Qwen3.7 Max - Next-generation flagship designed for the agent-centric era with excellence in programming, productivity tasks, and long-term autonomous execution. Pure-text interface optimal for sophisticated penetration testing automation and complex agentic security workflows
@@ -15,7 +15,7 @@
price:
input: 2.5
output: 7.5
cache_read: 1.25
cache_read: 0.5
# Qwen3.6 Series - Native vision-language models with enhanced agentic coding (April 2026)
- name: qwen3.6-max-preview
@@ -25,7 +25,7 @@
price:
input: 1.3
output: 7.8
cache_read: 0.13
cache_read: 0.26
- name: qwen3.6-plus
description: Qwen3.6 Plus - Native vision-language model with state-of-the-art performance and significant improvements over 3.5 series in agentic coding, front-end programming, OCR, and object localization. Ideal for multimodal pentesting scenarios requiring screen analysis and code reasoning (lowest <=256k tier pricing)
@@ -34,7 +34,7 @@
price:
input: 0.5
output: 3.0
cache_read: 0.05
cache_read: 0.10
- name: qwen3.6-flash
description: Qwen3.6 Flash - Native vision-language Flash model with significant performance boost over 3.5-Flash, excels in agentic coding, math/code reasoning, spatial intelligence, and object detection. Optimal for high-throughput security scanning with multimodal awareness
@@ -43,7 +43,7 @@
price:
input: 0.25
output: 1.5
cache_read: 0.025
cache_read: 0.05
- name: qwen3.6-35b-a3b
description: Qwen3.6 35B Open-Source - MoE variant (35B params, ~3B active) of the Qwen3.6 native vision-language series. Cost-effective on-premises option for continuous security monitoring with multimodal awareness
@@ -69,7 +69,7 @@
price:
input: 0.4
output: 2.4
cache_read: 0.04
cache_read: 0.08
- name: qwen3.5-flash
description: Qwen3.5 Flash - Native vision-language Flash with outstanding performance and pure-text capabilities. Ultra-fast lightweight model optimized for high-throughput security scanning and rapid vulnerability classification
@@ -78,7 +78,7 @@
price:
input: 0.1
output: 0.4
cache_read: 0.01
cache_read: 0.02
- name: qwen3.5-397b-a17b
description: Qwen3.5 397B Open-Source - Largest open-source model in 3.5 series with hybrid architecture (397B params, ~17B active) and exceptional reasoning capabilities. Suitable for deep on-premises security research and sophisticated threat modeling