Repository navigation
fix(studio): support preserve thinking for llama.cpp connections - #11706
Conversation
…k fail (unslothai#11749) * Chat UI driver: wait for the Recents thread to load, and let the check fail The Recents step clicked the first sidebar row, slept 500 ms and read the turns once. Opening a chat runs a history loader that awaits the thread, its active runs, its messages and its research state in sequence before anything renders. On the Windows lane, which runs two Studios and two browsers on one runner, that took longer than 500 ms in 15 of 57 Windows runs on 2026-09-23, so the read found turns_text=''. The server logs of those runs show the messages request returning 200 at or after the moment the driver navigated away; the thread was loading, not empty. It never failed a job because the soft_fail sat inside the try whose except Exception was meant for click errors. In STRICT mode the AssertionError was caught, logged as "recent-thread click 0 failed", and the step passed. The FAIL line that shows up in failing runs of unslothai#11706 and unslothai#11731 is this swallowed message; those jobs failed on other steps. The step now: - picks the Recents row whose title is a prompt this run sent, falling back to the listed order, since the most recent row need not be ours - waits up to 20 s for the URL to name that thread and for a user turn to contain one of our prompts, instead of reading once after 500 ms - raises outside the click retry, so a thread that opens without our turns fails the run in STRICT mode tests/studio/test_chat_ui_recents_step.py runs the helper in Chromium against a page whose thread renders after 1.5 s (passes), one that never shows our prompts (fails), and one with an unrelated chat above ours (checks ours), plus source checks for the sleep and the swallowing except. * Chat UI driver: keep looking for this run's chat when Recents titles are generated With auto-titling no Recents title equals a prompt this run sent, so the fallback tried the newest row, stopped there, and failed after 20 s when that row was someone else's chat, even with ours next in the list. A row titled with our prompt is ours and must still show our turns. A row reached only by the fallback is now judged when it loads: our prompt passes, someone else's turns or none moves on to the next row, within a 60 s budget. * Chat UI driver: do not judge a Recents row from the previous thread's turns The chat keeps one runtime while the next thread loads, so the previous thread's turns stay on screen for a while after the URL changes. Judging a fallback row on those could reject our chat as someone else's, or, with our thread already open, pass a different chat on our stale turns. Snapshot the user turns and open thread before each click, and count turns identical to that snapshot as not loaded yet unless the clicked row is the thread that was already open. The fixture can now keep stale turns on screen until the next thread loads, as the app does. * Chat UI driver: reopen this run's chat by id in the Recents step The prompts are fixed, so on a reused Studio home an earlier run's chat can carry the same title and turns, and the title match would open it and pass without ever reopening this run's chat. Read this run's chat id while it is open, from ?thread= or the active Recents row, and have the Recents step open exactly that row and require our turns in it. The title search stays as the fallback when no id is on the page. A test evaluates the driver's capture expression itself, since it only runs there. * Chat UI driver: find this run's chat by id anywhere in the sidebar Pinned and project chats use the same row testid as Recents, so on a reused home this run's chat can sit past the first 20 rows the title search reads. Locate the captured id directly across every row, and walk candidate rows rather than indices so a strict row, known to be ours by id or title, still has to show our turns. * Recents step tests: skip when another file left a Playwright stand-in Backend CI's CPU studio shard has no Playwright, and test_heavy_thread_measurement_integrity.py installs a stand-in playwright.sync_api whose every name raises RuntimeError. importorskip then succeeds, and all 12 browser tests errored in that job. A stand-in that raises now skips, like a missing package.
# Conflicts: # studio/frontend/src/features/chat/shared-composer.tsx
… llama.cpp kwarg merge The reprompt path only builds a stalled assistant message after a provider-hosted tool ran, and reasoning replay is only enabled for llama.cpp connections, which host no tools. Adds coverage for reasoning-only turns whose tool calls are all dropped server cards, and for preserve_thinking and enable_thinking sharing chat_template_kwargs. Tightens the related comments.
|
Pushed a few small follow-ups on top of this PR:
|
|
Codex review on the staging copy converged on head Staging CI on the same head (Lyxot#86): 59 passed, 4 skipped, 1 failed. The failure is |
Lyxot
left a comment
There was a problem hiding this comment.
LGTM. Codex converged and staging CI passed on this head; also verified against latest main locally.
…k fail (unslothai#11749) * Chat UI driver: wait for the Recents thread to load, and let the check fail The Recents step clicked the first sidebar row, slept 500 ms and read the turns once. Opening a chat runs a history loader that awaits the thread, its active runs, its messages and its research state in sequence before anything renders. On the Windows lane, which runs two Studios and two browsers on one runner, that took longer than 500 ms in 15 of 57 Windows runs on 2026-09-23, so the read found turns_text=''. The server logs of those runs show the messages request returning 200 at or after the moment the driver navigated away; the thread was loading, not empty. It never failed a job because the soft_fail sat inside the try whose except Exception was meant for click errors. In STRICT mode the AssertionError was caught, logged as "recent-thread click 0 failed", and the step passed. The FAIL line that shows up in failing runs of unslothai#11706 and unslothai#11731 is this swallowed message; those jobs failed on other steps. The step now: - picks the Recents row whose title is a prompt this run sent, falling back to the listed order, since the most recent row need not be ours - waits up to 20 s for the URL to name that thread and for a user turn to contain one of our prompts, instead of reading once after 500 ms - raises outside the click retry, so a thread that opens without our turns fails the run in STRICT mode tests/studio/test_chat_ui_recents_step.py runs the helper in Chromium against a page whose thread renders after 1.5 s (passes), one that never shows our prompts (fails), and one with an unrelated chat above ours (checks ours), plus source checks for the sleep and the swallowing except. * Chat UI driver: keep looking for this run's chat when Recents titles are generated With auto-titling no Recents title equals a prompt this run sent, so the fallback tried the newest row, stopped there, and failed after 20 s when that row was someone else's chat, even with ours next in the list. A row titled with our prompt is ours and must still show our turns. A row reached only by the fallback is now judged when it loads: our prompt passes, someone else's turns or none moves on to the next row, within a 60 s budget. * Chat UI driver: do not judge a Recents row from the previous thread's turns The chat keeps one runtime while the next thread loads, so the previous thread's turns stay on screen for a while after the URL changes. Judging a fallback row on those could reject our chat as someone else's, or, with our thread already open, pass a different chat on our stale turns. Snapshot the user turns and open thread before each click, and count turns identical to that snapshot as not loaded yet unless the clicked row is the thread that was already open. The fixture can now keep stale turns on screen until the next thread loads, as the app does. * Chat UI driver: reopen this run's chat by id in the Recents step The prompts are fixed, so on a reused Studio home an earlier run's chat can carry the same title and turns, and the title match would open it and pass without ever reopening this run's chat. Read this run's chat id while it is open, from ?thread= or the active Recents row, and have the Recents step open exactly that row and require our turns in it. The title search stays as the fallback when no id is on the page. A test evaluates the driver's capture expression itself, since it only runs there. * Chat UI driver: find this run's chat by id anywhere in the sidebar Pinned and project chats use the same row testid as Recents, so on a reused home this run's chat can sit past the first 20 rows the title search reads. Locate the captured id directly across every row, and walk candidate rows rather than indices so a strict row, known to be ours by id or title, still has to show our turns. * Recents step tests: skip when another file left a Playwright stand-in Backend CI's CPU studio shard has no Playwright, and test_heavy_thread_measurement_integrity.py installs a stand-in playwright.sync_api whose every name raises RuntimeError. importorskip then succeeds, and all 12 browser tests errored in that job. A stand-in that raises now skips, like a missing package.
…lothai#11706) Show the Preserve thinking control on llama.cpp connections, forward chat_template_kwargs.preserve_thinking alongside enable_thinking, and replay earlier assistant reasoning (frontend history, backend history conversion, and Studio tool-loop rounds) when enabled. Other providers and local models are unchanged.
Connections hides Preserve thinking and omits prior reasoning when talking to an external llama-server. This adds the existing control to the llama.cpp connection preset, forwards
chat_template_kwargs.preserve_thinking, and replays previous assistant reasoning when enabled.Reasoning survives backend history conversion, reasoning-only replies, and Studio tool-loop follow-ups. The control works without advertising an unsupported thinking-generation toggle. Other provider types retain their existing behavior; the selected llama.cpp model still needs a template that supports
preserve_thinking.Validation
The live run exercised the feature before rebasing onto current main; the automated checks above were rerun after rebasing. Live testing used the source browser UI, not a rebuilt Desktop installer. Studio's built-in tool loop is covered by regression tests; the live tool test used a deterministic client-side function.