Skip to content

studio: add a sampling seed to the chat run settings - #9144

Merged
Lyxot merged 13 commits into
unslothai:mainfrom
mahiatlinux:feat/studio-sampling-seed
Aug 26, 2026
Merged

Lyxot merged 13 commits into
unslothai:mainfrom
mahiatlinux:feat/studio-sampling-seed

Conversation

@mahiatlinux

@mahiatlinux mahiatlinux commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Studio has no way to pin a sampling seed, so a generation cannot be reproduced. The backend already accepted one: ChatCompletionRequest.seed in studio/backend/models/inference.py reaches llama-server through routes/inference.py and core/inference/llama_cpp.py. The gap was the frontend's parameter set, so this adds the field and the control rather than any new server plumbing.

Fixes #9090.

The issue's own evidence points at the seed key in inference_defaults.json, which is families.seed, a model-family sampling block rather than a seed parameter. ChatCompletionRequest.seed is the field that actually carries the pin.

What changed

InferenceParams in studio/frontend/src/features/chat/types/runtime.ts gains seed?: number | null, defaulting to null. A blank field is unset, so nothing changes for anyone who does not touch it.

The run settings panel renders a Seed box in the Sampling section, below Max Tokens. It is a text input rather than type="number": the HTML value sanitization algorithm reports an entry the engine cannot parse as the empty string, which would silently clear the pin. chat-providers-dialog.tsx documents the same trap for the provider Max Tokens field. The box keeps the raw keystrokes in seedDraft and clamps on blur, so an entry past the maximum is not rewritten while it is still being typed. committedSeed is that clamp as a value rather than a side effect, so a click on Save, which blurs the box during mousedown but runs its onClick before React re-renders, saves the seed that was typed instead of the one before it. NumericValueInput cannot be reused here (value: number, no unset state) but its blur commit exists for that reason.

chat-adapter.ts sends seed on the local chat body only when it is set and when the loaded model's backend reads one. modelReadsSamplingSeed in types/runtime.ts answers that for both the panel and the request body, from the same models[] summary the body already reads isGguf from for context_overflow, so the two cannot drift and a pin left over from a GGUF is not sent invisibly.

llama-server reads the seed, and so does MLX since #9262: generate_chat_response takes it and builds _make_seeded_mlx_sampler, and worker.py's _backend_declares gate lets it through. The transformers backend declares no seed kwarg, so it is the one that drops it, and the one the control stays hidden for. An audio-output model is excluded too, since it answers through generateAudio, whose request carries no seed.

The flag has to reach the summary for that to work. A locally scanned model is in no /api/models/list row, so its models[] entry is minted from the load or status response, and both hops that mint one, syncModelCapabilities and ensureActiveModelInStoreList, now carry is_mlx the way they already carry has_video_input.

The pin covers 0 to 4294967294. llama.cpp reads the seed as a uint32_t and spends 0xFFFFFFFF on LLAMA_DEFAULT_SEED, its draw-one sentinel, so that value is the one a pin cannot name.

The hint says a matching reply also needs Parallel Slots at 1 and Speculative Decoding off. #9090's table shows seed plus temperature 0 plus top_k 1 still producing 3,960 against 150 characters without them.

Persistence

seed joins PERSISTED_INFERENCE_PARAM_KEYS, so it survives a reload and is remembered per model. Three places needed it:

  • utils/chat-settings-storage.ts gates both the hydration read and the outgoing PUT, so sanitizeInferenceParams now range-checks the seed and lets an explicit null through. Without the null the server merge, which only overwrites the keys it receives, would leave an old pin in place after the user cleared it.
  • ChatInferenceSettings in studio/backend/routes/chat_history.py is extra="forbid", so an unknown key would 400 the whole settings save. It bounds the seed and rejects booleans, matching the _no_booleans guard ChatPresetLoadConfig already applies to nBatch and nUbatch for the same reason: bool subclasses int, so lax mode would store true as a pin of 1.
  • presets/preset-policy.ts adds seed to PresetOwnedParams. The control sits with Temperature through Max Tokens, all preset-owned, so saving a preset captures the pin and applying one restores it.
  • utils/thread-scoped-settings.ts and ChatThreadSettings add it to the per-chat snapshot, so a pin belongs to the conversation it was taken in. Every other per-turn sampling control already travels that way; maxTokens is the one left out, and the reason thread-scoped-settings.test.ts gives is that the context belongs to the model that loaded, which does not cover a seed. It is also the first thread-scoped value whose cleared state is null rather than absent, so the three snapshot fallbacks in chat-runtime-store.ts go through firstSetThreadScopedValue instead of ??: coalescing would read a cleared seed as a missing key and hand back the installation pin.

