Skip to content

Studio: stop writing the date into user messages - #12699

Merged
mahiatlinux merged 18 commits into
unslothai:mainfrom
NilayYadav:studio-date-in-system-turn
Oct 5, 2026
Merged

mahiatlinux merged 18 commits into
unslothai:mainfrom
NilayYadav:studio-date-in-system-turn

Conversation

@NilayYadav

@NilayYadav NilayYadav commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

With "Tell the model today's date" on, Studio has been adding [Current date: YYYY-MM-DD] to the user's own messages since #12096, and with no system prompt also to the first message since #12382. Models read it as part of the chat. In role-play, Gemma 4 replies "The date has turned" and jumps the story ahead.

Now the date is one line in the system prompt, The current date is YYYY-MM-DD., and user messages are sent as written.

  • If the model's chat template has its own default system prompt (Qwen2.5, Magistral), the date goes in front of it so the default isn't lost.
  • If that default already states today's date (Granite, Mistral Small), it is left to the template.
  • A chat that crosses midnight reprocesses its prompt once on the new day.

Before / after this PR

Gemma 4 26B-A4B (UD-Q4_K_M), a role-play chat started 3 weeks earlier, no system prompt, default settings. Same chat and turn on both.

main (6295d6c) this PR (e519ff3)
Date in the prompt [Current date: 2026-09-14] on the first user message, [Current date: 2026-10-05] on the newest The current date is 2026-10-05. in the system prompt, user messages as written
Reasoning mentions the date 7/7 0/7

Before (main): the reasoning opens with "October 5, 2026 (Current date in-prompt)".

before main

After (this PR): the reasoning goes straight to the scene.

after this PR

Where it started

v0.1.815, with the date only in the system prompt: the reasoning goes straight to the scene.

v0.1.815

v0.1.902, after #12096 and #12382: the reasoning opens with "Current date: 2026-10-04 (this is a metadata update…)".

v0.1.902

Tests updated for the removed note, plus new tests for the system-prompt date and template-default handling.

@danielhanchen

Copy link
Copy Markdown
Member

The red MLX CI on Mac M1 here is not this PR. unsloth-zoo #1546 now calls nax_quantized_linear(model, int8_prefill), and the Studio MLX test stub only accepted one argument. #12700 fixes the stub. Re-run once it lands.

@NilayYadav NilayYadav left a comment •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review + reproduction evidence

Pinned review: 85bef7215e. Three regressions found and fixed in cf8831b455, 0d7a881800 and 85bef7215e; follow-ups below.

Same steps on main (9d76f755) and on this branch, Linux with an NVIDIA L4, default settings ("Tell the model today's date" on, no system prompt):

  • Echo test, Gemma 4 12B, "Repeat my message above exactly as you received it": main repeats [Current date: 2026-10-05] before the message in 3/3 runs. This branch repeats the message as typed in 3/3. Asked "What's today's date?", both answer October 5, 2026.
  • Role-play chat started three weeks earlier, next turn sent: on main the reasoning brings up the date in 3/3 replies ("The current date changed from 2026-09-15 to 2026-10-05 ... let me check the date jump"). On this branch it does in 0/3.

PR 12699 echo before/after

Fixed on this branch

  1. cf8831b455: with Search or Code on and no system prompt, a model whose template states the date itself (Granite 3.x, Mistral Small 3.x) got no date, because the tool instructions became the only system turn. Granite 3.3 2B, "What is today's date?": main 2026-10-05, as submitted 2023-03-15, now 2026-10-05, 3/3 each. The same commit makes safetensors and MLX read an applied chat template override instead of the shipped template.
  2. 0d7a881800: a model whose chat_template is a list of named templates (Hermes-3) lost its built-in system prompt. The default template is now read.
  3. 85bef7215e: the template's own default is now rendered for the user's day, not the server's. Granite 3.3 on a UTC server, browser on October 5, tools off: before "October 04, 2026", now "October 05, 2026" (3/3). Mistral Small 3.2 works out "yesterday" from that same day. The same commit keeps the default of templates that read text from content parts: granite-vision 3.2 lost "A chat between a curious user and an artificial intelligence assistant...", and its prompt goes from 45 to 78 tokens on a text turn and from 1,363 to 1,396 with an image, the same counts its own tokenizer and processor give for the date plus that default.

