Skip to content

Studio: remembered model settings can be erased by the run-settings hydration write-back (stale snapshot, lost update) #9604

Closed

Description

@danielhanchen

Found while investigating the Chat UI Tests (picker) flake (#9603). It is a separate, real defect and is not what makes that job red, so it is filed on its own.

Summary

The run-settings hydration write-back is a read-modify-write spanning an awaited request. model-config-page.tsx snapshots the stored config at panel mount:

const storedAtStart = resolveInitialConfig(configId, target.ggufVariant).config;

then, after fetchLoadModelOverride(...) resolves, writes:

const rememberedConfig = fromApiOverride(resolvedRow, storedAtStart);
savePerModelConfig(configId, target.ggufVariant, rememberedConfig, hydrationEvicted);

localStorage is shared across tabs, so anything written between the snapshot and the write is overwritten by a value read before it existed. fromApiOverride falls back to storedAtStart for every field the server row does not carry, so those fields revert.

This write-back is new; before it, opening the panel never wrote storage.

Reproduction

Two tabs, real gestures only. The one intervention is latency on a single request, which a slow link supplies for free.

  1. Tab A: open the model picker, click the gear for a model. Hold its GET /api/settings/openai-auto-switch/overrides.
  2. Tab B: open the same model's run settings, type Context Length 4096, tick "Remember for this model", press "Reload model". Storage now has customContextLength: 4096.
  3. Release tab A's response.

Observed, with the mirror PUT to /api/settings/openai-auto-switch/overrides failing (server down, offline, 5xx):

tab B: stored after the save    ... "customContextLength":4096 ... "gpuLayers":-1,"nCpuMoe":0
tab A: stored after hydration   ... "customContextLength":null  ... (gpuLayers/nCpuMoe gone)
VERDICT: PRODUCTION_LOSS

The user's remembered context is erased with no action on their part and nothing shown.

Conditions, stated precisely

Reproduced 3/3 with the mirror PUT blocked. Not reproduced with a healthy mirror: the save reaches the server, so tab A's row re-derives it, and gpuLayers / nCpuMoe survived too. So all three are needed:

  • two surfaces on the same origin (two tabs, or a tab plus a LAN client),
  • a hydration slower than the other surface's save,
  • the server mirror failing or unreachable.

A failing mirror PUT is a condition model-overrides.ts already documents ("a PUT that never landed ... leaves the same gap"), and neither latency nor a down server is a fault, so this is reachable in ordinary use rather than only under a harness.

Not reproducible with a single tab: an open panel left idle for 20 s never rewrites the key. The window is armed by the hydration GET at mount, and closing the picker does not cancel the pending .then() - a held response still lands after the panel is closed.

Suggested direction

Re-read the stored record inside the callback instead of trusting the mount-time snapshot, so the merge is against current storage. That keeps the intent the snapshot was introduced for (write against stored settings, not the running model's config) while removing the stale-read window. Worth considering alongside it: skip the write entirely when the merge is byte-identical to what is already stored, which removes most of the exposure without changing any semantics.

Scope note

The legacy unsloth_load_settings migration is not affected. migrateLegacyLoadSettingsOnce runs inside the first readMap() and returns before yielding, so no awaited response can split its read from its write, and a genuine upgrade shape (legacy blob, no versioned map, no flag) with the write-back armed preserves the remembered context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions