Repository navigation
fix(kimi): drop the unsupported output.encrypted_content include on Kimi Code Responses #8122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
845cd28
fix(kimi): drop the unsupported output.encrypted_content include on K…
lidge-jun ed2da61
fix(kimi): scope the include strip to the HTTPS default-port endpoint…
lidge-jun 5fa83b6
test(kimi): cover duplicate output.encrypted_content entries
lidge-jun 724348e
docs(kimi): note the Kimi Code include normalization in the adapters …
lidge-jun 5b29dfc
Merge remote-tracking branch 'origin/dev' into lead/sync-8122
lidge-jun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { describe, expect, test } from "bun:test"; | ||
| import { createResponsesPassthroughAdapter } from "../../src/adapters/openai-responses"; | ||
| import { parseRequest } from "../../src/responses/parser"; | ||
| import { createTranslatorBudget } from "../../src/lib/translator-budget"; | ||
| import type { OcxProviderConfig } from "../../src/types"; | ||
|
|
||
| // #8075: Kimi Code's native Responses endpoint answers 400 for the output.encrypted_content | ||
| // include entry that Codex Desktop sends on every turn. | ||
| const provider: OcxProviderConfig = { | ||
| adapter: "openai-responses", baseUrl: "https://api.kimi.com/coding/v1", | ||
| authMode: "key", apiKey: "test-credential", modelSuffixBracketStrip: true, | ||
| }; | ||
| const input = [ | ||
| { type: "message", role: "user", content: "read the file" }, | ||
| { type: "function_call", call_id: "call_1", name: "read_file", arguments: "{}" }, | ||
| { type: "function_call_output", call_id: "call_1", output: "first line" }, | ||
| ]; | ||
|
|
||
| function wire(include: unknown, target: OcxProviderConfig = provider): Record<string, unknown> { | ||
| const raw = { model: "k3.1-pro[256k]", input, stream: true, ...(include === undefined ? {} : { include }) }; | ||
| const snapshot = JSON.stringify(raw); | ||
| const budget = createTranslatorBudget(); | ||
| const request = createResponsesPassthroughAdapter(target) | ||
| .buildRequest(parseRequest(raw), { headers: new Headers(), translatorBudget: budget }); | ||
| request.releaseBodyObservation?.(); | ||
| budget.dispose(); | ||
| expect(JSON.stringify(raw)).toBe(snapshot); | ||
| return JSON.parse(request.body) as Record<string, unknown>; | ||
| } | ||
|
|
||
| describe("Kimi Code Responses include normalization (#8075)", () => { | ||
| test("removes only output.encrypted_content and keeps the other entries in order", () => { | ||
| const body = wire(["reasoning.encrypted_content", "output.encrypted_content", "message.output_text.logprobs"]); | ||
| expect(body.include).toEqual(["reasoning.encrypted_content", "message.output_text.logprobs"]); | ||
| expect(body.input).toEqual(input); | ||
| }); | ||
|
|
||
| test("omits include when the rejected entry was the only one", () => { | ||
| expect(wire(["output.encrypted_content"])).not.toHaveProperty("include"); | ||
| }); | ||
|
|
||
| test("removes every duplicate output.encrypted_content", () => { | ||
| expect(wire(["output.encrypted_content", "reasoning.encrypted_content", "output.encrypted_content"]).include) | ||
| .toEqual(["reasoning.encrypted_content"]); | ||
| }); | ||
|
|
||
| test("an absent or already-supported include list is unchanged", () => { | ||
| expect(wire(undefined)).not.toHaveProperty("include"); | ||
| expect(wire(["reasoning.encrypted_content"]).include).toEqual(["reasoning.encrypted_content"]); | ||
| }); | ||
|
|
||
| test.each([ | ||
| "https://api.kimi.com/v1", "https://api.kimi.com/coding/v2", | ||
| "https://api.kimi.com.evil.test/coding/v1", "https://kimi.example.test/coding/v1", | ||
| "https://api.moonshot.ai/v1", "http://api.kimi.com/coding/v1", "https://api.kimi.com:444/coding/v1", | ||
| ])("leaves other destinations untouched: %s", baseUrl => { | ||
| const include = ["reasoning.encrypted_content", "output.encrypted_content"]; | ||
| expect(wire(include, { ...provider, baseUrl }).include).toEqual(include); | ||
| }); | ||
| }); | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.