Skip to content

add a setting that tells the model the current date - #8879

Merged
Imagineer99 merged 21 commits into
unslothai:mainfrom
mahiatlinux:feat/studio-current-date-prompt
Aug 28, 2026
Merged

Imagineer99 merged 21 commits into
unslothai:mainfrom
mahiatlinux:feat/studio-current-date-prompt

Conversation

@mahiatlinux

Copy link
Copy Markdown
Contributor

Closes #8859.

Models answered from their training cutoff, so Deep Research planned its searches around 2023/2024 and web search went looking for stale sources. There was no way to fix it short of editing the system prompt every day.

What this adds

A global setting, include_current_date_in_prompt, default on, in studio/backend/utils/current_date_prompt_settings.py. It is served at GET/PUT /api/settings/current-date-prompt and shown as a toggle in Settings > Chat > Chat defaults.

Where the date now lands:

  • local chat, with or without tools, applied once in openai_chat_completions
  • Deep Research, prefixed in _system_prompt_with_instructions so the planner, agent, audit and report calls all get it. The date is stamped into the run config at creation, so a run spanning midnight keeps the date it started on
  • /v1/messages on every branch but the client-tool passthrough
  • self-hosted providers (vLLM, Ollama, llama.cpp, Custom) via provider_is_self_hosted

Deliberately left alone: hosted APIs and Codex, which state the date in their own context, and the llama-server passthrough, which forwards a caller's own request verbatim.

_build_tool_action_nudge no longer carries the date. It rides the system prompt instead, so a tool-less chat is no longer date-blind. Injection is idempotent on CURRENT_DATE_PROMPT_PREFIX: a research hop posts an already-dated prompt back through the chat route, and a second line would contradict the first once the run crosses midnight.

chat_count_tokens and anthropic_count_tokens follow the same rule as their generation twins, so counts still match what is sent.

Verification

Manually tested end to end against a running Studio instance.

Local MLX model (Qwen3-0.6B-4bit), asked for today's date:

setting reply
off 2024-05-05 (its training-cutoff guess, the reported bug)
on 2026-08-15

With a user system prompt set, both survive: Today's date is **2026-08-15**. BANANA.

Against an OpenAI-compatible server that echoes the system prompt it received:

vllm       -> "The current date is 2026-08-15.\n\nBe terse."
ollama     -> "The current date is 2026-08-15.\n\nBe terse."
llama_cpp  -> "The current date is 2026-08-15.\n\nBe terse."
custom     -> "The current date is 2026-08-15.\n\nBe terse."
openai     -> no date
deepseek   -> "Be terse."
mistral    -> "Be terse."
kimi       -> "Be terse."
openrouter -> "Be terse."

A prompt that already states a date is left untouched, including when Deep Research buries it under its instructions header, so no hop is dated twice.

Token counts track generation: 42 -> 89 with the setting on for a normal chat, and 42 either way on the verbatim passthrough.

The settings toggle was driven in a browser: it reads server state, writes on click, and a fresh session reads back the persisted value.

Ruff format and check clean, i18n strict parity clean across all 12 locales, tsc clean, 763 focused backend tests pass. No GPU checks were run; none apply to this change.

Models answered from their training cutoff, so Deep Research planned searches around
2023/2024 and web search looked for stale sources. Closes unslothai#8859.

New global setting `include_current_date_in_prompt` in utils/current_date_prompt_settings.py,
default on, exposed at GET/PUT /api/settings/current-date-prompt and as a toggle in
Settings > Chat > Chat defaults.

Where the date now lands:
- local chat, with or without tools, applied once in openai_chat_completions
- Deep Research, prefixed in _system_prompt_with_instructions so the planner, agent, audit
  and report calls all get it; stamped into the run config at creation so a run spanning
  midnight keeps its starting date
- /v1/messages on every branch but the client-tool passthrough
- self-hosted providers (vllm, ollama, llama_cpp, custom) via provider_is_self_hosted

Left alone: hosted APIs and Codex, which state the date in their own context, and the
llama-server passthrough, which forwards a caller's request verbatim.

_build_tool_action_nudge no longer carries the date, so it rides the system prompt instead
and a tool-less chat is no longer date-blind. Injection is idempotent on
CURRENT_DATE_PROMPT_PREFIX: a research hop posts an already-dated prompt back through the
chat route, and a second line would contradict the first after midnight.

chat_count_tokens and anthropic_count_tokens apply the same rule as their generation twins,
so counts still match what is sent.

