Skip to content

Studio: show status between tool rounds and while context compaction runs - #16608

Merged
Lyxot merged 8 commits into
unslothai:mainfrom
oobabooga:worktree-compaction-status
Nov 4, 2026
Merged

Lyxot merged 8 commits into
unslothai:mainfrom
oobabooga:worktree-compaction-status

Conversation

@oobabooga

@oobabooga oobabooga commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

After a tool call in a GGUF chat, the reply shows nothing until the model's next pass starts writing. In that gap Studio fits the context window, compacts it if needed, and processes the prompt again, which took 26 to 40 s per tool call in the CPU test below. A user on r/unsloth could not tell whether the model had frozen, the tool had failed, or compaction was running. Their slowdown went away after updating Studio, but the missing status still reproduces on current main, as measured below.

Two things cause the gap:

  • GeneratingIndicator in thread.tsx only renders while the reply is empty, so after the first tool call neither "Working..." nor "Processing prompt N%" comes back. The server keeps sending prefill progress during this time, but nothing displays it.
  • Compaction has no running signal. Its only event, context_truncated, is sent after the fit finishes.

Changes

  • Status between tool calls. NextRoundIndicator renders the existing GeneratingStatus under a finished tool call while the reply is still running, until the next pass streams something. A tool result clears the previous pass's live figures on the client and server, so a stale "Processing prompt 100%" cannot carry over.
  • "Compacting context..." label. The rolling and checkpoint fits now call an on_evict hook at the point where they decide to drop turns, including a manual /compact. That reaches _PrefillProgressSignal.compacting(), and the stall loop sends {"type": "generation_progress", "phase": "compacting"} while the fit is still blocked. Replaying a cut from an earlier request never reaches the hook. This matters because once a chat has compacted, its full history is over budget on every later request, so a token-count check would show the label on every turn.
  • Frontend. The new phase sets a flag in the runtime store. context_truncated, or the next prefill or decode sample, clears it. Both the live stream and the reconnect path (runtime-provider.tsx) handle it.

Notes

  • No new frame type: the label reuses generation_progress, which is only sent on Studio UI streams. A plain streaming /v1/chat/completions request that compacts still gets only chat chunks, context_truncated and [DONE]. Older frontends ignore the unknown phase.
  • The compaction label is llama.cpp only. MLX and managed engines compact through Orchestrator.compact_chat_context and still report only afterwards, but the between-calls status applies to them too.
  • Studio: move the GGUF chat requests and chat compaction out of llama_cpp.py #15596 moves the same llama_cpp.py call sites. Whichever merges second needs to carry the on_compacting argument across.

Screenshots

Main (3d4aa8685f) vs this PR, on a fresh Studio home, third turn of the test below.

While compaction runs:

Compacting context... under the tool call while compaction runs

While the prompt is processed again after compaction:

Processing prompt progress under the tool call after compaction

Testing

Live A/B in the browser: Qwen3-8B Q4_K_M on a CPU-only llama-server, 8192 context, auto-compact on. Three turns, each asking for one python call that prints 1200 items; the third turn compacts. Seconds from the tool result to the first token with no status line shown (measured at 47dab66e99):

Turn main this PR
1 36.4 0.3
2 26.4 0.3
3 (compacts) 39.9 0.3

The 0.3 s left on this PR is between the first token arriving and the run finishing. On the compacting turn the line goes "Working...", "Compacting context..." (about 1 s after the tool result, until context_truncated), "Working...", then "Processing prompt 60% · 16s left". A fourth turn that only replays the earlier cut shows no compaction label.

  • Backend: 16 new cases in test_live_generation_progress.py. They cover the hook in both fit policies, replay staying silent, a new checkpoint past an earlier cut, a forced reset, frame ordering in the stall loop, and dropping a previous pass's unsent figures. The related fit, compaction, tool-loop and refactor-guard suites pass (721 tests).
  • Frontend: 4 new tests in generation-details.test.ts. The typecheck and i18n:check:strict pass. In the full node suite, 14738 pass and 15 fail; the same 15 fail on 3d4aa8685f.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T07:50:37.025507Z 4917fa7 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@oobabooga

Copy link
Copy Markdown
Member 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: 6d983b1563

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

@oobabooga

Copy link
Copy Markdown
Member 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: 47e8858d72

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

@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: e7e0bdc984

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

@Lyxot

Lyxot commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Pushed two small follow-ups on top of e7e0bdc (no behavior change to the feature):

  • 20d0230: trimmed a few comments and docstrings.
  • 4917fa7: the live compaction-flag test in generation-details.test.ts now drives the real chat runtime store (compacting on, cleared by context_truncated, by the next prefill sample, and by the next decode sample) instead of matching the store's source; the pt-BR compactingContext label was still English and is now translated.

Both open review threads were already addressed by 51e8ac6 and e7e0bdc, so I resolved them.

@Lyxot

Lyxot commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

@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: 4917fa75d7

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

@Lyxot

Lyxot commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 4917fa75d7

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

@Lyxot

Lyxot commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Wrap-up for 4917fa75d7:

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Reviewed locally; codex converged and staging CI passed on 4917fa7.

@Lyxot
Lyxot merged commit f2d72cb into unslothai:main Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants