Repository navigation
add a setting that tells the model the current date - #8879
Conversation
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.
There was a problem hiding this comment.
💡 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()}." |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
… 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.
|
@codex review |
There was a problem hiding this comment.
💡 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".
| const saveCurrentDatePrompt = async (enabled: boolean) => { | ||
| setIsSavingCurrentDatePrompt(true); | ||
| setCurrentDatePromptError(null); | ||
| try { | ||
| setCurrentDatePrompt(await updateCurrentDatePrompt(enabled)); |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
@codex review |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 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".
…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.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
|
Before/after UI evidence, from two isolated Studio installs built with 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:
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 (
So the date line is gated on the setting rather than unconditional, and it lands ahead of the user's own text, matching No weights and no GPU were involved: a settings panel and one loopback endpoint are the whole cost. Downloadable copyPackaged by a disposable workflow on the fork branch
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. |
|
Fixed and pushed in
Validation:
No real-provider inference was run. |
There was a problem hiding this comment.
💡 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".
|
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 The review found and fixed these concrete problems at
The fixes are split across nine focused commits after the current Focused fork CI passed on Python 3.10 and Node 22: run 33162603334. ConvergenceThe first post-push Codex pass found two additional routing defects:
The upstream Windows frontend job also exposed a stale test assertion from the 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 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. |
|
@codex review |
There was a problem hiding this comment.
💡 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Fresh A/B on exact merge base |
Imagineer99
left a comment
There was a problem hiding this comment.
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.
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.
* 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]>


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, instudio/backend/utils/current_date_prompt_settings.py. It is served atGET/PUT /api/settings/current-date-promptand shown as a toggle in Settings > Chat > Chat defaults.Where the date now lands:
openai_chat_completions_system_prompt_with_instructionsso 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/messageson every branch but the client-tool passthroughprovider_is_self_hostedDeliberately 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_nudgeno longer carries the date. It rides the system prompt instead, so a tool-less chat is no longer date-blind. Injection is idempotent onCURRENT_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_tokensandanthropic_count_tokensfollow 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:
2024-05-05(its training-cutoff guess, the reported bug)2026-08-15With 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:
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,
tscclean, 763 focused backend tests pass. No GPU checks were run; none apply to this change.