Granite date with Search on

The PR's tests and the tool passthrough suites pass on this branch (2281 passed); on main the PR's tests fail (15 failed, 6 errors).

Follow-ups, not in this PR

  • On vLLM/SGLang engines and for Gemma 3n audio, the date line can still replace the template's own default system prompt or instruction.

@NilayYadav

NilayYadav commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

Codex coverage

Codex does not answer @codex review on this repo, so it reviewed exact mirrors: NilayYadav/unsloth#387 for rounds 1 to 3 and NilayYadav/unsloth#394 from round 4. The PR's files on the mirror are byte-identical to 85bef7215e; the current head 5243e59895 only adds the pre-commit.ci formatting commit on top (test_openai_auto_switch.py, +1/-3).

  • Round 1 on e90c12d270 (as submitted): a P1 and two P2s. Probing the shipped template instead of an applied override on safetensors/MLX (P2) was genuine and is fixed in cf8831b455. A template that rejects a system turn failing every chat (P1) was rejected: Gemma 2 2B with no system prompt chats normally on this branch. Freezing request-dependent defaults such as Granite with tools (P2) was rejected: Studio never sends the flags those branches read except tools, and with tools on the tool instructions already replaced that default on main.
  • Round 2 on cf8831b455: three new items. Named templates (the Hermes-3 list shape) probing as None (P1) was genuine and is fixed in 0d7a881800. The server clock in self-dating templates (P2) was genuine and is fixed in 85bef7215e: the default is now rendered for the user's day. Probing the processor template for image requests (P1) was rejected: on 14 vision models the processor and tokenizer templates carry the same default once the probe also reads content parts, which 85bef7215e adds.
  • Round 3 on 0d7a881800: one new P2, selecting the named tool_use template on tool requests, was rejected: with tools on, the tool instructions already replaced that default on main.
  • Round 4 on 85bef7215e: two P1s, both rejected. A template that rejects a system turn (raised again, now for GGUF and MLX): llama.cpp merges a system message into the first user turn when the template has no system role (system_message_not_supported in common/chat.cpp), Gemma 2 2B with no system prompt chats normally on this branch, and v0.1.815 already sent a date-only system turn for every chat without one. Probing the tool_use branch for tool requests (as in rounds 1 and 3): with tools on, the tool instructions already replaced that default on main.

Status: no open items on the current head. Every finding above is fixed or rejected, and rounds 3 and 4 raised only items that were rejected.

@mahiatlinux mahiatlinux self-assigned this Oct 5, 2026
@mahiatlinux

Copy link
Copy Markdown
Contributor

Final review and repair evidence

Reviewed from merge base 312d126b015eb4e3738e8a360540b832eceb97d8 through repaired source head 46648fb17f3f25d2669126e1ffbb932aaa6ce85d.

The repair commit preserves native chat-template defaults across generation-tag templates, Transformers-compatible tojson and absent tool/document values, structurally different system branches, and safetensors/MLX client-tool paths. Exact-model probes covered Qwen 2.5, Sarvam M, and OLMo 3 templates.

Verification:

  • Isolated affected suite: 1761 passed, 114 skipped.
  • Focused repaired paths: 74 passed.
  • Repository formatter, Ruff, and git diff --check: clean.
  • Exact before/after Studio run: the old second user turn contained a current-date prefix; the repaired turn is byte-exact while the system date remains present.
  • The landed source commit has the same stable patch ID as converged mirror commit 167ebe095.
  • Convergence completed with no major issues on mirror PR #89.

Before and after current-date placement

The full source CI matrix has been retriggered for the repaired head. The prior source head was green across Linux, macOS, Windows, cross-browser, lint, CodeQL, wheel, and startup checks.

@mahiatlinux
mahiatlinux self-requested a review October 5, 2026 05:56

@mahiatlinux mahiatlinux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Ready to merge, all manually checked.

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.

3 participants