@@ -281,6 +281,82 @@ describe("kimi tool-call markup wrapper", () => {
|
281 | 281 | }); |
282 | 282 | }); |
283 | 283 | |
| 284 | +it("strips Anthropic cache_control markers before Kimi requests are sent", () => { |
| 285 | +const { streamFn: baseStreamFn, getCapturedPayload } = createPayloadCapturingStream({ |
| 286 | +system: [{ type: "text", text: "stable", cache_control: { type: "ephemeral", ttl: "1h" } }], |
| 287 | +messages: [ |
| 288 | +{ |
| 289 | +role: "user", |
| 290 | +content: [ |
| 291 | +{ type: "text", text: "hello", cache_control: { type: "ephemeral" } }, |
| 292 | +{ |
| 293 | +type: "tool_result", |
| 294 | +tool_use_id: "tool_1", |
| 295 | +content: [ |
| 296 | +{ |
| 297 | +type: "text", |
| 298 | +text: "done", |
| 299 | +cache_control: { type: "ephemeral" }, |
| 300 | +}, |
| 301 | +], |
| 302 | +cache_control: { type: "ephemeral" }, |
| 303 | +}, |
| 304 | +{ |
| 305 | +type: "tool_use", |
| 306 | +id: "tool_2", |
| 307 | +name: "persist", |
| 308 | +input: { |
| 309 | +cache_control: "tool argument", |
| 310 | +nested: { cache_control: "nested argument" }, |
| 311 | +}, |
| 312 | +cache_control: { type: "ephemeral" }, |
| 313 | +}, |
| 314 | +{ type: "text", text: "bye" }, |
| 315 | +], |
| 316 | +}, |
| 317 | +], |
| 318 | +}); |
| 319 | + |
| 320 | +const wrapped = createKimiThinkingWrapper(baseStreamFn, "enabled"); |
| 321 | +void wrapped( |
| 322 | +{ |
| 323 | +api: "anthropic-messages", |
| 324 | +provider: "kimi", |
| 325 | +id: "kimi-code", |
| 326 | +} as Model<"anthropic-messages">, |
| 327 | +{ messages: [] } as Context, |
| 328 | +{}, |
| 329 | +); |
| 330 | + |
| 331 | +expect(getCapturedPayload()).toEqual({ |
| 332 | +system: [{ type: "text", text: "stable" }], |
| 333 | +messages: [ |
| 334 | +{ |
| 335 | +role: "user", |
| 336 | +content: [ |
| 337 | +{ type: "text", text: "hello" }, |
| 338 | +{ |
| 339 | +type: "tool_result", |
| 340 | +tool_use_id: "tool_1", |
| 341 | +content: [{ type: "text", text: "done" }], |
| 342 | +}, |
| 343 | +{ |
| 344 | +type: "tool_use", |
| 345 | +id: "tool_2", |
| 346 | +name: "persist", |
| 347 | +input: { |
| 348 | +cache_control: "tool argument", |
| 349 | +nested: { cache_control: "nested argument" }, |
| 350 | +}, |
| 351 | +}, |
| 352 | +{ type: "text", text: "bye" }, |
| 353 | +], |
| 354 | +}, |
| 355 | +], |
| 356 | +thinking: { type: "enabled" }, |
| 357 | +}); |
| 358 | +}); |
| 359 | + |
284 | 360 | it("lets explicit model params keep Kimi thinking disabled even when session thinking is on", () => { |
285 | 361 | const { streamFn: baseStreamFn, getCapturedPayload } = createPayloadCapturingStream(); |
286 | 362 | |
|