Checks

Run on the rebase.

  • npm run typecheck clean
  • npm test 5161 passed, 0 failed, including 24 in tests/chat-sampling-seed.test.ts
  • pytest tests/test_chat_settings_payload.py tests/test_chat_history_routes.py tests/test_chat_thread_settings.py tests/test_chat_history_storage.py 195 passed, 0 failed
  • ruff check clean on both backend files

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f07971711

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18384a941e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +526 to +528
const showSeed =
!isExternalModel &&
modelReadsSamplingSeed(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Hide or forward the seed during deep research

When Deep Research is enabled for a local GGUF model, this predicate still exposes the Seed control, but the adapter exits through the earlier buildResearchInferenceRequest path, whose input and resulting ResearchInferenceRequest contain temperature, top-p, and max tokens but no seed. Consequently every research run silently ignores the pinned value despite the control promising reproducible sampling; either propagate the seed through the research request/backend or exclude Deep Research from showSeed.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not taking this one. ResearchInferenceRequest carries temperature, topP and maxTokens only, so topK, minP, repetitionPenalty and presencePenalty are dropped on the research path exactly as the seed is, and the panel shows all four during deep research today. Singling out the seed would be inconsistent with its neighbours and would not be a fix. Deep Research is also a per-turn mode rather than a model class: buildResearchInferenceRequest runs only while the branch guard at chat-adapter.ts holds, and a thread that already researched falls through to the ordinary seeded body, so hiding the control whenever the toggle is on would remove a knob that still works for those turns. Carrying sampling settings through the research run is worth doing for the whole set in its own change, not for one field here.

@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 18384a941e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed the gap is real, InferenceParams had no seed while ChatCompletionRequest.seed already reaches llama-server, and gating the control on modelReadsSamplingSeed is the right call. Could you rebase off the conflict and get Backend CI on Python 3.13 and the Mac GGUF smoke green so this can be reviewed?

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against current main. The gap is real and the persistence handling is the good part, but main moved under the branch. Also diagnosed the red CI, since it turns out not to be yours.

Verified

  • ChatCompletionRequest.seed reaches llama-server on both the tools and no-tools GGUF paths; InferenceParams has no seed. Gap confirmed.
  • The backend edit is required, not incidental: ChatInferenceSettings is extra = "forbid".
  • The seed === null branch is load-bearing — the sanitizer runs on the outgoing patch too (savePersistedChatSettingsPatch), and _deep_merge_settings overwrites per key without ever deleting, so an omitted key would leave the old pin in place. That is the subtle part of this change and it is right at every layer.
  • LLAMA_DEFAULT_SEED is 0xFFFFFFFF and the server parses seed as a uint32_t with clamping, so the reasoning behind the ceiling holds for that backend.

A note on the issue rather than the PR: the seed key in inference_defaults.json is families.seed, a model-family sampling block, not a seed parameter. Your description cites ChatCompletionRequest.seed instead, which is the correct evidence — flagging only so the issue's premise does not get quoted onward.

Blocking

1. modelReadsSamplingSeed is out of date since #9262. The MLX backend now declares and uses seed: generate_chat_response takes it and builds _make_seeded_mlx_sampler from it, the chat route forwards payload.seed on the non-GGUF path, and worker.py's _backend_declares gate passes it through. The transformers backend is the one that still drops it, deliberately.

As written the predicate returns false for a loaded MLX model — ggufVariant is a quant label and is null for non-GGUF, and ggufContextLength "covers only GGUF" per the store's own comment — so the panel hides the control and the adapter strips the seed for models that would honor it. Since the rebase is needed anyway, this is worth redoing on top of it. activeModel.isMlx is a clean signal here: for a loaded model that flag comes from backend.device == "mlx" rather than from the repo name, so it already answers "is this served by MLX" including the Apple-Silicon-safetensors case.

2. A test comment asserts something that is not true. The ceiling is justified with "a run whose server-drawn seed landed there could not be replayed" — but no chat path reports the seed back. Every seed echo in routes/inference.py belongs to the diffusion gallery recipes, and no chat response type carries one. A seed can only be replayed if the user typed it. The bound itself is fine; the rationale should go or change, since it will be read as documenting behavior that exists.

Worth changing

3. The hint promises more than the seed delivers. #9090's own table shows seed + temperature 0 + top_k 1 still producing 3,960 vs 150 characters, and reproducing only at n_parallel = 1 with speculative decoding off. The hint covers the sibling sampling knobs and greedy decoding but not the two levers that actually broke it, so the likely outcome is a user pinning a seed, getting a different reply, and reporting the seed as broken. One clause would cover it.

4. The panel and the request body do not gate identically. The panel passes the active model summary as a fourth argument; the adapter passes three. It is harmless today, since an audio-output model returns through generateAudio before the chat body is built — but the test asserting the invariant is a regex on the call name and cannot see the difference. That is the same blind spot as finding 1.

Notes

5. The request body already computes activeModel?.isGguf for context_overflow while modelReadsSamplingSeed re-derives the same fact from three other signals. Two notions of "is this a GGUF" in one object literal will drift.

6. NumericValueInput keeps a raw draft while focused and commits on blur, specifically so it does not rewrite what the user is typing; this field clamps on every keystroke, so typing past the maximum silently rewrites the box mid-entry. It cannot be reused as-is (value: number, no unset state), so the hand-roll is fair — just noting the divergence.

7. The type="number" precedent named in the description is in chat-providers-dialog.tsx, not chat-settings-sheet.tsx. The test comment has it right.

CI: neither failure is yours

The red checks predate and outlive this branch, so the rebase alone should clear them.

Backend CI / (Python 3.13) — failing on main itself. All six main runs of that workflow on 18 Aug failed on that job, with (Python 3.11) green on the same runs, which matches the pattern here.

Mac Studio GGUF CI / GGUF inference smoke — broadly red in the window this branch ran in. Between 03:00 and 08:00 UTC on 18 Aug that workflow failed on 17 distinct branches, main among them (nine main failures in that window, two of them at 05:38 and 05:39, minutes from this branch's 05:07 run) — 25 failures against 3 successes overall. It recovered later the same day and was green on every branch from about 16:00 onward.

Unsloth Tauri CI / Tauri Linux debug build — not a failure at all; that job was cancelled.

Mechanics

302 commits behind with conflicts, unchanged since 19 Aug. The three formatting hunks (test_lan_access_settings.py, test_compile_caches_are_per_worker.py, test_no_test_shadows_another.py) are already on main verbatim, so the rebase should shrink the diff rather than grow it.

One design thought, not a request

The client-side capability gate is the fragile part here. It was correct when written and went stale in six days, silently, in the direction of dropping a parameter the backend would have honored. The backend already solves this properly — _backend_declares inspects the live signature and fails closed. Having the load or status response report which sampling parameters the loaded backend honors, and reading that in the panel, would have lit this field up for MLX with no frontend change at all. Too large for this PR, but worth knowing it is the pattern the next parameter will copy.

@mahiatlinux
mahiatlinux force-pushed the feat/studio-sampling-seed branch from 18384a9 to bbbdb98 Compare August 25, 2026 22:49
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main and addressed all of it. The three formatting hunks (test_lan_access_settings.py, test_compile_caches_are_per_worker.py, test_no_test_shadows_another.py) dropped out of the rebase as already upstream, so the diff shrank: 10 files, 453 insertions, 3 deletions.

1. modelReadsSamplingSeed and MLX. You were right, and the predicate was answering from the wrong signals entirely. It now takes the models[] summary and returns isGguf || isMlx, with the audio-output exclusion kept ahead of it. activeGgufVariant, ggufContextLength and the .gguf suffix are gone from it. Checked the claim before rewriting: mlx_inference.py:1742 declares seed, _make_seeded_mlx_sampler at 1150 builds a per-request mx.random.key from it, worker.py:641 gates it through _backend_declares, and inference.py:1047 is the signature that has no seed, so transformers is the one that drops it. is_mlx on the loaded row comes from worker.py:442 (backend.device == "mlx"), not the repo name, so an Apple-Silicon safetensors load is covered.

5, folded into the same change. The predicate now reads the same activeModel summary the request body already reads activeModel?.isGguf from for context_overflow, so there is one notion of "is this a GGUF" per request instead of two.

4. Identical gating. Both call sites are modelReadsSamplingSeed(activeModel) on one argument. The panel's !isExternalModel prefix is gone as well: an external selection carries an external:: id (external-providers.ts:460) that no models[] entry can match, so the summary answers that case. The test no longer regexes the call name. the panel and the request body gate on the same argument extracts the argument text from both files and deepEquals it, so adding a fourth argument at one site fails it. Verified by mutating the panel to pass a second argument.

2. The ceiling comment. Removed. You are right that no chat path reports a seed back: every seed echo in routes/inference.py belongs to the diffusion recipes, and no chat response type carries one. The comment now justifies the bound as llama-server parsing the field as a uint32, so stopping at int32 max would refuse half the seeds it accepts.

3. The hint. Added: "Matching a reply also needs the model loaded with Parallel Slots at 1 and Speculative Decoding off, since both change how tokens are batched and that moves the result." Those are the load-config labels in model-config-page.tsx, so the wording points at controls the user can find.

6. Mid-entry clamping. Fixed rather than left as a note. The box keeps the raw keystrokes in a seedDraft state and commits the clamp on blur, with Enter routed to blur so it is reachable from the keyboard. Nothing rewrites what is being typed. NumericValueInput still cannot be reused (value: number, no unset state), but the divergence is gone.

7 and 8, in the description. The type="number" precedent is now chat-providers-dialog.tsx. Added a line saying the issue's inference_defaults.json evidence is families.seed, a model-family sampling block, and that ChatCompletionRequest.seed is the field that carries the pin.

The design note. Agreed and out of scope here. A load or status response reporting which sampling parameters the loaded backend honors, read by the panel, is the right shape, and _backend_declares already has the live-signature check to build it on. Not in this PR.

Checks on the rebase: npm run typecheck clean, npm test 5156 passed 0 failed with 19 in tests/chat-sampling-seed.test.ts, pytest over the four chat settings files 187 passed 0 failed, ruff check clean. Mutation-checked the four new or rewritten assertions: dropping isMlx from the predicate, passing an extra argument at the panel call site, reverting the draft to a clamp on change, and swapping the over-length clamp for slice(0, 10) each fail exactly one test and nothing else. No GPU or Mac GGUF run here, so the Mac Studio smoke is CI's to report.

InferenceParams had no seed, so a Studio generation could not be reproduced
even though ChatCompletionRequest.seed already reached llama-server. Add the
field, default null, and surface it in the Sampling section as a blank-means-
random text box.

The seed is sent only when set and only when the loaded model decodes through
llama-server, which modelReadsSamplingSeed answers for the panel and the
request body alike. Range is 0 to 4294967294: llama.cpp reads a uint32 and
spends 0xFFFFFFFF on LLAMA_DEFAULT_SEED.

Persisting it needed the storage sanitizer to range-check the value and pass an
explicit null, ChatInferenceSettings to accept the key at all since it is
extra="forbid", and PresetOwnedParams to carry it so a preset captures the pin.
An audio-output GGUF (isAudio and no hasAudioInput) answers through the
generateAudio branch in chat-adapter.ts, whose request carries no seed, so the
control let a user pin and persist one that every audio run ignored.
modelReadsSamplingSeed now takes the active model summary and excludes that
case. A model that takes audio in still decodes through llama-server and keeps
the field.
modelReadsSamplingSeed dropped the seed for MLX, which reads one since unslothai#9262:
generate_chat_response takes it, _make_seeded_mlx_sampler uses it, and worker.py's
_backend_declares gate passes it through. The old predicate answered from
activeGgufVariant, ggufContextLength and the .gguf suffix, none of which is true for
a loaded MLX model, so the panel hid the control and the adapter stripped the pin.

It now takes the models[] summary the request body already reads isGguf from for
context_overflow and returns isGguf || isMlx, so there is one notion of "is this a
GGUF" per request and both call sites pass the same argument. The transformers
backend still declares no seed kwarg, so it is still the one that drops it.

The Seed box keeps a raw draft while it is being typed into and clamps on blur.
Clamping every keystroke rewrote the box mid-entry, which is the trap
NumericValueInput's blur commit exists to avoid.

The hint now names Parallel Slots at 1 and Speculative Decoding off. unslothai#9090's table
shows seed plus temperature 0 plus top_k 1 still producing 3,960 against 150
characters without them, so the old wording promised more than the seed delivers.

The ceiling test justified the bound with a run whose server-drawn seed could not be
replayed. No chat path reports a seed back, so that comment is gone.
@mahiatlinux
mahiatlinux force-pushed the feat/studio-sampling-seed branch from bbbdb98 to f6cbb21 Compare August 26, 2026 03:45
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8511a59f01

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The seed was persisted per model and installation-wide, so a pin taken in one chat
fixed the draw for every other chat opened on that model, and reopening the first
could not bring its own value back. Every other per-turn sampling control in the
panel already travels with the conversation; maxTokens is out for a reason that does
not apply here, since a context budget belongs to the model that loaded.

seed joins THREAD_SCOPED_PARAM_KEYS and ChatThreadSettings, with the same 0 to
4294967294 bound and boolean guard the installation copy uses.

It is the first thread-scoped value whose cleared state is null rather than absent,
so the three fallbacks that read a snapshot key can no longer use ??: null there is
the chat's own choice, and coalescing it would hand back the installation pin the
user had just dropped. firstSetThreadScopedValue takes the first value that is not
undefined instead.
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ca58a6763

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…ve the seed being typed

Two ways the seed reached the wrong answer.

A locally scanned model is in neither /api/models/list nor the external ids, so its
models[] summary is minted from the load or status response. Both hops that mint one,
syncModelCapabilities and ensureActiveModelInStoreList, dropped is_mlx, so
modelReadsSamplingSeed read false for a model MLX was serving: the panel hid the field
and the adapter stripped the pin. Both now carry it, the same way hasVideoInput is
carried for the GGUF row that /api/models/list leaves incomplete.

Clicking Save on a preset blurs the seed box during mousedown, but React has not
re-rendered by the time that button's onClick runs, so the save wrote the seed from
before the entry, and over an otherwise-unmodified preset the button was still disabled
and the first click did nothing at all. committedSeed computes what blur would land on,
and the save, the unsaved-changes check and the blur handler all read it, so no two of
them can answer differently. NumericValueInput bridges the same gap with commit().
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c90a9f6d72

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…t as null

The thread response dumped every unset field as null, which runtime-provider.tsx notes
and sanitizeThreadScopedSettings drops. That worked while no thread-scoped setting had a
meaningful null. seed does: null means this chat draws its own rather than taking the pin
it would otherwise inherit, so a snapshot written before the field existed read as a chat
that had cleared it, and opening one wiped the seed the chat should have inherited.

A field_serializer on ChatThread.settings dumps with exclude_unset, so the three cases
separate on the wire: absent for a key the snapshot never held, null for a pin the chat
cleared, a number for one it set. thread_from_row validates the stored dict, so
model_fields_set is exactly the stored keys, and the test drives it through a real
response_model to cover FastAPI re-validating the return value.

POST /threads stores payload.model_dump(), so a create now stores the keys it was sent
instead of every key with nulls. The PATCH path already did that.
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d7bd723235

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…reads

QueuedModelCapabilities is a Pick over ChatModelSummary that left isMlx out, so a queued
run adopting a resident MLX model with no catalog row minted a private summary that
looked like a backend with no seed support, and the request dropped the pin.

Enumerating the rest of the family found two more: the queued snapshot at
snapshotVisibleModelState, and the compare composer's own models[] sync, which mints a
row the same way. Four places mint or refresh a summary and three were missing the flag.

Replaced the two spot checks with a rule over the capability cluster: every literal that
writes hasVideoInput has to write isMlx too, named by file and line when it does not.
Verified by dropping the flag at each of the five sites in turn.
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 5d3852b9f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Lyxot added 5 commits August 26, 2026 20:03
Blur is the only commit the Seed field has, and a browser fires no blur when a focused
element is removed: focus moves to the body and no handler runs. A draft left behind when
the field goes away, or when the loaded model changes underneath it, therefore stayed in
state with nothing able to clear it, went on answering for committedSeed, and so marked
the preset modified with the field no longer on screen and handed a preset save a seed the
user had abandoned.

Discard the draft rather than commit it when the field's model or visibility changes: an
entry walked away from was never confirmed, least of all for whichever model is loaded now.
`modelReadsSamplingSeed` answers from `isGguf`, `isMlx`, `isAudio` and `hasAudioInput`. All four were optional, so a row that left one out did not fail — it read as `false` and the gate answered wrong, hiding the seed field for a model whose backend does read one. Two commits on this branch are each a mint site that was missed that way, and the compiler had nothing to say about either.

The flags stay optional on `ChatModelSummary`, because not every summary is a catalog row and some are built by tests with no opinion on a backend. What changes is the shape the store holds: `models[]` and `setModels` now take `ChatModelRow`, a summary that has stated the four, and the gate takes `SeedGateFlags` so it cannot be handed a shape that has not. Anything minting a row therefore has to answer, and answering is cheap — every mint site already holds the backend response the flags come from.

That named a fifth site the earlier passes had not reached: the default-model row in the chat adapter stated neither `isMlx` nor `hasAudioInput`.
…gs models

The guard was copied into a third model with the sampling seed, and the uint32 ceiling was
spelled out twice. Both are one rule: bool subclasses int, so lax mode takes `true` for a
number nobody set, and llama.cpp keeps 0xFFFFFFFF for its draw-one sentinel.

The bound sits inside the Optional rather than beside it. Outside, pydantic compares None
against it and a cleared pin raises TypeError instead of validating -- the settings and
thread-settings tests both catch that, which is how the placement was settled.
Four comments repeated what the line beside them says. The seed bound in the thread-scoped table names a constant whose own definition carries the llama.cpp rationale; the preset entry said a preset captures the seed, which is the `Pick` above it, in place of saying why the value is normalised; the adopted-model row explained that the seed gate reads `isMlx`, which the summary type now requires outright; and the storage branch restated its own `null` test ahead of the reason that null is kept.

The remaining comments record constraints the code cannot: the blur gap in the numeric input, the audio-output path that answers through generateAudio, the transformers backend's missing `seed` kwarg, and the hydration paths the bound applies to.
The test pins the shape of the seed-draft reset and read as though it proved the reset runs. It cannot: this project has no DOM environment, so nothing here mounts the panel or watches the effect fire. It now states that limit, and where the claim behind it actually comes from — removing a focused input was measured in a browser to run no blur and no focusout.
@Lyxot

Lyxot commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Pushed five commits addressing the review points. Summary of what changed and why:

A seed entry could outlive the field it was typed into. Blur is the only path that commits the draft, and browsers fire no blur when a focused element is removed — focus just moves to the body. So typing a seed and then switching model, or switching to a backend that reads no seed, left the draft live in committedSeed with the field gone: the preset read as modified with nothing to show for it, and a preset save could capture a seed the user had walked away from. The draft is now discarded when the checkpoint changes or the field goes away.

The seed gate could answer wrong instead of failing. modelReadsSamplingSeed reads isGguf, isMlx, isAudio and hasAudioInput, and all four were optional, so a row that omitted one read as false — hiding the seed field for a model whose backend does read one. The flags stay optional on ChatModelSummary, since not every summary is a catalog row. What changed is the shape the store holds: models[] and setModels now take ChatModelRow (a summary that has stated the four), and the gate takes SeedGateFlags, so a mint site has to answer. That turned up one more site — the default-model row in the chat adapter stated neither isMlx nor hasAudioInput.

The boolean guard and the seed bound were duplicated across the settings models. Three near-identical validators became one BeforeValidator, and the bound is now a shared SamplingSeed annotation, so the thread-scoped and inference paths can't drift apart.

Comment trim. Removed prose that restated the line beneath it, keeping the parts the code can't say — the browser blur gap, bool subclassing int, and the llama.cpp sentinel that sets the ceiling.

One correction worth flagging: a comment I'd written claimed the seed bound had to sit inside the Optional because an outer placement would reject a cleared pin. That's not true — measured on pydantic 2.13.4, Optional[Annotated[int, Field(ge, le), ...]] and Annotated[Optional[int], Field(ge, le), ...] behave identically across None, absent, 0, the ceiling, over-ceiling, negative and True. The claim was removed rather than reworded.

Validation: 105 frontend tests, 145 backend tests, tsc clean. The comment-trim commits were checked syntax-tree-identical to their originals, so they change no code.

@Lyxot

Lyxot commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 6fc0c3a323

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. The code checks out and CI is clean once main's own breakage is accounted for.

To get a full check run without waiting on the upstream queue, I mirrored this branch into a fork PR at the same commit — identical diff, verified by hash:

upstream #9144 diff sha1: 0ef2ff984028957fd60bae61eeaca5fd8bd9a9d8
mirror        diff sha1: 0ef2ff984028957fd60bae61eeaca5fd8bd9a9d8

Result: 41 pass, 5 fail, 4 skipped. All five failures are inherited from main, not introduced here:

Check Actual failure Origin
Frontend build + bundle sanity Locale parity: 4 missing settings.agents.* keys #9752 added them to en.ts only, no overlays
Repo tests (CPU) test_pip_cache_naming.py reads without an encoding, ×3 #9781
workflow-trigger lint Same file reads a workflow but isn't in the unfiltered guard job #9781
Python 3.13 test_control_markup_neutralize_7066 — 1 fail in 32,733 pre-existing on main
Core (HF=latest + TRL=latest) mxfp4.dequantize missing on transformers 5.16.0 upstream API drift

Two things make the attribution solid: this branch touches none of those files — the four missing i18n keys appear zero times in the diff — and both root-cause commits landed on main after this branch's merge-base, so they only appear because CI tests the merge. pre-commit.ci is red for the same reason: it is currently failing on main itself, and the 163 files it rewrites include none from this PR.

What I checked beyond CI:

  • The seed reaches inference. payload.seed already flowed to llama-server before this PR, so the frontend field lands on working plumbing rather than a no-op.
  • The ?? → firstSetThreadScopedValue change is the risky one, since it touches every thread-scoped param and the backend declares them all Optional. It is safe: sanitizeThreadScopedSettings drops null for every bounded-number key and re-adds it only for seed. Feeding it a legacy all-nulls snapshot returns {"seed": null} and nothing else.
  • Seed input edges: "" clears, 4294967295 clamps to 4294967294 so a pin can never land on LLAMA_DEFAULT_SEED, overlong input clamps, non-numeric clears.
  • Locally: 1317 frontend chat tests and 155 backend tests pass.

@Lyxot
Lyxot merged commit ca62b6b into unslothai:main Aug 26, 2026
40 of 50 checks passed
@mahiatlinux
mahiatlinux deleted the feat/studio-sampling-seed branch September 25, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Studio: no sampling seed in the UI, so a generation cannot be reproduced

3 participants