@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: ef5943d3ac

ℹ️ 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".

"""Return the shared date sentence, or an empty string when the preference is off."""
if not get_current_date_prompt_enabled():
return ""
return f"{CURRENT_DATE_PROMPT_PREFIX}{(today or date.today()).isoformat()}."

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 Derive today's date from the caller's timezone

In remote, Colab, or shared-server deployments where the backend and user are in different timezones, date.today() supplies the server's calendar date. Around midnight this default-on feature therefore tells the model yesterday's or tomorrow's date, and Deep Research persists that incorrect value for the entire run. The request needs to provide the browser's timezone/date, or the application needs an explicit user timezone setting, rather than relying on the host timezone.

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. date.today() is the same server-local call the tool nudge already used before this PR, so the date value's semantics are unchanged; what changed is only how often it is sent. There is no user or browser timezone anywhere in the request today, so honouring one means a new request field plus frontend plumbing and a per-user setting, which is a separate change rather than a fix to this behaviour. Studio also runs on localhost in the common case, where server and user share a timezone. Worth doing as a follow-up for remote and Colab deployments.

Comment thread studio/backend/routes/inference.py Resolved
Comment thread studio/backend/routes/inference.py Resolved
… date

anthropic_count_tokens skipped the date whenever the caller sent any tools, but /messages only
forwards verbatim on the client-tool passthrough. A Studio server-tool alias, or a template
without tool-passthrough support, falls through to plain generation there and does carry the
date, so the count under-reported those prompts. It now reproduces the same client_tools
predicate the generation route uses.

_prepend_current_date_to_messages returned on the first system turn, so a date on a later
system or developer turn was missed and a second one got inserted. The scan now covers every
system turn before anything is written.
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 14, 2026

@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: 6f5e876210

ℹ️ 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".

