mirror of
https://github.com/router-for-me/CLIProxyAPIPlus.git
synced 2026-03-10 15:53:16 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e35ffaa925 | ||
|
|
14f044ce4f | ||
|
|
88872baffc |
@@ -883,8 +883,21 @@ func BuildAssistantMessageStruct(msg gjson.Result) KiroAssistantResponseMessage
|
||||
contentBuilder.WriteString(content.String())
|
||||
}
|
||||
|
||||
// CRITICAL FIX: Kiro API requires non-empty content for assistant messages
|
||||
// This can happen with compaction requests where assistant messages have only tool_use
|
||||
// (no text content). Without this fix, Kiro API returns "Improperly formed request" error.
|
||||
finalContent := contentBuilder.String()
|
||||
if strings.TrimSpace(finalContent) == "" {
|
||||
if len(toolUses) > 0 {
|
||||
finalContent = kirocommon.DefaultAssistantContentWithTools
|
||||
} else {
|
||||
finalContent = kirocommon.DefaultAssistantContent
|
||||
}
|
||||
log.Debugf("kiro: assistant content was empty, using default: %s", finalContent)
|
||||
}
|
||||
|
||||
return KiroAssistantResponseMessage{
|
||||
Content: contentBuilder.String(),
|
||||
Content: finalContent,
|
||||
ToolUses: toolUses,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,14 @@ const (
|
||||
// InlineCodeMarker is the markdown inline code marker (backtick).
|
||||
InlineCodeMarker = "`"
|
||||
|
||||
// DefaultAssistantContentWithTools is the fallback content for assistant messages
|
||||
// that have tool_use but no text content. Kiro API requires non-empty content.
|
||||
DefaultAssistantContentWithTools = "I'll help you with that."
|
||||
|
||||
// DefaultAssistantContent is the fallback content for assistant messages
|
||||
// that have no content at all. Kiro API requires non-empty content.
|
||||
DefaultAssistantContent = "I understand."
|
||||
|
||||
// KiroAgenticSystemPrompt is injected only for -agentic models to prevent timeouts on large writes.
|
||||
// AWS Kiro API has a 2-3 minute timeout for large file write operations.
|
||||
KiroAgenticSystemPrompt = `
|
||||
|
||||
@@ -718,13 +718,10 @@ func buildAssistantMessageFromOpenAI(msg gjson.Result) KiroAssistantResponseMess
|
||||
// This can happen with compaction requests or error recovery scenarios
|
||||
finalContent := contentBuilder.String()
|
||||
if strings.TrimSpace(finalContent) == "" {
|
||||
const defaultAssistantContentWithTools = "I'll help you with that."
|
||||
const defaultAssistantContent = "I understand."
|
||||
|
||||
if len(toolUses) > 0 {
|
||||
finalContent = defaultAssistantContentWithTools
|
||||
finalContent = kirocommon.DefaultAssistantContentWithTools
|
||||
} else {
|
||||
finalContent = defaultAssistantContent
|
||||
finalContent = kirocommon.DefaultAssistantContent
|
||||
}
|
||||
log.Debugf("kiro-openai: assistant content was empty, using default: %s", finalContent)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user