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" ;
44import type { SessionCreatedActor } from "../../packages/gateway-protocol/src/index.js" ;
55import { resetProviderAuthAliasMapCacheForTest } from "../agents/provider-auth-aliases.test-support.js" ;
66import type { OpenClawConfig } from "../config/config.js" ;
@@ -16,11 +16,20 @@ import { applySessionsPatchToStore } from "./sessions-patch.js";
1616const 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
2024vi . 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+
2433const SUBAGENT_MODEL = "synthetic/hf:moonshotai/Kimi-K2.7-Code" ;
2534const KIMI_SUBAGENT_KEY = "agent:kimi:subagent:child" ;
2635const MAIN_SESSION_KEY = "agent:main:main" ;
@@ -256,6 +265,32 @@ function createAllowlistedAnthropicModelCfg(): OpenClawConfig {
256265}
257266
258267describe ( "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