fix(claude-kiro): 确保历史消息以assistantResponseMessage结尾
当历史消息最后一条是用户消息时,添加空的assistantResponseMessage以满足Kiro API要求 默认存在configs目录,用于docker挂载
This commit is contained in:
parent
ff79531750
commit
ca8a68261f
2 changed files with 15 additions and 0 deletions
0
configs/0
Normal file
0
configs/0
Normal file
|
|
@ -780,6 +780,21 @@ async initializeAuth(forceRefresh = false) {
|
||||||
// 设置 currentContent 为 "Continue",因为我们需要一个 user 消息来触发 AI 继续
|
// 设置 currentContent 为 "Continue",因为我们需要一个 user 消息来触发 AI 继续
|
||||||
currentContent = 'Continue';
|
currentContent = 'Continue';
|
||||||
} else {
|
} else {
|
||||||
|
// 最后一条消息是 user,需要确保 history 最后一个元素是 assistantResponseMessage
|
||||||
|
// Kiro API 要求 history 必须以 assistantResponseMessage 结尾
|
||||||
|
if (history.length > 0) {
|
||||||
|
const lastHistoryItem = history[history.length - 1];
|
||||||
|
if (!lastHistoryItem.assistantResponseMessage) {
|
||||||
|
// 最后一个不是 assistantResponseMessage,需要补全一个空的
|
||||||
|
console.log('[Kiro] History does not end with assistantResponseMessage, adding empty one');
|
||||||
|
history.push({
|
||||||
|
assistantResponseMessage: {
|
||||||
|
content: 'Continue'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 处理 user 消息
|
// 处理 user 消息
|
||||||
if (Array.isArray(currentMessage.content)) {
|
if (Array.isArray(currentMessage.content)) {
|
||||||
for (const part of currentMessage.content) {
|
for (const part of currentMessage.content) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue