fix(kiro): canonicalize tool history and route API keys correctly

Route API-key inference through Amazon Q first, enforce adjacent
one-to-one tool use/result pairs after session replay, and treat
payload-invalid HTTP 400 as terminal.
This commit is contained in:
nguyenha935
2026-07-29 19:25:45 +07:00
parent 44c7b34837
commit 16cb40fda1
14 changed files with 1050 additions and 465 deletions

View File

@@ -62,8 +62,13 @@ export function translateRequest(sourceFormat, targetFormat, model, body, stream
// Always ensure tool_calls have id (some providers require it)
ensureToolCallIds(result);
// Fix missing tool responses (insert empty tool_result if needed)
fixMissingToolResponses(result);
// Kiro performs stricter source-aware reconciliation after session replay.
// The generic helper inserts OpenAI `role: tool` messages, which a direct
// Claude→Kiro translator cannot consume and which cannot repair partial
// parallel tool results.
if (targetFormat !== FORMATS.KIRO) {
fixMissingToolResponses(result);
}
// Capture thinking intent from the original (pre-translation) body, before any
// format conversion strips/renames the fields. Applied after translation.