Comment thread studio/backend/routes/inference.py Resolved
Comment thread studio/backend/core/research/prompts.py Resolved
Comment on lines +220 to +224
const saveCurrentDatePrompt = async (enabled: boolean) => {
setIsSavingCurrentDatePrompt(true);
setCurrentDatePromptError(null);
try {
setCurrentDatePrompt(await updateCurrentDatePrompt(enabled));

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 Recount context usage after changing the date prompt

After this save succeeds, the server changes the prompt that /chat/count_tokens and the next local generation will render, but the currently mounted chat retains its existing contextUsage snapshot. Because Settings is an overlay, closing it does not remount the chat or trigger ThreadContextUsageRecount, which only counts into a blank bar; enabling the date can therefore leave the context meter undercounting until a generation completes and may let a near-limit request exceed the available context. Clear and refresh the active thread's usage after the update succeeds.

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. The date is a single short sentence, so the drift is roughly ten tokens, and the meter re-counts on the next message anyway. Reaching from the settings overlay into the active thread's usage store to force a recount is a change in another feature for that margin, and the near-limit case it describes is already handled by the server-side context check rather than the bar. Happy to revisit if the meter turns out to drift by an amount that actually changes a decision.

The inference router is also mounted at /v1, so a third party's sk-unsloth key reached the same
handlers and a tool-less request came back with a system turn it never sent, which breaks a
deterministic eval. _wants_current_date gates on _request_used_api_key, which already treats
internal workflow keys as Studio, so Deep Research and the UI keep the date.

The planner rule said never to put an older year in a query. Early in a year the most recent
annual figures are the previous year's, so it now says to anchor on the stated date rather than
a year the training data makes feel current.

Pinned the current-date line off in the shared count-tokens backend helper so message-shape
assertions do not depend on the host's stored setting, and added
test_chat_count_tokens_prices_the_current_date for the date's own effect on the count.
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 14, 2026
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

1 similar comment
@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: c6888ec286

ℹ️ 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 thread studio/backend/routes/research_runs.py Resolved
Comment thread studio/backend/routes/inference.py Resolved
Comment thread studio/backend/routes/inference.py Resolved
…t parts

_wants_current_date gated on _request_used_api_key, which excludes Studio's own workflow keys,
so the date reached two callers that compose their own prompts. routes/data_recipe/jobs.py mints
an internal key and points user-authored recipes at /v1, where the injected instruction would
change generated datasets. Deep Research decides once at run creation and stamps the answer into
its config, so a run created while the preference was off picked up a fresh date as soon as the
preference was turned back on. Gating on _request_has_api_key leaves both to their own prompt and
limits the date to an interactive session.

_states_a_date now reads content parts as well as plain strings, so a date already present in a
text-part array suppresses a second one.
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

1 similar comment
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: b783353630

ℹ️ 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 mahiatlinux self-assigned this Aug 17, 2026
@mahiatlinux

mahiatlinux commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Before/after UI evidence, from two isolated Studio installs built with install.sh --local at the merge base 203007d19 and at the head b783353630, driven through the same scene.

Chat defaults, before and after

Settings > Chat > Chat defaults, shot as an element so the row descriptions stay legible. 5 rows becomes 6, with "Tell the model today's date" first and its toggle on. The five rows below it are the same rows in the same order with the same toggle states on both halves, which is the control: had they moved, the tab would not have rendered and the pair would prove nothing.

Read from the same servers that were photographed:

reading base 203007d19 head b783353630
GET /api/settings/current-date-prompt 404 {"enabled": true, "default_enabled": true}
PUT /api/settings/current-date-prompt 405 {"enabled": false, "default_enabled": true}
rows in Chat defaults 5 6
the new row's Switch absent aria-checked="true", not disabled

The behavioural half was measured through the real proxy path instead of being taken on trust. A loopback OpenAI-compatible server stands in for a self-hosted endpoint (provider_type: "vllm", provider_base_url on 127.0.0.1, no key, which provider_is_self_hosted admits) and records the system turn Studio hands it. The chat's own system prompt is Be terse.:

side system turn the endpoint received
base Be terse.
head, setting at its default The current date is 2026-08-17.\n\nBe terse.
head, after PUT {"enabled": false} Be terse.

So the date line is gated on the setting rather than unconditional, and it lands ahead of the user's own text, matching _apply_current_date_prompt's comment about the system prompt keeping the last word.

No weights and no GPU were involved: a settings panel and one loopback endpoint are the whole cost.

Downloadable copy

Packaged by a disposable workflow on the fork branch pr-8879-evidence-ci, run 32025454962, green. Artifact name pr8879-evidence, 112 KB:

  • chat-defaults-before-after.png, the labelled BEFORE | AFTER pair shown above, 1404x508
  • before_chat_defaults.png, the base half on its own, 690x452
  • after_chat_defaults.png, the head half on its own, 690x452
  • facts.json, the per-side readings behind both tables, with the base and head SHAs

The run re-asserts every claim in this comment against those four files before uploading them, so a swapped image or an edited table fails it rather than shipping. Both halves are padded to the same 690x452 canvas, which is why the pair is at one scale and nothing was cropped to fit.

No GIF: this scene takes single element screenshots, so there is no frame series or webm here to build one from.

Etherll commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Fixed and pushed in 2df0013f1 (with current main merged in f893585e6).

  • _states_a_date now recognizes only a complete canonical The current date is YYYY-MM-DD. line, so prompts that merely discuss the phrase are still dated.
  • Added negative regressions for plain system prompts and structured text parts while retaining the existing buried/idempotent stamp coverage.
  • Resolved chat-tab.tsx against current main by preserving both the current-date toggle and all newly added chat defaults.

Validation:

  • current-date suite: 24 passed
  • broader OpenAI/Anthropic route set: 907 passed; the same two pre-existing Windows 0.2s timing tests failed as in the base/target review
  • frontend: 3,633 passed; typecheck passed; strict i18n parity passed for all 12 locales
  • Ruff and targeted Biome checks passed; GitHub now reports the PR mergeable

No real-provider inference was run.

@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: b514ab577e

ℹ️ 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

mahiatlinux commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Verified scope first. Issue #8859 reports Deep Research treating cutoff-era dates as current. The repository routes every research planner, agent, audit, and report prompt through _system_prompt_with_instructions, so a run-scoped date is an effective fix at the prompt source. The setting remains limited to Studio-composed requests and defaults on.

The review found and fixed these concrete problems at 9e532d677c41393679bd262154dee21cf970ccc0:

  1. The backend date could disagree with the user's calendar date. A Studio browser in Auckland talking to a UTC server around midnight received the server's date. authFetch now sends the browser IANA zone and offset on initial and retry requests, and the backend resolves the date with ZoneInfo, offset fallback, then server-local fallback. Evidence: auth/api.ts lines 31-47, current_date_prompt_settings.py lines 79-108, and the boundary regression.

  2. An old canonical date suppressed today's date. Existing prompts and copied Deep Research instructions could retain The current date is 2025-..., so the model saw stale or conflicting dates. Interactive prompts now replace canonical date lines without mutating caller input. Research runs stamp one browser-local date at creation, strip conflicting canonical dates from instructions, and keep that date stable across midnight and setting changes. Evidence: inference.py lines 4750-4803, research_runs.py lines 363-372, prompts.py lines 116-131, and stale-date regressions.

  3. Hosted providers were excluded from the feature. Studio composes and forwards the message list for OpenAI, Anthropic, Gemini, OpenRouter, and the other external providers just as it does for self-hosted providers. Limiting the date to a provider_is_self_hosted classification made the setting silently ineffective for hosted chats and misclassified legacy saved providers. The route now dates every Studio-authenticated external-provider message list, while API-key passthrough stays unchanged. Evidence: external route application and the hosted-provider matrix. The redundant provider classification was removed.

  4. Structured system content produced a second system turn. OpenAI-compatible messages may hold system content as text parts. Prepending a separate message changed the conversation shape and could violate provider ordering. The date is now inserted into or refreshed inside the existing system/developer content, including lists with no text part. Evidence: _prepend_current_date_to_messages lines 4823-4855 and structured-content regressions.

  5. API server-side tool loops lost the date after their first pass, and count-token routes disagreed with generation. These loops are composed by Studio even though they carry an API key. The date is now allowed only for an actual Studio server-tool loop. Plain API requests, client-tool passthrough, and internal workflows remain verbatim so Deep Research keeps its run-stamped date. OpenAI and Anthropic token counting use the same gate. Evidence: include_api_key gate, OpenAI route regression, Anthropic route regression, and count-token parity.

  6. The local GGUF context meter stayed stale after toggling the setting. The stored token count still represented the old prompt. A successful save now invalidates the displayed count and requests a recount, with active-generation retry behavior preserved. Evidence: chat-tab.tsx lines 311-320, refresh-context-usage.ts lines 188-224, and the focused meter regression.

  7. Settings search could not find the new row. The translation key is now in the Chat search index and covered by the search test. Evidence: settings-search.ts lines 96-104 and settings-search.test.ts lines 63-70.

  8. The switch had no accessible name and save/load errors were not announced. The switch now uses the translated row label and the error has role="alert". Evidence: chat-tab.tsx lines 397-416 and the accessibility regression.

  9. Network-error fallbacks were hardcoded English despite all 12 locale keys existing. The API helper now receives translated fallbacks from the settings tab, so a non-FastAPI failure no longer bypasses localization. Evidence: current-date-prompt.ts lines 27-53, chat-tab.tsx lines 295-325, and the translated-fallback regressions.

The fixes are split across nine focused commits after the current main merge. Focused local checks passed for current-date behavior, hosted-provider routing, structured content, OpenAI and Anthropic server-tool loops, count-token parity, Ruff on changed backend paths, the five relevant frontend test files, TypeScript typecheck, and strict parity for all 12 locales. No GPU tests, model downloads, or full local suite were run.

Focused fork CI passed on Python 3.10 and Node 22: run 33162603334.

Convergence

The first post-push Codex pass found two additional routing defects:

  • API-key external-provider requests used the preliminary studio_tool_loop intent to allow date injection. An empty or unrecognized selected tool list then fell back to plain proxying with the caller's prompt already modified. Date injection now happens after tool resolution and uses run_studio_tool_loop, so only a real server-tool loop gets the API exception. Evidence: inference.py lines 18175-18189 and the empty-resolution regression.
  • The dedicated ChatGPT subscription branch returned before the shared external-provider injection point. Interactive Codex chats therefore never received the date. The branch now applies the date after its own tool selection, with the same resolved-tool API gate. Evidence: inference.py lines 17861-17890 and the route regression.

The upstream Windows frontend job also exposed a stale test assertion from the scrollRowPadding to unrailedRowPadding rename on current main. The assertion now tracks the production variable and its six focused tests pass. Evidence: on-device-dot-and-header-alignment.test.ts lines 67-101.

Focused convergence verification passed: 92 backend route and date tests, the exact Codex route regression, Ruff on changed backend paths, and all six sidebar alignment tests. A second Codex pass reported no remaining major issues on d349e7cb1.

Final focused fork CI passed every relevant backend test, Ruff, TypeScript typecheck, strict parity for all 12 locales, and the six focused frontend files: run 33164293605.

@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: 7d2adf739f

ℹ️ 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".

Comment thread studio/backend/routes/inference.py Resolved
Comment thread studio/backend/routes/inference.py Resolved
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: d349e7cb16

ℹ️ 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".

Copy link
Copy Markdown
Member

Fresh A/B on exact merge base 411b40615a vs head d349e7cb16: Chat defaults goes from 12 to 13 rows, the new current-date switch is first and on by default, toggles persist, and the date reaches the model only when enabled. Looks valid. There was no equivalent Studio setting or injection on base. I don't think another Actions A/B run adds much here; the focused CI plus this UI/runtime proof covers the actual risk.

PR 8879 Studio Chat defaults BEFORE and AFTER

@Imagineer99 Imagineer99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved. The four failing checks are inherited from merge base 411b406, including the exact same 19 Python 3.13 failures. The Core failures come from the unpinned unsloth_zoo@main test suite and also fail on main. PR-specific Studio checks pass.

@Imagineer99
Imagineer99 merged commit 4502999 into unslothai:main Aug 28, 2026
47 of 51 checks passed
danielhanchen pushed a commit that referenced this pull request Aug 31, 2026
The retry added in the previous commit did its job and disproved its own premise.
It fired three times, 33 seconds apart, and each attempt failed identically:

  [appimage-e2e] quant listing failed (attempt 1/3): "Unsloth isn't running..."
  [appimage-e2e] quant listing failed (attempt 2/3): "Unsloth isn't running..."
  [appimage-e2e] quant listing failed (attempt 3/3): "Unsloth isn't running..."

So this was never a transient blip. It is deterministic, and the cause is a CORS
preflight the fixture rejects.

#8879 (2026-08-28 12:01 UTC) started attaching X-Unsloth-Timezone and
X-Unsloth-Timezone-Offset-Minutes to every authFetch. The fixture answered
preflights with a hand-written "Authorization, Content-Type, X-HF-Token", so the
browser refuses to send those two, the request never reaches the socket, fetch
rejects with a TypeError, asTransportFailure turns that into "Unsloth isn't
running -- please relaunch it.", and the row renders it where its quantizations
belong. /api/health keeps answering throughout because it is not an authFetch and
needs no preflight, which is why the app looks perfectly healthy in the artifact.
The failures start the same day. Nothing else moved.

#8879 is right and the real backend already allows this: studio/backend/main.py
runs CORSMiddleware with allow_headers = ["*"]. The fixture's fixed list was never
the product's behaviour, only a second copy of it, and a second copy is the bug --
it can only drift, and it did.

So the preflight echoes Access-Control-Request-Headers, which is what ["*"] means
in practice and cannot drift again. Preflights are also recorded now: a rejected
one sends no request, so the log showed nothing at all and the failure read as
"the frontend never tried".

Reproduced before fixing. Driving a real OPTIONS through http.server with the
exact headers an authFetch sends, and reading the header names out of the frontend
source rather than restating them:

  main (hardcoded list)  Allow-Headers: authorization, content-type, x-hf-token
                         missing: x-unsloth-timezone,
                                  x-unsloth-timezone-offset-minutes
                         => browser blocks -> fetch TypeError
  this change (echo)     missing: none => allowed

tests/studio/test_appimage_fixture_cors.py keeps it that way, 6 tests: the echo
admits everything the frontend sends; the old list is still detected as broken;
the fixture must echo rather than name headers (mutation-checked -- restoring the
hardcoded list fails it); the backend still allows every header, since that
premise is what makes echoing faithful; and casing does not matter.

The Retry handling from the previous commit stays. It is what turned an opaque
15-second timeout into the three-line log above, and it still reports what the row
said when the retries run out.
danielhanchen added a commit that referenced this pull request Aug 31, 2026
* Let the AppImage E2E use the Retry the failed quant row offers

`AppImage model download E2E` has failed on roughly three runs in four since
2026-08-28, on unrelated branches, as a hard gate on every PR. Two adjacent runs
on the same branch, one pass and one fail, so it is a race rather than a break.

What the evidence from the failing run shows, and what it rules out. Studio is up:
the app started, the managed preflight reported ManagedReady, the backend was
validated on port 8888, desktop auth was exchanged, and the fixture kept answering
/api/health for another 49 seconds after the point of failure. The screenshot
shows the Images page loaded and the model picker open and populated. So this is
not a launch failure, not auth, and not the AppImage.

What actually fails is one row. The captured DOM has "Unsloth isn't running --
please relaunch it." rendered inside the FLUX.2-klein-4B row, exactly where its
quantizations belong, and no Q4_K_M anywhere. That string comes from
asTransportFailure in features/auth/api.ts, which tags a fetch TypeError, so the
request never completed at the transport layer. The fixture records every GET
before dispatch and no gguf-variants request appears, so it never left the webview
-- and the fixture does implement that endpoint, so a missing route is not it.

Waiting longer cannot help. The expander's effect is keyed on
[repoId, localSource, refreshKey, hfToken] and its .catch() calls setError and
stops. There is no automatic retry by design; the row renders a Retry button
instead. One blip at the moment the row expands therefore leaves that row showing
an error for the rest of the run, and the 15s wait sits on a row where nothing is
in flight.

So the test now clicks the Retry the row is offering, up to three times. That is
what a user does, and it uses the product's own affordance rather than working
around it. It stays honest in both directions:

  - it only retries when a listing error is actually on screen; a quantization
    that is simply absent still fails on the first wait, with the original message
  - if the retries run out, it fails and quotes what the row reported, so a
    backend that really is unreachable is still a red run

Verified against the real artifact: the selectors were run over the captured
failure DOM from run 33338397183 and match exactly one element, the destructive
row carrying both the message and the Retry button, with Q4_K_M genuinely absent.
The helper itself is covered offline in four scenarios, 5/5: recovers when Retry
clears it, fails naming the row's message when it never clears, does not click
Retry when there is no error, and passes untouched when the quant is there.

Not fixed here, and worth a look separately: a user who hits that blip sees a
dead row until they press Retry themselves. That may well be the intended
trade-off, but the sticky state is what makes this gate flaky, and I could not
reproduce the underlying transport failure on this machine to say more.

* Stop the E2E fixture's CORS preflight drifting from the real backend

The retry added in the previous commit did its job and disproved its own premise.
It fired three times, 33 seconds apart, and each attempt failed identically:

  [appimage-e2e] quant listing failed (attempt 1/3): "Unsloth isn't running..."
  [appimage-e2e] quant listing failed (attempt 2/3): "Unsloth isn't running..."
  [appimage-e2e] quant listing failed (attempt 3/3): "Unsloth isn't running..."

So this was never a transient blip. It is deterministic, and the cause is a CORS
preflight the fixture rejects.

#8879 (2026-08-28 12:01 UTC) started attaching X-Unsloth-Timezone and
X-Unsloth-Timezone-Offset-Minutes to every authFetch. The fixture answered
preflights with a hand-written "Authorization, Content-Type, X-HF-Token", so the
browser refuses to send those two, the request never reaches the socket, fetch
rejects with a TypeError, asTransportFailure turns that into "Unsloth isn't
running -- please relaunch it.", and the row renders it where its quantizations
belong. /api/health keeps answering throughout because it is not an authFetch and
needs no preflight, which is why the app looks perfectly healthy in the artifact.
The failures start the same day. Nothing else moved.

#8879 is right and the real backend already allows this: studio/backend/main.py
runs CORSMiddleware with allow_headers = ["*"]. The fixture's fixed list was never
the product's behaviour, only a second copy of it, and a second copy is the bug --
it can only drift, and it did.

So the preflight echoes Access-Control-Request-Headers, which is what ["*"] means
in practice and cannot drift again. Preflights are also recorded now: a rejected
one sends no request, so the log showed nothing at all and the failure read as
"the frontend never tried".

Reproduced before fixing. Driving a real OPTIONS through http.server with the
exact headers an authFetch sends, and reading the header names out of the frontend
source rather than restating them:

  main (hardcoded list)  Allow-Headers: authorization, content-type, x-hf-token
                         missing: x-unsloth-timezone,
                                  x-unsloth-timezone-offset-minutes
                         => browser blocks -> fetch TypeError
  this change (echo)     missing: none => allowed

tests/studio/test_appimage_fixture_cors.py keeps it that way, 6 tests: the echo
admits everything the frontend sends; the old list is still detected as broken;
the fixture must echo rather than name headers (mutation-checked -- restoring the
hardcoded list fails it); the backend still allows every header, since that
premise is what makes echoing faithful; and casing does not matter.

The Retry handling from the previous commit stays. It is what turned an opaque
15-second timeout into the three-line log above, and it still reports what the row
said when the retries run out.

---------

Co-authored-by: danielhanchen <[email protected]>
@mahiatlinux
mahiatlinux deleted the feat/studio-current-date-prompt branch September 25, 2026 05:33
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.

[Feature] check Box for including current date in prompt, whether for system or deep research / search

4 participants