feat(llm): 支持增量上下文,为模型加 store: true 即走 relay

- 新增 instance.js:data_root/instance-id,首次启动生成 12 位 hex,跨 core 唯一
- engine 传 context_id = <core_id>:<user>:<session_id>,三层定位不撞车
- callModel 对 store: true 的模型只发新增消息 + X-Context-Id/Hash,
  409 时改发全量重试一次;指针存内存,重启自动回落全量
- config.js 把 store 字段透传到模型对象(以前会被丢掉)
- 未配 store 的模型行为完全不变
This commit is contained in:
2026-11-17 20:29:16 +08:00
parent 05d03f0836
commit bba42ae2ca
5 changed files with 87 additions and 2 deletions
+4
View File
@@ -236,6 +236,9 @@ function normalizePlatforms(rawPlatforms, profileNames) {
// 非空时发请求前给历史 assistant 行挂该字段;空(缺省)= 不回传。纯发送侧旋钮,
// 与接收解析无关(接收早已兼容 reasoning/reasoning_content 双名)。
reasoning_ack_field: typeof m.reasoning_ack_field === 'string' ? m.reasoning_ack_field.trim() : '',
// 选填:该模型的请求走增量上下文(context relay),只有配合 relay 生效。
// 不配 = 每轮重传全量,和以前完全一样。
store: m.store === true,
// 选填:自动压缩阈值(用户自定义的「上下文用量线」,**不是**模型真实窗口)。
// 回合内 In token 峰值达到它即自动压缩上下文(见 engine.runLoopInner 循环顶部);0/未配 = 不启用。
max_context: Math.max(0, parseInt(m.max_context, 10) || 0),
@@ -363,6 +366,7 @@ function parseAndValidate(rawText, configPath) {
extra_params: m.extra_params, thinking_params: m.thinking_params,
reasoning_ack_field: m.reasoning_ack_field,
max_context: m.max_context,
store: m.store,
profile: m.profile,
url: p.url, api_key: k.api_key, platform: p.name, type: p.type, concurrency: k.concurrency,
platform_index: pi, key_index: ki, model_index: mi,