#5991 [Other] the shipped Harness 0.2.1-alpha.3 has no model-switch pressure check, added upstream in dsh-v0.2.1-alpha.4
closed · @xvcezrqpbxtpzblrt · 3 comentarios · En GitHub
BenchmarksSetup & installServer & APIAMD / HIPNVIDIA / CUDAModels & quantsDocumentationWindows
Descripción
### Area
[Other] — the agent runtime the desktop app ships with. The compaction policy itself lives in the bundled DeepSeek Harness; the pin is recorded in this repository.
### Desktop app, Terminal or source?
Desktop app (Windows), release 0.2.13.
### What happened
I compared the Harness the installer ships with the upstream Harness repository. The shipped copy is older than the upstream release that added the model-switch context check, so a mid-chat model switch is not measured against the destination window before the first request on it.
The app lets a person pick a cloud API model inside the same chat: `apps/host/src/components/ChatModelPicker.tsx:23` lists the loaded local instances and every configured API connection's models in one menu, and `apps/host/src/lib/types.ts:476` keeps `remoteModel` as a per-chat preference ("This chat's API model; absent or null means the local model"). The host then changes the model on one Harness session — `apps/host/server/agent/agent-bridge.mjs:421-423` calls `session/selectModel` with the same `sessionId` when the route changed:
```js
const wanted = `${provider}/${route.modelId}/${level ?? ''}`;
if (c.route !== wanted || c.routeGeneration !== runtime.generation) {
const select = effort => runtime.gw.rpc('session/selectModel', { request: { sessionId, provider, model: route.modelId, … } });
```
In the Harness version the app ships, nothing measures the existing history against the route being switched **to**. The shipped `dsh-compaction-basic` registers exactly these listeners:
```
839: ctx.on("agent/pre-step", async ({ agent, signal }, next) => {
853: ctx.on("agent/status", ({ agent, status }) => {
856: ctx.on("session/event", (session, event) => {
861: ctx.on("agent/request-error", async ({ agent, failure, signal }, next) => {
```
and its `compactIfNeeded` takes the route from the session log (`:914 const target = routedTarget(agent.session);`), i.e. the route already committed. Occurrences in that same file: `agent/request"` — 0, `MODEL_SWITCH` — 0. Over the whole shipped Harness (`harness\node_modules\@deepseek-ai\`, 299 packages) the string `MODEL_SWITCH_COMPACTION_FAILED` returns 0 matches; the only hits on the wider pressure-pattern search were `pressureBudgetTokens`, which the shipped build uses for the ordinary threshold, not for a switch.
Upstream added precisely that missing piece. In Harness `master` (`39163dd30f703a79079e2d2446545cff3c453738`, `package.json` version `0.2.2-rc.3`) `packages/compaction/compaction-basic/src/index.ts` carries `ctx.on('agent/request', …)` at :198 and `'MODEL_SWITCH_COMPACTION_FAILED'` at :213, and the release-level upgrade guide (`docs/upgrade-guide/v0.2.1-alpha.4/model-switch-compaction/guide.md`) states:
> With `compaction-basic` automatic mode enabled, a provider/model switch now checks destination pressure before recording the new request header. **Previously, proactive pressure checks used the last committed route** and warned on configuration or summary failure. A switch now fails with `MODEL_SWITCH_COMPACTION_FAILED` when destination capacity cannot be resolved, its pressure budget is invalid, or compaction cannot reduce history below its threshold.
Upstream publishes that as tags: `dsh-v0.2.1-alpha.3`, `dsh-v0.2.1-alpha.4`, … `dsh-v0.2.2-rc.3` (Tags API, read 2026-11-15). The app pins the release just before the fix:
- `apps/host/server/agent/README.md:6` — "The Harness is a separate, pinned component (`DSH 0.2.1-alpha.3`, commit `57190202`, MIT)."
- `apps/host/tests/agent-host.test.mjs:91` — `assert.equal(status.harness.version, '0.2.1-alpha.3');`
- `strata_cli/launch/harness.py:254` — `tested="DSH 0.2.1-alpha.3"`
- shipped `%LOCALAPPDATA%\Programs\Strata\harness\BUNDLE.json` — `"component":"deepseek-harness","version":"0.2.1-alpha.3","builtAt":"2026-10-16T17:45:39.441Z"`
The app does register a per-model pressure policy for API routes — `apps/host/server/agent/profile.mjs:286` pushes `modelPolicies` with `headroomTokens` for every connection model, and `profile.mjs:30,277` default an API model with no declared size to `ASSUMED_API_CONTEXT = 128_000` — so the destination numbers exist; the shipped Harness simply does not read them at switch time. The host's own pre-send fit check does not cover it either, because it is gated on the local route: `agent-bridge.mjs:441` — `if (!goal && route.kind === 'local') {`.
Expected: a route switch is measured against the destination capacity before the first request on the new route, or refused with a named error — the behaviour upstream documents from `dsh-v0.2.1-alpha.4` on.
Actual (as far as the build tells me): the destination is first met by the request itself, and repair starts afterwards from `agent/request-error`, where `maxOverflowRetries` defaults to `1`.
### Smallest steps or command that reproduce it
What I actually ran (PowerShell, 2026-11-15, against the installed 0.2.13):
```powershell
Get-Content "$env:LOCALAPPDATA\Programs\Strata\harness\BUNDLE.json" -Raw
Select-String -Path "$env:LOCALAPPDATA\Programs\Strata\harness\node_modules\@deepseek-ai\dsh-compaction-basic\lib\index.js" -Pattern 'ctx\.on\("'
(Select-String -Path "…\dsh-compaction-basic\lib\index.js" -Pattern 'MODEL_SWITCH' -AllMatches).Count # 0
(Select-String -Path "…\dsh-compaction-basic\lib\index.js" -Pattern 'agent/request"' -AllMatches).Count # 0
```
The user-visible failure would need: a long agent chat on a local model with a wide context, then picking a cloud API model with a smaller window in the same chat, then sending one more message. I did not drive the UI that far, so those steps are stated as a hypothesis, not as something I saw.
### Reproduction status
Unconfirmed static analysis (I read the shipped build and compared it with upstream; I did not see the switch fail). The build facts above — the four registered listeners, the two zero counts, the version string — are things I ran and saw.
### Strata version
Strata 0.2.13 · engine 0.1.59 · bundled Harness `deepseek-harness 0.2.1-alpha.3` (`BUNDLE.json` builtAt 2026-10-16T17:45:39Z). Revisions I read: `Niko1221/Strata` main `13eedf552417a6a791a7d13c6597e24300ee3a09`, `deepseek-ai/deepseek-harness` master `39163dd30f703a79079e2d2446545cff3c453738`. Latest release on GitHub is still `v0.2.13` (published 2026-11-09), so this is current.
### Graphics card, memory and system
RTX 3080 Ti Laptop 16 GB (16384 MiB) · 64 GB RAM · Windows 11 Pro 10.0.26300 · i7-12800HX · driver 621.14 — read on this machine 2026-11-15 with `nvidia-smi --query-gpu=name,memory.total,driver_version` and `Get-CimInstance Win32_ComputerSystem` / `Win32_OperatingSystem`.
### Model, size and settings
Qwen3.8-Flash-Next, IQ3_S pack · context 384K (engine `--max-context 393216`) · KV `k8v4` · YaRN 1.5 · MTP drafting · pictures on (CPU vision) · agent mode on · thinking budget 2K. Relevant to this report: the local route's 393216 window against `ASSUMED_API_CONTEXT = 128_000` for a connection model with no declared size, and the per-route `headroomTokens` from `profile.mjs:151-153`.
### Logs
No failure occurred, so there is no failure log. One line from the app's own engine log showing why an extra refused round trip is expensive on this setup, quoted as written there (no keys in it):
```
strata serve: prompt 201825 tokens = 6531 reused + 195294 read in 176512 ms (1106.4 tok/s), 724 generated in 19417 ms (37.3 tok/s)
```
### What I suggest
Move the pin to a Harness at or after `dsh-v0.2.1-alpha.4` (the newest upstream tag today is `dsh-v0.2.2-rc.3`), and name the compaction changes that ride along in the changelog, because `MODEL_SWITCH_COMPACTION_FAILED` is a new refusal a person can meet where today they do not. Before the bump, step 1 of that guide is worth checking against this app: every selectable route needs an adapter whose `resolveModelInfo()` declares `context.contextWindow`, while `profile.mjs:277` currently falls back to an assumed 128,000 for a connection model without a declared size — that is the case #5011 already describes.
### Validation
**Passed** (this machine, 2026-11-15): the four commands under "Smallest steps" — shipped version string, the four `ctx.on` registrations, and 0 occurrences of both `MODEL_SWITCH` and `agent/request"`; a content search for `MODEL_SWITCH_COMPACTION_FAILED` across `harness\node_modules\@deepseek-ai\` (299 packages) → 0 matches; the same string present in the upstream clone at `packages/compaction/compaction-basic/src/index.ts:213` and declared as a failure code at `packages/llm/llm/src/error.ts:49`. Hardware readout above. Also passed: `estimateContent` from the shipped `@deepseek-ai/dsh-token-meter` prices 46 Chinese characters as 16 tokens, with `const CHARS_PER_TOKEN = 4;` at `dsh-token-meter/lib/index.js:16`.
**Failed:** nothing failed; every command above returned what is quoted.
**Not run:** the model switch in the app UI; the true token count of Chinese text under this model's own tokenizer (the 16-token figure is what the shipped estimator returns, not what the engine counts); whether switching from an API model back to a local model takes the same route-change path (`ChatModelPicker.tsx:43-52` shows that direction also reloads a model version).
### Limits
This is a version-pin report, not a fix, and the failure itself is inferred from the two builds rather than observed. I did not measure how often a person switches route inside one long chat, and I did not test whether the after-the-fact recovery (`agent/request-error`, `maxOverflowRetries: 1`) is enough in practice. I searched open and closed issues first: `in:title compaction` returns 19 items (#4744, #5011, #3694, #3753, #3850, #3852, #4838, #5006 among them) and none covers the Harness pin; a whole-repository search for `MODEL_SWITCH_COMPACTION_FAILED` returns 0. If the pin is already tracked in another thread, close this as a duplicate.
En el sitio
Enlaces a install, modelos, releases.