mirror of
https://github.com/router-for-me/CLIProxyAPIPlus.git
synced 2026-04-25 03:26:59 +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())
|
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{
|
return KiroAssistantResponseMessage{
|
||||||
Content: contentBuilder.String(),
|
Content: finalContent,
|
||||||
ToolUses: toolUses,
|
ToolUses: toolUses,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,14 @@ const (
|
|||||||
// InlineCodeMarker is the markdown inline code marker (backtick).
|
// InlineCodeMarker is the markdown inline code marker (backtick).
|
||||||
InlineCodeMarker = "`"
|
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.
|
// 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.
|
// AWS Kiro API has a 2-3 minute timeout for large file write operations.
|
||||||
KiroAgenticSystemPrompt = `
|
KiroAgenticSystemPrompt = `
|
||||||
|
|||||||
@@ -718,13 +718,10 @@ func buildAssistantMessageFromOpenAI(msg gjson.Result) KiroAssistantResponseMess
|
|||||||
// This can happen with compaction requests or error recovery scenarios
|
// This can happen with compaction requests or error recovery scenarios
|
||||||
finalContent := contentBuilder.String()
|
finalContent := contentBuilder.String()
|
||||||
if strings.TrimSpace(finalContent) == "" {
|
if strings.TrimSpace(finalContent) == "" {
|
||||||
const defaultAssistantContentWithTools = "I'll help you with that."
|
|
||||||
const defaultAssistantContent = "I understand."
|
|
||||||
|
|
||||||
if len(toolUses) > 0 {
|
if len(toolUses) > 0 {
|
||||||
finalContent = defaultAssistantContentWithTools
|
finalContent = kirocommon.DefaultAssistantContentWithTools
|
||||||
} else {
|
} else {
|
||||||
finalContent = defaultAssistantContent
|
finalContent = kirocommon.DefaultAssistantContent
|
||||||
}
|
}
|
||||||
log.Debugf("kiro-openai: assistant content was empty, using default: %s", finalContent)
|
log.Debugf("kiro-openai: assistant content was empty, using default: %s", finalContent)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user