Skip to content

Commit 4e0a9cd

Browse files
committed
fix: persist modelContextLimit immediately after caching
The chat.message save always ran before the system.prompt hook cached modelContextLimit, so the value never reached disk and restarts could not restore it. Save right after caching in the system.prompt hook.
1 parent 58cd6ed commit 4e0a9cd

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

lib/hooks.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ export function createSystemPromptHandler(
6868
if (input.model?.limit?.context) {
6969
state.modelContextLimit = input.model.limit.context
7070
logger.debug("Cached model context limit", { limit: state.modelContextLimit })
71+
// 立即持久化:opencode 的 chat.message 保存总在 system.prompt 缓存
72+
// 之前运行,若不在此保存,modelContextLimit 永远无法写入磁盘,
73+
// 重启后第一轮阈值无法按百分比解析。
74+
if (state.sessionId) {
75+
void saveSessionState(state, logger)
76+
}
7177
}
7278

7379
if (state.isSubAgent && !config.experimental.allowSubAgents) {

0 commit comments

Comments
 (0)