@@ -31,7 +31,11 @@ import { buildGatewaySessionEventFields } from "./session-event-payload.js";
3131import { resolveSessionStoreAgentId , resolveSessionStoreKey } from "./session-store-key.js" ;
3232import { deriveSessionTitle } from "./session-utils-core.js" ;
3333import { listSessionsFromStore , listSessionsFromStoreAsync } from "./session-utils-list.js" ;
34- import { getSessionDefaults , resolveGatewayModelSupportsImages } from "./session-utils-model.js" ;
34+ import {
35+ getSessionDefaults ,
36+ projectSessionPatchResult ,
37+ resolveGatewayModelSupportsImages ,
38+ } from "./session-utils-model.js" ;
3539import {
3640 buildSessionListRowContext ,
3741 buildSingleRowStoreChildSessionsByKey ,
@@ -1198,6 +1202,55 @@ describe("gateway session utils", () => {
11981202 expect ( staleRuntime . thinkingLevel ) . toBe ( "max" ) ;
11991203 } ) ;
12001204
1205+ test ( "strips nested thinking provenance from Gateway patch results" , async ( ) => {
1206+ const entry : InternalSessionEntry = {
1207+ sessionId : "private-fallback" ,
1208+ updatedAt : 1 ,
1209+ modelFallback : {
1210+ prevModel : "gpt-5.6-sol" ,
1211+ prevProvider : "openai" ,
1212+ prevThinkingLevelSelection : {
1213+ provider : "openai" ,
1214+ model : "gpt-5.6-sol" ,
1215+ agentRuntime : "codex" ,
1216+ level : "ultra" ,
1217+ } ,
1218+ source : "agent-patch" ,
1219+ ts : 1 ,
1220+ } ,
1221+ } ;
1222+ const result = await projectSessionPatchResult ( {
1223+ canonicalKey : "agent:main:main" ,
1224+ cfg : {
1225+ agents : { defaults : { model : { primary : "openai/gpt-5.6-sol" } } } ,
1226+ } as OpenClawConfig ,
1227+ entry,
1228+ modelCatalogByAgent : new Map ( [
1229+ [
1230+ "main" ,
1231+ Promise . resolve ( [
1232+ {
1233+ provider : "openai" ,
1234+ id : "gpt-5.6-sol" ,
1235+ name : "GPT 5.6 Sol" ,
1236+ reasoning : true ,
1237+ } ,
1238+ ] ) ,
1239+ ] ,
1240+ ] ) ,
1241+ storePath : "/tmp/openclaw-sessions.json" ,
1242+ targetAgentId : "main" ,
1243+ } ) ;
1244+
1245+ expect ( result . entry . modelFallback ) . toEqual ( {
1246+ prevModel : "gpt-5.6-sol" ,
1247+ prevProvider : "openai" ,
1248+ source : "agent-patch" ,
1249+ ts : 1 ,
1250+ } ) ;
1251+ expect ( JSON . stringify ( result . entry ) ) . not . toContain ( "prevThinkingLevelSelection" ) ;
1252+ } ) ;
1253+
12011254 test ( "reports observed locked runtime from agentHarnessId instead of configured intent" , ( ) => {
12021255 const cfg = {
12031256 agents : {
0 commit comments