feat(antigravity): comprehensive enhancements - model mapping, rate limiting, scheduling & ops
Key changes: - Upgrade model mapping: Opus 4.5 → Opus 4.6-thinking with precise matching - Unified rate limiting: scope-level → model-level with Redis snapshot sync - Load-balanced scheduling by call count with smart retry mechanism - Force cache billing support - Model identity injection in prompts with leak prevention - Thinking mode auto-handling (max_tokens/budget_tokens fix) - Frontend: whitelist mode toggle, model mapping validation, status indicators - Gemini session fallback with Redis Trie O(L) matching - Ops: enhanced concurrency monitoring, account availability, retry logic - Migration scripts: 049-051 for model mapping unification
This commit is contained in:
68
backend/internal/service/antigravity_thinking_test.go
Normal file
68
backend/internal/service/antigravity_thinking_test.go
Normal file
@@ -0,0 +1,68 @@
|
||||
//go:build unit
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestApplyThinkingModelSuffix(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
mappedModel string
|
||||
thinkingEnabled bool
|
||||
expected string
|
||||
}{
|
||||
// Thinking 未开启:保持原样
|
||||
{
|
||||
name: "thinking disabled - claude-sonnet-4-5 unchanged",
|
||||
mappedModel: "claude-sonnet-4-5",
|
||||
thinkingEnabled: false,
|
||||
expected: "claude-sonnet-4-5",
|
||||
},
|
||||
{
|
||||
name: "thinking disabled - other model unchanged",
|
||||
mappedModel: "claude-opus-4-6-thinking",
|
||||
thinkingEnabled: false,
|
||||
expected: "claude-opus-4-6-thinking",
|
||||
},
|
||||
|
||||
// Thinking 开启 + claude-sonnet-4-5:自动添加后缀
|
||||
{
|
||||
name: "thinking enabled - claude-sonnet-4-5 becomes thinking version",
|
||||
mappedModel: "claude-sonnet-4-5",
|
||||
thinkingEnabled: true,
|
||||
expected: "claude-sonnet-4-5-thinking",
|
||||
},
|
||||
|
||||
// Thinking 开启 + 其他模型:保持原样
|
||||
{
|
||||
name: "thinking enabled - claude-sonnet-4-5-thinking unchanged",
|
||||
mappedModel: "claude-sonnet-4-5-thinking",
|
||||
thinkingEnabled: true,
|
||||
expected: "claude-sonnet-4-5-thinking",
|
||||
},
|
||||
{
|
||||
name: "thinking enabled - claude-opus-4-6-thinking unchanged",
|
||||
mappedModel: "claude-opus-4-6-thinking",
|
||||
thinkingEnabled: true,
|
||||
expected: "claude-opus-4-6-thinking",
|
||||
},
|
||||
{
|
||||
name: "thinking enabled - gemini model unchanged",
|
||||
mappedModel: "gemini-3-flash",
|
||||
thinkingEnabled: true,
|
||||
expected: "gemini-3-flash",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := applyThinkingModelSuffix(tt.mappedModel, tt.thinkingEnabled)
|
||||
if result != tt.expected {
|
||||
t.Errorf("applyThinkingModelSuffix(%q, %v) = %q, want %q",
|
||||
tt.mappedModel, tt.thinkingEnabled, result, tt.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user