Skip to content

Studio: show prompt-processing progress in API monitor - #10834

Open
loject wants to merge 3 commits into
unslothai:mainfrom
loject:main
Open

Studio: show prompt-processing progress in API monitor#10834
loject wants to merge 3 commits into
unslothai:mainfrom
loject:main

Conversation

@loject

@loject loject commented Sep 12, 2026

Copy link
Copy Markdown

Summary

Adds live inference phase reporting to the Studio API monitor.

Running GGUF requests now show:

  • Prompt processing · N% while llama.cpp is processing the input prompt
  • Token generation once decoded output begins

The existing request lifecycle status (running, completed, error, etc.) remains unchanged.

Motivation

For large prompts, the API monitor previously showed only running, so it was impossible to tell whether a request was waiting, processing the prompt, or already generating tokens.

llama.cpp already exposes live prompt_progress information. This change surfaces that existing telemetry in the API monitor instead of inferring the phase from throughput.

Implementation

  • Preserve llama.cpp prompt_progress events in the request-scoped performance callback.
  • Track the current inference sub-phase in ApiMonitorEntry.
  • Store prompt progress values including total, processed, cached tokens, and elapsed prompt-processing time.
  • Calculate prompt-processing percentage as processed / total.
  • Switch the phase to token_generation when the first decoded model output arrives.
  • Expose the new fields through the API monitor response and render them in the Studio UI.

No OpenAI-compatible response or SSE payloads are changed.

Compatibility

Backends that do not expose live prompt progress continue to behave as before and fall back to the generic running state.

The percentage is currently available for llama.cpp/GGUF requests where prompt_progress is provided.

Validation

  • npm run build — passed
  • Tested locally with a Qwen3.8 27B GGUF through the OpenAI-compatible API using OpenCode
  • Verified live transition:
    • Prompt processing · N%
    • Token generation
    • completed request
  • Verified prompt speed remains visible during prompt processing and generation speed appears once decoding begins
image image

@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: 8f2eba9831

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

Comment thread studio/backend/core/inference/api_monitor.py
@loject

loject commented Sep 12, 2026

Copy link
Copy Markdown
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: 691c372f2b

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

)
# Only a real llama.cpp prompt_progress frame means prefill is active.
# Final timing metadata must not move a decoding request back to this phase.
prompt_progress = timings.get("prompt_progress") if isinstance(timings, dict) else None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Forward top-level prompt progress from proxied streams

This only reads prompt_progress nested inside timings, which _report_live_llama_timings synthesizes for backend-owned generators. Raw llama-server proxy paths instead feed frames through _monitor_openai_sse_event and _monitor_openai_chunk (for example, streaming /v1/completions at inference.py:26952-26956), where llama.cpp's prompt_progress remains a top-level sibling and _monitor_openai_chunk forwards only data["timings"]; consequently these GGUF API requests never set running_phase and remain displayed as Running throughout prefill. Pass the top-level progress object into the monitor path as well.

Useful? React with 👍 / 👎.

entry is None
or entry.status != "running"
or entry.kind != "request"
or entry.running_phase == "token_generation"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Allow later tool-loop prefills to replace generation phase

When a server-side tool loop starts a second model turn, this guard drops every new progress frame unless something first clears token_generation. The OpenAI GGUF loop only performs that reset behind _ui_events (inference.py:23079-23080), which is false for ordinary API streams, and the Anthropic server-tool loop has no corresponding reset, so their second and later prefills continue to display Token generation. Reset the phase at every internal tool boundary independently of whether a UI control card is emitted, or otherwise identify a new prefill round before applying this guard.

Useful? React with 👍 / 👎.

@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: 691c372f2b

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

Comment on lines +5815 to +5816
prompt_progress = timings.get("prompt_progress") if isinstance(timings, dict) else None
if monitor_id and isinstance(prompt_progress, dict):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve prompt progress for multi-choice requests

When a supported non-streaming GGUF /v1/chat/completions request uses n > 1, the standard chat handler sets _gguf_perf_callback to None at inference.py:22626-22630 and passes it to every generated choice. Consequently no live sample can reach this new extraction path, so long multi-choice prefills remain displayed as generic Running rather than Prompt processing. Keep request-wide final timing aggregation disabled if necessary, but provide a separate progress callback and reset it between choices.

Useful? React with 👍 / 👎.

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.

1 participant