billion-context-dsh 0.2.10 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [English](./README.en.md) | [中文](./README.md)
4
4
 
5
5
  > **⚠️ Beta notice — not for production use**
6
- > This project (**v0.2.10**) is a work-in-progress beta. The [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) itself is also in **public beta**. **Do not use either in engineering / production environments** — expect breaking changes and rough edges.
6
+ > This project (**v0.2.11**) is a work-in-progress beta. The [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) itself is also in **public beta**. **Do not use either in engineering / production environments** — expect breaking changes and rough edges.
7
7
 
8
8
  <p align="center">
9
9
  <strong>Built with gratitude on top of these projects</strong> — please give them a ⭐:
@@ -171,7 +171,7 @@ This project reuses `acp-kernel`'s compression core and `billion-context-pi`'s d
171
171
  | Key | Default | Meaning |
172
172
  |---|---|---|
173
173
  | `modelContextLimit` | auto-detected (fallback `128000`) | Context window used for the kernel's pressure decisions; an explicit value wins and skips the probe |
174
- | `autoModelContextLimit` | `true` | Probe the model's real window from the model API (`agent.ctx.llm.resolveModelInfo`); fall back to the default on failure, the `/acp` command shows the window source (the `acp_status` model tool carries no window info) |
174
+ | `autoModelContextLimit` | `true` | Probe the model's real window from the model API (`agent.ctx.llm.resolveModelInfo`); fall back to the default on failure, the `/acp` command shows the window source (the `acp_status` model tool carries no window info). A failed probe is surfaced in the host log and the `/acp` panel (`restart to re-probe`) — the failure is cached like a success, so fixing the gateway requires a restart or an explicit `modelContextLimit` before the probe retries |
175
175
  | `nudgeMinContextLimitPct` | kernel default `0.45` | Nudge window lower bound (usage fraction) — validation only; the growth-driven trigger has no percentage floor — same default as billion-context-pi |
176
176
  | `nudgeMaxContextLimitPct` | engine default `0.70` (kernel/pi default `0.75`) | Over-limit line: above this the nudge fires regardless of growth — deliberately below the host compaction-basic 80% auto-compaction line so the forced nudge fires first; an explicit value wins |
177
177
  | `nudgeEmergencyThresholdPct` | engine default `0.85` (kernel/pi default `0.95`) | Emergency nudge (bypasses the per-turn dedup) — lowered from `0.95`: at 95% the model has no room to act and the 80% auto-compaction line shadows it; an explicit value wins |
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [中文](./README.md) | [English](./README.en.md)
4
4
 
5
5
  > **⚠️ 测试版声明——请勿用于生产环境**
6
- > 本项目(**v0.2.10**)仍处于开发中的测试版。[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 本身也处于**公开测试版**阶段。**请勿将两者用于工程化 / 生产环境**——预期会有破坏性变更与粗糙之处。
6
+ > 本项目(**v0.2.11**)仍处于开发中的测试版。[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 本身也处于**公开测试版**阶段。**请勿将两者用于工程化 / 生产环境**——预期会有破坏性变更与粗糙之处。
7
7
 
8
8
  <p align="center">
9
9
  <strong>衷心感谢以下项目——请给它们一个 ⭐:</strong>
@@ -172,7 +172,7 @@ DSH 的每个模型请求都派生自其 append-only 会话日志(*surface*)
172
172
  | 键 | 默认值 | 含义 |
173
173
  |---|---|---|
174
174
  | `modelContextLimit` | 自动探测(回退 `128000`) | 用于内核压力决策的上下文窗口;显式配置时优先且跳过探测 |
175
- | `autoModelContextLimit` | `true` | 从模型 API 自动探测真实窗口(`agent.ctx.llm.resolveModelInfo`);探测失败回退默认值,`/acp` 命令展示窗口来源(模型工具 `acp_status` 不含窗口信息) |
175
+ | `autoModelContextLimit` | `true` | 从模型 API 自动探测真实窗口(`agent.ctx.llm.resolveModelInfo`);探测失败回退默认值,`/acp` 命令展示窗口来源(模型工具 `acp_status` 不含窗口信息)。探测失败会在宿主日志与 `/acp` 面板提示(`restart to re-probe`)——失败结果同样被缓存,修复网关后需重启或显式设置 `modelContextLimit` 才会重新探测 |
176
176
  | `nudgeMinContextLimitPct` | 内核默认 `0.45` | Nudge 窗口下界(用量占比)——仅作配置校验,增长路径的触发没有百分比下限——与 billion-context-pi 相同的默认值 |
177
177
  | `nudgeMaxContextLimitPct` | engine 默认 `0.70`(内核/pi 默认 `0.75`) | 过限线:超过此值则无论增长与否都触发 nudge——刻意低于宿主 compaction-basic 的 80% 自动压缩线,保证强制 nudge 先触发;显式配置优先 |
178
178
  | `nudgeEmergencyThresholdPct` | engine 默认 `0.85`(内核/pi 默认 `0.95`) | 紧急 nudge(绕过每轮去重)——从 `0.95` 下调:95% 时模型已无操作空间且会被 80% 自动压缩线遮蔽;显式配置优先 |
@@ -4,6 +4,6 @@
4
4
  * @module billion-context-dsh/commands
5
5
  */
6
6
  import type { CommandDefinition } from '@deepseek-ai/dsh-commands';
7
- import type { ToolEnvironment } from './tools.ts';
7
+ import { type ToolEnvironment } from './tools.ts';
8
8
  /** Register the /acp command (idempotent per engine). */
9
9
  export declare function acpCommand(env: ToolEnvironment): CommandDefinition;
package/dist/index.js CHANGED
@@ -3836,6 +3836,9 @@ function requireAgent(exec) {
3836
3836
  }
3837
3837
  return exec.agent;
3838
3838
  }
3839
+ async function resolveEffectiveWindow(env, agent) {
3840
+ return env.windowFor === void 0 ? { limit: env.modelContextLimit, source: "explicit" } : await env.windowFor(agent);
3841
+ }
3839
3842
  var compressParameters = {
3840
3843
  // Tolerated wrapped-arguments form: some models emit
3841
3844
  // `{ "arguments": "{\"content\": [...]}" }` (double-nested) or
@@ -3947,7 +3950,8 @@ async function handleCompress(env, args, exec) {
3947
3950
  const coreMessages = allLogMessages(session);
3948
3951
  const surfaceMessages = eventsToCoreMessages(surfaceEventsOf(session));
3949
3952
  const tokenCount = resolveTokenCount(agent, surfaceMessages);
3950
- const config = kernelConfigFor(env);
3953
+ const window = await resolveEffectiveWindow(env, agent);
3954
+ const config = kernelConfigFor({ ...env, modelContextLimit: window.limit });
3951
3955
  const turn = env.kernel.processTurn({ messages: coreMessages, state, config, tokenCount });
3952
3956
  env.store.set(session, turn.state);
3953
3957
  const byRaw = turn.state.messageRefs.byRaw;
@@ -4231,7 +4235,8 @@ async function handleStatus(env, rawArgs, exec) {
4231
4235
  const coreMessages = allLogMessages(session);
4232
4236
  const surfaceMessages = eventsToCoreMessages(surface, toolNames);
4233
4237
  const tokenCount = resolveTokenCount(agent, surfaceMessages);
4234
- const config = kernelConfigFor(env);
4238
+ const window = await resolveEffectiveWindow(env, agent);
4239
+ const config = kernelConfigFor({ ...env, modelContextLimit: window.limit });
4235
4240
  const turn = env.kernel.processTurn({ messages: coreMessages, state, config, tokenCount });
4236
4241
  const statusMessages = eventsToCoreMessages(
4237
4242
  surface.filter((event) => !isCheckpointEvent(event)),
@@ -4304,6 +4309,7 @@ function windowSourceLabel(window) {
4304
4309
  if (window.source === "auto") {
4305
4310
  return `auto-detected from ${window.provider ?? "?"}/${window.model ?? "?"}`;
4306
4311
  }
4312
+ if (window.probeFailed === true) return "default (auto-detection failed \u2014 restart to re-probe)";
4307
4313
  return "default (auto-detection unavailable)";
4308
4314
  }
4309
4315
  async function detectContextWindow(agent, provider, model) {
@@ -4327,7 +4333,7 @@ async function statusText(env, agent) {
4327
4333
  const coreMessages = allLogMessages(session);
4328
4334
  const surfaceMessages = eventsToCoreMessages(surfaceEventsOf(session));
4329
4335
  const estimated = resolveTokenCount(agent, surfaceMessages);
4330
- const window = env.windowFor === void 0 ? { limit: env.modelContextLimit, source: "explicit" } : await env.windowFor(agent);
4336
+ const window = await resolveEffectiveWindow(env, agent);
4331
4337
  const limit = window.limit;
4332
4338
  const lines = [
4333
4339
  `ACP status \u2014 session ${session.id}`,
@@ -4336,6 +4342,9 @@ async function statusText(env, agent) {
4336
4342
  ` estimated context: ${estimated} / ${limit} (${Math.round(estimated / limit * 100)}%)`,
4337
4343
  ` context window: ${limit} (${windowSourceLabel(window)})`
4338
4344
  ];
4345
+ if (window.probeFailed === true) {
4346
+ lines.push(` \u26A0 window auto-detection failed \u2014 using the ${limit} fallback (restart to re-probe, or set modelContextLimit explicitly)`);
4347
+ }
4339
4348
  const state = structuredClone(env.store.stateFor(session));
4340
4349
  const config = kernelConfigFor({ ...env, modelContextLimit: limit });
4341
4350
  const turn = env.kernel.processTurn({ messages: coreMessages, state, config, tokenCount: estimated });
@@ -4569,7 +4578,14 @@ var AcpCompactionEngine = class extends CompactionEngine {
4569
4578
  window = { limit: DEFAULT_CONTEXT_WINDOW, source: "default", provider, model };
4570
4579
  } else {
4571
4580
  const detected = await detectContextWindow(agent, provider, model);
4572
- window = detected === null ? { limit: DEFAULT_CONTEXT_WINDOW, source: "default", provider, model } : { limit: detected, source: "auto", provider, model };
4581
+ if (detected === null) {
4582
+ this.ctx.logger.warn(
4583
+ `billion-context-dsh: context-window auto-detection failed for ${provider}/${model} \u2014 using the ${DEFAULT_CONTEXT_WINDOW} fallback (restart to re-probe, or set modelContextLimit explicitly)`
4584
+ );
4585
+ window = { limit: DEFAULT_CONTEXT_WINDOW, source: "default", provider, model, probeFailed: true };
4586
+ } else {
4587
+ window = { limit: detected, source: "auto", provider, model };
4588
+ }
4573
4589
  }
4574
4590
  this.windowCache.set(key, window);
4575
4591
  return window;