Skip to content

Commit 08295a4

Browse files
author
leic4u
committed
2 parents aaa5955 + a1cafe6 commit 08295a4

6 files changed

Lines changed: 117 additions & 0 deletions

File tree

internal/config/oauth_model_alias_defaults.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ func defaultKiroAliases() []OAuthModelAlias {
1414
// Sonnet 4
1515
{Name: "kiro-claude-sonnet-4", Alias: "claude-sonnet-4-20250514", Fork: true},
1616
{Name: "kiro-claude-sonnet-4", Alias: "claude-sonnet-4", Fork: true},
17+
// Opus 4.7
18+
{Name: "kiro-claude-opus-4-7", Alias: "claude-opus-4-7", Fork: true},
1719
// Opus 4.6
1820
{Name: "kiro-claude-opus-4-6", Alias: "claude-opus-4-6", Fork: true},
1921
// Opus 4.5

internal/config/oauth_model_alias_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func TestSanitizeOAuthModelAlias_InjectsDefaultKiroAliases(t *testing.T) {
8282
"claude-sonnet-4-5",
8383
"claude-sonnet-4-20250514",
8484
"claude-sonnet-4",
85+
"claude-opus-4-7",
8586
"claude-opus-4-6",
8687
"claude-opus-4-5-20251101",
8788
"claude-opus-4-5",

internal/registry/model_definitions.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,18 @@ func GetKiroModels() []*ModelInfo {
643643
MaxCompletionTokens: 64000,
644644
Thinking: &ThinkingSupport{Min: 1024, Max: 32000, ZeroAllowed: true, DynamicAllowed: true},
645645
},
646+
{
647+
ID: "kiro-claude-opus-4-7",
648+
Object: "model",
649+
Created: 1746057600, // 2025-05-01
650+
OwnedBy: "aws",
651+
Type: "kiro",
652+
DisplayName: "Kiro Claude Opus 4.7",
653+
Description: "Claude Opus 4.7 via Kiro (2.2x credit)",
654+
ContextLength: 200000,
655+
MaxCompletionTokens: 64000,
656+
Thinking: &ThinkingSupport{Min: 1024, Max: 32000, ZeroAllowed: true, DynamicAllowed: true},
657+
},
646658
{
647659
ID: "kiro-claude-opus-4-6",
648660
Object: "model",
@@ -797,6 +809,18 @@ func GetKiroModels() []*ModelInfo {
797809
MaxCompletionTokens: 4096,
798810
},
799811
// --- Agentic Variants (Optimized for coding agents with chunked writes) ---
812+
{
813+
ID: "kiro-claude-opus-4-7-agentic",
814+
Object: "model",
815+
Created: 1746057600, // 2025-05-01
816+
OwnedBy: "aws",
817+
Type: "kiro",
818+
DisplayName: "Kiro Claude Opus 4.7 (Agentic)",
819+
Description: "Claude Opus 4.7 optimized for coding agents (chunked writes)",
820+
ContextLength: 200000,
821+
MaxCompletionTokens: 64000,
822+
Thinking: &ThinkingSupport{Min: 1024, Max: 32000, ZeroAllowed: true, DynamicAllowed: true},
823+
},
800824
{
801825
ID: "kiro-claude-opus-4-6-agentic",
802826
Object: "model",

internal/registry/model_definitions_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,39 @@ func TestCodexStaticModelsIncludeGPT55(t *testing.T) {
3333
assertGPT55ModelInfo(t, "lookup", model)
3434
}
3535

36+
func TestKiroStaticModelsIncludeClaudeOpus47Variants(t *testing.T) {
37+
tests := []struct {
38+
id string
39+
displayName string
40+
}{
41+
{
42+
id: "kiro-claude-opus-4-7",
43+
displayName: "Kiro Claude Opus 4.7",
44+
},
45+
{
46+
id: "kiro-claude-opus-4-7-agentic",
47+
displayName: "Kiro Claude Opus 4.7 (Agentic)",
48+
},
49+
}
50+
51+
kiroModels := GetKiroModels()
52+
for _, tt := range tests {
53+
t.Run(tt.id, func(t *testing.T) {
54+
model := findModelInfo(kiroModels, tt.id)
55+
if model == nil {
56+
t.Fatalf("expected GetKiroModels to include %q", tt.id)
57+
}
58+
if model.DisplayName != tt.displayName {
59+
t.Fatalf("display name mismatch for %q: got %q, want %q", tt.id, model.DisplayName, tt.displayName)
60+
}
61+
lookup := LookupStaticModelInfo(tt.id)
62+
if lookup == nil {
63+
t.Fatalf("expected LookupStaticModelInfo to find %q", tt.id)
64+
}
65+
})
66+
}
67+
}
68+
3669
func findModelInfo(models []*ModelInfo, id string) *ModelInfo {
3770
for _, model := range models {
3871
if model != nil && model.ID == id {

internal/runtime/executor/kiro_executor.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,6 +1676,7 @@ func (e *KiroExecutor) mapModelToKiro(model string) string {
16761676
"amazonq-claude-sonnet-4-20250514": "claude-sonnet-4",
16771677
"amazonq-claude-haiku-4-5": "claude-haiku-4.5",
16781678
// Kiro format (kiro- prefix) - valid model names that should be preserved
1679+
"kiro-claude-opus-4-7": "claude-opus-4.7",
16791680
"kiro-claude-opus-4-6": "claude-opus-4.6",
16801681
"kiro-claude-sonnet-4-6": "claude-sonnet-4.6",
16811682
"kiro-claude-opus-4-5": "claude-opus-4.5",
@@ -1686,6 +1687,8 @@ func (e *KiroExecutor) mapModelToKiro(model string) string {
16861687
"kiro-claude-haiku-4-5": "claude-haiku-4.5",
16871688
"kiro-auto": "auto",
16881689
// Native format (no prefix) - used by Kiro IDE directly
1690+
"claude-opus-4-7": "claude-opus-4.7",
1691+
"claude-opus-4.7": "claude-opus-4.7",
16891692
"claude-opus-4-6": "claude-opus-4.6",
16901693
"claude-opus-4.6": "claude-opus-4.6",
16911694
"claude-sonnet-4-6": "claude-sonnet-4.6",
@@ -1701,6 +1704,8 @@ func (e *KiroExecutor) mapModelToKiro(model string) string {
17011704
"claude-sonnet-4-20250514": "claude-sonnet-4",
17021705
"auto": "auto",
17031706
// Agentic variants (same backend model IDs, but with special system prompt)
1707+
"claude-opus-4.7-agentic": "claude-opus-4.7",
1708+
"kiro-claude-opus-4-7-agentic": "claude-opus-4.7",
17041709
"claude-opus-4.6-agentic": "claude-opus-4.6",
17051710
"claude-sonnet-4.6-agentic": "claude-sonnet-4.6",
17061711
"claude-opus-4.5-agentic": "claude-opus-4.5",
@@ -1749,6 +1754,10 @@ func (e *KiroExecutor) mapModelToKiro(model string) string {
17491754

17501755
// Check for Opus variants
17511756
if strings.Contains(modelLower, "opus") {
1757+
if strings.Contains(modelLower, "4-7") || strings.Contains(modelLower, "4.7") {
1758+
log.Debugf("kiro: unknown Opus 4.7 model '%s', mapping to claude-opus-4.7", model)
1759+
return "claude-opus-4.7"
1760+
}
17521761
if strings.Contains(modelLower, "4-6") || strings.Contains(modelLower, "4.6") {
17531762
log.Debugf("kiro: unknown Opus 4.6 model '%s', mapping to claude-opus-4.6", model)
17541763
return "claude-opus-4.6"

internal/runtime/executor/kiro_executor_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,3 +421,51 @@ func TestEndpointAliases(t *testing.T) {
421421
t.Errorf("unexpected number of aliases: got %d, want %d", len(endpointAliases), len(expectedAliases))
422422
}
423423
}
424+
425+
func TestMapModelToKiro_MapsClaudeOpus47Variants(t *testing.T) {
426+
executor := &KiroExecutor{}
427+
tests := []struct {
428+
name string
429+
model string
430+
expected string
431+
}{
432+
{
433+
name: "kiro alias",
434+
model: "kiro-claude-opus-4-7",
435+
expected: "claude-opus-4.7",
436+
},
437+
{
438+
name: "kiro agentic alias",
439+
model: "kiro-claude-opus-4-7-agentic",
440+
expected: "claude-opus-4.7",
441+
},
442+
{
443+
name: "native hyphen alias",
444+
model: "claude-opus-4-7",
445+
expected: "claude-opus-4.7",
446+
},
447+
{
448+
name: "native dotted alias",
449+
model: "claude-opus-4.7",
450+
expected: "claude-opus-4.7",
451+
},
452+
{
453+
name: "native agentic alias",
454+
model: "claude-opus-4.7-agentic",
455+
expected: "claude-opus-4.7",
456+
},
457+
{
458+
name: "unknown opus 4.7 fallback",
459+
model: "partner-opus-4.7-preview",
460+
expected: "claude-opus-4.7",
461+
},
462+
}
463+
464+
for _, tt := range tests {
465+
t.Run(tt.name, func(t *testing.T) {
466+
if got := executor.mapModelToKiro(tt.model); got != tt.expected {
467+
t.Fatalf("mapModelToKiro(%q) = %q, want %q", tt.model, got, tt.expected)
468+
}
469+
})
470+
}
471+
}

0 commit comments

Comments
 (0)