|
1 | 1 | import { describe, expect, test } from "bun:test"; |
| 2 | +import { createOpenAIChatAdapter } from "../src/adapters/openai-chat"; |
2 | 3 | import { createRegisteredAdapter } from "../src/adapters/registry"; |
3 | 4 | import { |
4 | 5 | stripClinePassDeepSeekV4ToolReplayNarration, |
@@ -72,12 +73,16 @@ function parsedWithHybridToolTurn(modelId: string): OcxParsedRequest { |
72 | 73 | }; |
73 | 74 | } |
74 | 75 |
|
75 | | -async function outboundMessages(modelId: string): Promise<Array<Record<string, unknown>>> { |
76 | | - const adapter = createRegisteredAdapter(provider); |
77 | | - const request = await adapter.buildRequest(parsedWithHybridToolTurn(modelId), { |
| 76 | +function incoming() { |
| 77 | + return { |
78 | 78 | headers: new Headers(), |
79 | 79 | translatorBudget: createTestTranslatorBudget(), |
80 | | - }); |
| 80 | + }; |
| 81 | +} |
| 82 | + |
| 83 | +async function outboundMessages(modelId: string): Promise<Array<Record<string, unknown>>> { |
| 84 | + const adapter = createRegisteredAdapter(provider); |
| 85 | + const request = await adapter.buildRequest(parsedWithHybridToolTurn(modelId), incoming()); |
81 | 86 | const body = JSON.parse(request.body) as { messages?: Array<Record<string, unknown>> }; |
82 | 87 | return body.messages ?? []; |
83 | 88 | } |
@@ -106,12 +111,12 @@ describe("ClinePass DeepSeek V4 tool-call history replay", () => { |
106 | 111 | expect(finalAssistant).toBeDefined(); |
107 | 112 | }); |
108 | 113 |
|
109 | | - test("leaves hybrid assistant content unchanged for non-target models", async () => { |
110 | | - const messages = await outboundMessages("cline-pass/not-deepseek-v4"); |
111 | | - const toolTurn = messages.find(message => Array.isArray(message.tool_calls)); |
| 114 | + test("leaves non-target OpenAI-chat requests byte-identical", async () => { |
| 115 | + const parsed = parsedWithHybridToolTurn("cline-pass/not-deepseek-v4"); |
| 116 | + const plainRequest = await createOpenAIChatAdapter(provider).buildRequest(parsed, incoming()); |
| 117 | + const wrappedRequest = await createRegisteredAdapter(provider).buildRequest(parsed, incoming()); |
112 | 118 |
|
113 | | - expect(toolTurn?.content).toContain("I should inspect the repository first."); |
114 | | - expect(toolTurn?.content).toContain("Let me run that now."); |
| 119 | + expect(wrappedRequest.body).toBe(plainRequest.body); |
115 | 120 | }); |
116 | 121 |
|
117 | 122 | test("keeps reasoning metadata when stripping a target tool turn", () => { |
|
0 commit comments