Skip to content

Studio: stop /api/inference/status raising on every loaded GGUF - #8074

Merged
danielhanchen merged 1 commit into
mainfrom
fix/status-chat-template-override
Aug 7, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/status-chat-template-override

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

/api/inference/status has returned 500 for every loaded GGUF since #8007 landed on main.

TypeError: models.inference.InferenceStatusResponse() got multiple values
           for keyword argument 'chat_template_override'
  studio/backend/routes/inference.py:8032, in get_status

What happens

_llama_runtime_fields() builds its dict by comprehension over _InferenceRuntimeFields.model_fields, so it returns one entry per field on that model. get_status splats that dict and passes the same keyword explicitly:

**_llama_runtime_fields(llama_backend),
chat_template_override = _reported_chat_template_override,

#8007 added chat_template_override to _InferenceRuntimeFields. From that commit on, the key is in the dict and in the argument list, and Python raises before the response is constructed.

The sibling field was handled correctly: chat_template_override_reason is pinned to None inside fields.update(...). That pattern does not work here, because the collision does not depend on the values. The key has to be absent from the dict, not None.

The other splat site (line 3706) does not name any runtime field explicitly, so it was never affected.

User-visible effect

The chat UI polls status from first paint. With status failing it shows Failed to get status and two Failed to refresh models toasts, and the model picker renders with no models in it.

That is also what took studio-windows-ui-smoke red on main. The assertion that fired reads

model picker text was identical for qwen + llama queries -- typeahead may not be filtering

which is a downstream symptom: with an empty picker, both queries produce the same text. Typeahead filtering is fine. The screenshots in that run's artifacts show the empty picker with both error toasts.

The fix

Assign into the dict, then splat once, so the reported-override logic above still wins:

_runtime_fields = _llama_runtime_fields(llama_backend)
_runtime_fields["chat_template_override"] = _reported_chat_template_override

Test

tests/studio/test_inference_status_runtime_fields_contract.py parses both modules and asserts that no call splatting **_llama_runtime_fields(...) also names one of _InferenceRuntimeFields's fields as an explicit keyword. It is source level because importing the routes module pulls in the whole studio stack, and this is a call-shape property AST can see directly.

Verified in both directions: it fails on the parent commit, reporting line 8032: ['chat_template_override'], and passes with the fix.

It guards the general case rather than this one field, so the next field added to _InferenceRuntimeFields cannot reintroduce the same collision at either splat site.

_llama_runtime_fields() returns one entry per field on _InferenceRuntimeFields
and get_status splats it. #8007 added chat_template_override to that model while
get_status was already passing the same keyword explicitly, so the call raised
TypeError: got multiple values for keyword argument 'chat_template_override'.

Every status poll with a GGUF loaded returned 500. The chat UI showed
'Failed to get status' plus 'Failed to refresh models', and the model picker
rendered empty, which is what took studio-windows-ui-smoke red on main.

Assign into the dict before splatting. Pinning the duplicate to None would not
help: two values for one keyword is a TypeError whatever the values are.

Adds a source-level contract so any future field added to _InferenceRuntimeFields
cannot collide with an explicit keyword at a splat site.

@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: cf9c777ef1

ℹ️ 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 +60 to +62
and isinstance(kw.value, ast.Call)
and isinstance(kw.value.func, ast.Name)
and kw.value.func.id == SPLAT_HELPER

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 Track the indirect runtime-field splat

The matcher only recognizes **_llama_runtime_fields(...), but the fixed status path now assigns that result to _runtime_fields and splats the variable. Consequently, adding a runtime field already passed explicitly by InferenceStatusResponse—for example spec_fallback_reason—would make /status raise the same duplicate-keyword TypeError while this regression test still passes because it examines only the separate load-response call. Extend the analysis to follow the local assignment or otherwise include the status constructor.

Useful? React with 👍 / 👎.

@danielhanchen
danielhanchen merged commit e99651b into main Aug 7, 2026
41 of 46 checks passed
@danielhanchen
danielhanchen deleted the fix/status-chat-template-override branch August 7, 2026 03:18
shimmyshimmer pushed a commit that referenced this pull request Aug 7, 2026
#8074 fixed the duplicate-keyword TypeError and added a source-level contract
that no runtime field is also passed as an explicit keyword at a splat site.
That contract cannot see the value, so the assignment it relies on can be
dropped without failing it.

Removing `_runtime_fields["chat_template_override"] = ...` leaves the contract
test green while /status starts reporting the raw backend value. An
auto-applied bundled family template then reads as a user override, and the
frontend re-sends it for the next, unrelated model.

Adds two cases to the existing loaded-GGUF status tests: the user override is
echoed, and an auto-applied template still reports None.
danielhanchen pushed a commit that referenced this pull request Aug 7, 2026
test_status_path scans the InferenceStatusResponse construction for a
literal _llama_runtime_fields(llama_backend). #8074 had to bind that call
to _runtime_fields one line above the construction so it could overwrite
chat_template_override before passing it on, which moved the call out of
the block the test reads. The route still applies the runtime fields, so
the test has been red on main since that merge and on every PR branched
from it.

Accept either shape, and only count the splat when the dict is the
helper's, so removing the fields from the route still fails the test.

Co-authored-by: Unsloth <[email protected]>
danielhanchen added a commit that referenced this pull request Aug 7, 2026
* Studio: pin the /status chat template echo behaviour

#8074 fixed the duplicate-keyword TypeError and added a source-level contract
that no runtime field is also passed as an explicit keyword at a splat site.
That contract cannot see the value, so the assignment it relies on can be
dropped without failing it.

Removing `_runtime_fields["chat_template_override"] = ...` leaves the contract
test green while /status starts reporting the raw backend value. An
auto-applied bundled family template then reads as a user override, and the
frontend re-sends it for the next, unrelated model.

Adds two cases to the existing loaded-GGUF status tests: the user override is
echoed, and an auto-applied template still reports None.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: shimmyshimmer <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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