fix: filter out web_search/websearch tools unsupported by Kiro API

This commit is contained in:
Skyuno
2026-01-28 23:49:02 +08:00
parent 38f7e754ca
commit 5dc936a9a4

View File

@@ -17,7 +17,6 @@ import (
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
) )
// Kiro API request structs - field order determines JSON key order // Kiro API request structs - field order determines JSON key order
// KiroPayload is the top-level request structure for Kiro API // KiroPayload is the top-level request structure for Kiro API
@@ -34,7 +33,6 @@ type KiroInferenceConfig struct {
TopP float64 `json:"topP,omitempty"` TopP float64 `json:"topP,omitempty"`
} }
// KiroConversationState holds the conversation context // KiroConversationState holds the conversation context
type KiroConversationState struct { type KiroConversationState struct {
ChatTriggerType string `json:"chatTriggerType"` // Required: "MANUAL" - must be first field ChatTriggerType string `json:"chatTriggerType"` // Required: "MANUAL" - must be first field
@@ -378,7 +376,6 @@ func hasThinkingTagInBody(body []byte) bool {
return strings.Contains(bodyStr, "<thinking_mode>") || strings.Contains(bodyStr, "<max_thinking_length>") return strings.Contains(bodyStr, "<thinking_mode>") || strings.Contains(bodyStr, "<max_thinking_length>")
} }
// IsThinkingEnabledFromHeader checks if thinking mode is enabled via Anthropic-Beta header. // IsThinkingEnabledFromHeader checks if thinking mode is enabled via Anthropic-Beta header.
// Claude CLI uses "Anthropic-Beta: interleaved-thinking-2025-05-14" to enable thinking. // Claude CLI uses "Anthropic-Beta: interleaved-thinking-2025-05-14" to enable thinking.
func IsThinkingEnabledFromHeader(headers http.Header) bool { func IsThinkingEnabledFromHeader(headers http.Header) bool {
@@ -518,6 +515,15 @@ func convertClaudeToolsToKiro(tools gjson.Result) []KiroToolWrapper {
for _, tool := range tools.Array() { for _, tool := range tools.Array() {
name := tool.Get("name").String() name := tool.Get("name").String()
// Filter out web_search/websearch tools (Kiro API doesn't support them)
// This matches the behavior in AIClient-2-API/claude-kiro.js
nameLower := strings.ToLower(name)
if nameLower == "web_search" || nameLower == "websearch" {
log.Debugf("kiro: skipping unsupported tool: %s", name)
continue
}
description := tool.Get("description").String() description := tool.Get("description").String()
inputSchemaResult := tool.Get("input_schema") inputSchemaResult := tool.Get("input_schema")
var inputSchema interface{} var inputSchema interface{}