Repository navigation
Studio: keep a local model's built-in system prompt when the date setting is on - #12382
Conversation
NilayYadav
left a comment
There was a problem hiding this comment.
Codex review coverage
Mirror: NilayYadav#247 (base = merge base 6f70f901, head = this PR).
Reviewed commit: 47e355e3cbd73da2db83d1fec6611de60686c9d9 (the PR as submitted). One round, one item.
| # | Item | Verdict |
|---|---|---|
| 1 | P2 studio/backend/routes/inference.py:6385 "Refresh stale date notes instead of accepting them": a first user message that already starts with [Current date: ...] is left as is |
False positive. The note is added server side per request and is never stored or sent back by the Studio client, and API key callers are gated before this point, so a stale note only reaches this line if a user types one by hand at the start of their own message. |
Not covered by this round:
- The follow-up commit
03773846bapushed during review (keeps the date note when context compaction evicts the first turn). It was verified by hand on Modal and with the backend tests, but has not had its own Codex pass yet. - Runtime behaviour in general: the round is a static read of the diff. The by-hand reproduction (Qwen2.5 GGUF on Modal, main vs PR) is in the evidence comment.
NilayYadav
left a comment
There was a problem hiding this comment.
Review + reproduction evidence
Pinned review: 03773846ba (PR head 47e355e3 plus one fix pushed during review: keep the date note when context compaction evicts the first turn).
I reproduced the default chat (no system prompt, "Tell the model today's date" on) on fresh upstream main with Qwen2.5-0.5B-Instruct GGUF Q4_K_M, Studio installed with install.sh --local on Modal (Linux, CPU), Chromium 1440x900, Temperature 0 in Run settings:
- main
e477badf: "Who created you?" -> "I am a computer program created by Microsoft." The date-only system turn replaces Qwen's built-in "You are Qwen, created by Alibaba Cloud" prompt. Context meter 80 / 4.1k. - PR on main (
e477badf+ this branch): "I am a text-based AI created by Alibaba Cloud, and I was created by Alibaba Cloud." The model still answers today's date (2026-10-01). Context meter 106 / 4.1k.
Same flow through the API the web app calls (temperature 0, seed 0):
| case | main | PR |
|---|---|---|
| no system prompt, "Who created you?" | Microsoft, 38 prompt tokens | Qwen / Alibaba Cloud, 54 |
| no system prompt, "today's date?" | 2026-09-30 | 2026-09-30 |
| count_tokens vs completion prompt | 38 / 38 | 54 / 54 |
| system prompt set | Microsoft, 44 | identical, 44 |
| date setting off | Qwen, 38, date 2023-04-01 | identical |
| sk-unsloth API key | Qwen, 38, date 2023-04-01 | identical |
Fix pushed during review (03773846ba): the date now rides on the first user turn, which context compaction evicts first. On the PR as submitted, a 1024-token GGUF chat with context_overflow: truncate_oldest (what the web app sends) answered "2023-01-01" to "What is today's date?" after 12 long turns on the same day; main answered "2026-09-30". With the fix the note moves to the oldest kept user turn and the same flow answers "2026-09-30" (long and short first message both checked). Regression test: test_an_evicted_first_turn_hands_its_date_note_to_the_oldest_kept_turn.
- Midnight: a thread started at 23:42 UTC and continued at 00:01 UTC answered 2026-10-01; the first message of an older empty thread got exactly one date note (64 tokens, same as a fresh chat).
- Backend tests on Modal: the PR's four new or changed tests fail on main and pass on the branch (DISCRIMINATING); 1499 other tests unchanged.
- Not on a hot path: one extra regex match per request, no change to prompt cache reuse between turns of a thread.
Conclusion: the bug is real on main and fixed by this PR; with the compaction fix above I found no remaining blocking issue. Not run here: Windows and macOS by hand, MLX, and templates whose default system prompt carries its own clock date (Mistral Small 3.x, Granite 3.x), which will now show both that date and the Studio note.
NilayYadav
left a comment
There was a problem hiding this comment.
Codex review coverage, round 2
Mirror: NilayYadav#247. Reviewed commit: 03773846ba (the compaction fix).
| # | Item | Verdict |
|---|---|---|
| 1 | P2 studio/backend/core/inference/llama_cpp.py:417 "Recount after transferring the date note": the note was added after the fit measured the prompt, so prompt_tokens_after was stale and a tight fit could end up over target |
Genuine, fixed in edf23f8c9c: the fit is recounted after the note moves, prompt_tokens_after is updated, and the note is put back if it would push the prompt past the target. Tests: test_an_evicted_first_turn_hands_its_date_note_to_the_oldest_kept_turn, test_a_date_note_that_would_overflow_the_fit_is_not_moved. |
Not covered: edf23f8c9c itself has not had a Codex pass (single round requested). ce291e35 is the pre-commit formatting commit only.
|
Review record for #12382, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#276. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. Round 1: reviewed mirror
|

With "Tell the model today's date" on (the default) and no system prompt, local chats sent a system turn holding only the date. Chat templates skip their own default system prompt when a system turn exists, so Qwen2.5, Mistral Small, Magistral, Granite and similar models silently lost it. Qwen2.5 stopped knowing it was Qwen, and Magistral lost its reasoning format instruction.
Now, when there is no system prompt, the date leads the chat's first message as "[Current date: YYYY-MM-DD]", the note Studio already adds when a chat crosses midnight. The template's default renders again, the model still knows the date, and later turns keep reusing the prompt cache. Chats with a system prompt, API key callers and external providers are unchanged.
Studio UI regression check
Base
6f70f901evs headda53ab434. Functional: NO_REGRESSION, UI coverage 64%, 10 visual change(s), 6 text-only change(s). Only steps whose screenshots differ are shown.The settings and load pairs differ only in the context meter on an empty chat: base priced the date-only system turn (
4 / 2.0k), head shows- / 2.0k, as Studio already does with the date setting off. The compaction chat pairs differ in the model's reply text.inference_settings/load_2048: | reproduced on confirm (VISUAL_DIFF)

inference_settings/open_settings: | reproduced on confirm (VISUAL_DIFF)

inference_settings/reapply_4096: | reproduced on confirm (VISUAL_DIFF)

inference_settings/custom_sampling: | reproduced on confirm (VISUAL_DIFF)

inference_settings/save_preset: | reproduced on confirm (VISUAL_DIFF)

parallel/load_parallel: | reproduced on confirm (VISUAL_DIFF)

compaction/load_2048: | reproduced on confirm (VISUAL_DIFF)

compaction/ui_settings: | reproduced on confirm (VISUAL_DIFF)

compaction/ui_compacted: masks cover 281% of the shot | reproduced on confirm (VISUAL_DIFF)

compaction/ui_answer_after: masks cover 282% of the shot | reproduced on confirm (VISUAL_DIFF)

Facts:
mentions_flappy: {'before': False, 'after': True}compaction/seed_historycompaction/api_compactscompaction/over_window_compactscompaction/api_refuses_when_offcompaction/api_short_not_compactedcrawl/r_projects