fix(kiro): route requests through current runtime surfaces and fix 400 REQUEST_BODY_INVALID (#3776)

This commit is contained in:
mrnim94
2026-09-09 10:45:44 +07:00
parent 7fee56bacd
commit 35b950be81
7 changed files with 57 additions and 31 deletions

View File

@@ -26,9 +26,8 @@ describe("Claude → Kiro (direct route)", () => {
expect(first.conversationState.conversationId).toBe("hermes-session-123-claude-replay");
expect(second.conversationState.conversationId).toBe("hermes-session-123-claude-replay");
expect(first.conversationState.agentContinuationId).toBeTruthy();
expect(second.conversationState.agentContinuationId).toBe(first.conversationState.agentContinuationId);
expect(first.conversationState.agentTaskType).toBe("vibe");
expect(first.conversationState).not.toHaveProperty("agentContinuationId");
expect(second.conversationState).not.toHaveProperty("agentTaskType");
expect(second.conversationState.history[0].userInputMessage.content).toBe(
first.conversationState.currentMessage.userInputMessage.content
);
@@ -84,7 +83,7 @@ describe("Claude → Kiro (direct route)", () => {
expect(out.systemPrompt).toContain(
"<thinking_mode>enabled</thinking_mode>"
);
expect(out.agentMode).toBe("vibe");
expect(out).not.toHaveProperty("agentMode");
});
it("does not send additionalModelRequestFields for Kiro models without effort support", () => {

View File

@@ -20,26 +20,26 @@ describe("Kiro auth-aware endpoint routing", () => {
]);
});
it("keeps Builder ID OAuth on the Kiro runtime surface", () => {
it("routes Builder ID OAuth through Amazon Q first (runtime path deprecated)", () => {
expect(executor.getOrderedBaseUrls(credentials("builder-id"))).toEqual([
RUNTIME,
CODEWHISPERER,
Q,
CODEWHISPERER,
RUNTIME,
]);
});
it("keeps external IdP on CodeWhisperer before Amazon Q", () => {
it("routes external IdP through Amazon Q first", () => {
expect(executor.getOrderedBaseUrls(credentials("external_idp"))).toEqual([
CODEWHISPERER,
Q,
CODEWHISPERER,
RUNTIME,
]);
});
it("regionalizes AWS endpoints for IDC without changing Kiro runtime", () => {
it("regionalizes AWS endpoints for IDC with Q first", () => {
expect(executor.getOrderedBaseUrls(credentials("idc", "eu-west-1"))).toEqual([
"https://codewhisperer.eu-west-1.amazonaws.com/generateAssistantResponse",
"https://q.eu-west-1.amazonaws.com/generateAssistantResponse",
"https://codewhisperer.eu-west-1.amazonaws.com/generateAssistantResponse",
RUNTIME,
]);
});

View File

@@ -0,0 +1,19 @@
import { describe, expect, it } from "vitest";
import { openaiToKiroRequest } from "../../open-sse/translator/request/openai-to-kiro.js";
import { claudeToKiroRequest } from "../../open-sse/translator/request/claude-to-kiro.js";
for (const [name, translate, body] of [
["OpenAI", openaiToKiroRequest, { messages: [{ role: "user", content: "hello" }] }],
["Claude", claudeToKiroRequest, { messages: [{ role: "user", content: "hello" }] }],
]) {
describe(`${name} Kiro minimal wire payload`, () => {
it("omits unsupported agent fields", () => {
const payload = translate("kiro/claude-sonnet-4.5", body, true, {});
expect(payload).not.toHaveProperty("agentMode");
expect(payload.conversationState).not.toHaveProperty("agentContinuationId");
expect(payload.conversationState).not.toHaveProperty("agentTaskType");
expect(payload.conversationState.chatTriggerType).toBe("MANUAL");
expect(payload.conversationState.currentMessage.userInputMessage.origin).toBe("AI_EDITOR");
});
});
}

View File

@@ -606,7 +606,7 @@ describe("openaiToKiroRequest", () => {
);
expect(second.conversationState.conversationId).toBe("hermes-session-openai-replay");
expect(second.conversationState.agentContinuationId).toBe(first.conversationState.agentContinuationId);
expect(second.conversationState).not.toHaveProperty("agentContinuationId");
expect(second.conversationState.history[0].userInputMessage.content).toBe(
first.conversationState.currentMessage.userInputMessage.content
);