@@ -6,9 +6,6 @@ import type { CompressionBlock } from "../lib/state"
66import { syncCompressionBlocks } from "../lib/messages/sync"
77import { prune } from "../lib/messages/prune"
88import type { PluginConfig } from "../lib/config"
9- import { saveSessionState , loadSessionState } from "../lib/state/persistence"
10- import { existsSync , rmSync , readFileSync } from "node:fs"
11- import { join } from "node:path"
129
1310function msg ( id : string , role : "user" | "assistant" = "user" ) : WithParts {
1411 return {
@@ -171,38 +168,3 @@ test("prune injects compressed summary into LLM context after sync keeps block a
171168 assert . ok ( messages . some ( ( m ) => m . info . id === anchorMsgId ) )
172169} )
173170
174- test ( "modelContextLimit is persisted and restored across restarts" , async ( ) => {
175- // 回归:重启后第一轮 chat.message hook 先于 system.prompt hook 运行,
176- // modelContextLimit 若未持久化则阈值无法按百分比解析。
177- const sid = "ses-persist-roundtrip"
178- const filePath = join (
179- process . env . XDG_DATA_HOME || join ( process . env . USERPROFILE || "" , ".local" , "share" ) ,
180- "opencode" ,
181- "storage" ,
182- "plugin" ,
183- "dcp" ,
184- `${ sid } .json` ,
185- )
186- try {
187- const logger = new Logger ( false )
188-
189- const state = createSessionState ( )
190- state . sessionId = sid
191- state . modelContextLimit = 1000000 // 1M,如 deepseek-v4-flash / kimi k3
192- await saveSessionState ( state , logger )
193-
194- // 模拟重启:从磁盘加载(modelContextLimit 必须恢复)
195- const loaded = await loadSessionState ( sid , logger )
196- assert . ok ( loaded !== null )
197- assert . equal ( loaded . modelContextLimit , 1000000 )
198-
199- // 持久化文件里确实包含该字段(而非仅内存)
200- assert . equal ( existsSync ( filePath ) , true )
201- const raw = JSON . parse ( readFileSync ( filePath , "utf-8" ) )
202- assert . equal ( raw . modelContextLimit , 1000000 )
203- } finally {
204- if ( existsSync ( filePath ) ) {
205- rmSync ( filePath , { force : true } )
206- }
207- }
208- } )
0 commit comments