Skip to content

Commit c680cc0

Browse files
author
Peter Steinberger
committed
test(gateway): isolate session patch provider policy
1 parent 0dbf9b6 commit c680cc0

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

‎src/gateway/sessions-patch.test.ts‎

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Session patch tests cover model/provider edits, subagent patching, provider
22
// aliases, model catalog validation, and rejected invalid patch payloads.
3-
import { afterEach, describe, expect, test, vi } from "vitest";
3+
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
44
import type { SessionCreatedActor } from "../../packages/gateway-protocol/src/index.js";
55
import { resetProviderAuthAliasMapCacheForTest } from "../agents/provider-auth-aliases.test-support.js";
66
import type { OpenClawConfig } from "../config/config.js";
@@ -16,11 +16,20 @@ import { applySessionsPatchToStore } from "./sessions-patch.js";
1616
const acpSessionMetaMocks = vi.hoisted(() => ({
1717
readAcpSessionMetaForEntry: vi.fn(),
1818
}));
19+
const providerThinkingMocks = vi.hoisted(() => ({
20+
resolveProviderThinkingProfile:
21+
vi.fn<typeof import("../plugins/provider-thinking.js").resolveProviderThinkingProfile>(),
22+
}));
1923

2024
vi.mock("../acp/runtime/session-meta.js", () => ({
2125
readAcpSessionMetaForEntry: acpSessionMetaMocks.readAcpSessionMetaForEntry,
2226
}));
2327

28+
// This suite owns patch projection; provider policy artifacts have dedicated contract coverage.
29+
vi.mock("../plugins/provider-thinking.js", () => ({
30+
resolveProviderThinkingProfile: providerThinkingMocks.resolveProviderThinkingProfile,
31+
}));
32+
2433
const SUBAGENT_MODEL = "synthetic/hf:moonshotai/Kimi-K2.7-Code";
2534
const KIMI_SUBAGENT_KEY = "agent:kimi:subagent:child";
2635
const MAIN_SESSION_KEY = "agent:main:main";
@@ -256,6 +265,32 @@ function createAllowlistedAnthropicModelCfg(): OpenClawConfig {
256265
}
257266

258267
describe("gateway sessions patch", () => {
268+
beforeEach(() => {
269+
providerThinkingMocks.resolveProviderThinkingProfile.mockReset();
270+
providerThinkingMocks.resolveProviderThinkingProfile.mockImplementation(
271+
({ provider, context }) => {
272+
if (provider !== "openai") {
273+
return undefined;
274+
}
275+
if (context.modelId === "gpt-5.5") {
276+
return {
277+
levels: (["off", "minimal", "low", "medium", "high", "xhigh"] as const).map((id) => ({
278+
id,
279+
})),
280+
};
281+
}
282+
if (context.modelId === "gpt-5.6-luna") {
283+
const levels =
284+
context.agentRuntime === "openclaw"
285+
? (["off", "minimal", "low", "medium", "high", "max", "ultra"] as const)
286+
: (["off", "minimal", "low", "medium", "high", "max"] as const);
287+
return { levels: levels.map((id) => ({ id })) };
288+
}
289+
return undefined;
290+
},
291+
);
292+
});
293+
259294
afterEach(() => {
260295
acpSessionMetaMocks.readAcpSessionMetaForEntry.mockReset();
261296
resetProviderAuthAliasMapCacheForTest();

0 commit comments

Comments
 (0)