Skip to content

Answer /status the runtime fields a backend double cannot invent - #11076

Merged
danielhanchen merged 3 commits into
mainfrom
fix/status-runtime-fields-double
Sep 16, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
fix/status-runtime-fields-double

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Answer /status the runtime fields a backend double cannot invent

Backend CI has been red on main since af4e98e with three multi-account
tests asserting {"detail":"Failed to get status"}, and Repo tests (CPU, studio) red alongside them. The message names neither the field nor the cause.

af4e98e added four reasoning fields to _InferenceRuntimeFields. They are
not Optional, which is right: LlamaCppBackend.__init__ sets _reasoning_budget = -1 and _reasoning_budget_message = "", so the real backend never answers
None for them. _llama_runtime_fields mirrors every field in that model off the
backend, public name first and the _name slot as a fallback, and the doubles
in these tests answer None for anything nobody set. None is not a value those
four accept, so /status raised ValidationError and the route returned 500.

The PR is correct; the doubles were not.

What changed

FakeLlamaCppBackend now carries the runtime surface /status mirrors, at the
values LlamaCppBackend.__init__ gives them. The same block was being
re-declared by hand in the per-test fakes, which is exactly what the shared
double exists to end.

Fields the real backend holds only as _name are declared under that name
here, so the double claims nothing production cannot read. The blanket
__getattr__ that several fakes carry defeated that fallback: answering None
for the public name hides the private slot that has the value. It lives on the
shared double now and defers to the private sibling before answering None, so
one contract covers every double instead of each one re-deriving it.

Coverage

The existing canary drives /chat/completions, which never reaches this. A
second one builds the /status runtime payload from the bare double and
validates it, failing with the offending field in the message.

Mutation-tested: removing the four reasoning fields reproduces af4e98e and
the canary names all four; restoring the blanket None __getattr__ names the
seven private-only fields.

`Backend CI` has been red on main since af4e98e with three multi-account
tests asserting `{"detail":"Failed to get status"}`, and `Repo tests (CPU,
studio)` red alongside them. The message names neither the field nor the cause.

af4e98e added four reasoning fields to `_InferenceRuntimeFields`. They are
not Optional, which is right: `LlamaCppBackend.__init__` sets `_reasoning_budget
= -1` and `_reasoning_budget_message = ""`, so the real backend never answers
None for them. `_llama_runtime_fields` mirrors every field in that model off the
backend, public name first and the `_name` slot as a fallback, and the doubles
in these tests answer None for anything nobody set. None is not a value those
four accept, so /status raised ValidationError and the route returned 500.

The PR is correct; the doubles were not.

## What changed

`FakeLlamaCppBackend` now carries the runtime surface /status mirrors, at the
values `LlamaCppBackend.__init__` gives them. The same block was being
re-declared by hand in the per-test fakes, which is exactly what the shared
double exists to end.

Fields the real backend holds only as `_name` are declared under that name
here, so the double claims nothing production cannot read. The blanket
`__getattr__` that several fakes carry defeated that fallback: answering None
for the public name hides the private slot that has the value. It lives on the
shared double now and defers to the private sibling before answering None, so
one contract covers every double instead of each one re-deriving it.

## Coverage

The existing canary drives /chat/completions, which never reaches this. A
second one builds the /status runtime payload from the bare double and
validates it, failing with the offending field in the message.

Mutation-tested: removing the four reasoning fields reproduces af4e98e and
the canary names all four; restoring the blanket None `__getattr__` names the
seven private-only fields.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 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-09-16T05:29:44.829931Z af3b980 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.

@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: 3b03526879

ℹ️ 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 +75 to +80
if not name.startswith("_"):
try:
return object.__getattribute__(self, f"_{name}")
except AttributeError:
pass
return 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.

P1 Badge Preserve fallback semantics for absent backend capabilities

Returning None for every missing attribute prevents callers' getattr(..., default) fallbacks from running. For example, _ToolGguf in test_video_chat_completions_behaviour.py sets supports_tools = True but omits supports_tool_passthrough; the route intentionally defaults that capability to supports_tools, whereas this method now returns None, causing the request to be rejected as lacking tool passthrough before reaching the guided-decoding media guard. Consequently, the existing test at lines 491–509 receives the wrong error and fails. Restrict this private-name fallback to the runtime fields or raise AttributeError when no private sibling exists.

Useful? React with 👍 / 👎.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 3b03526879

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

A blanket __getattr__ on the shared double took away callers' getattr(...,
default) fallbacks: the route defaults supports_tool_passthrough to
supports_tools, and None is not absent, so a double that set supports_tools and
omitted the passthrough flag had its request rejected before reaching the guard
the test was asserting on.

The fallback now covers only the names /status mirrors, taken from
_InferenceRuntimeFields rather than listed, and anything else raises
AttributeError as before. Within that set the private slot still comes first,
which is what the response model needs for the fields the real backend holds
only as _name.

Attributes the status route reads straight off the backend rather than through
the model-field loop are declared too, at the real backend's initial values:
requested_spec_mode, requested_parallel_slots, effective_parallel_slots,
requested_n_ctx, requested_extra_args, spec_fallback_reason and
spec_drafter_kind. An absent one is an AttributeError before the drift check
can name it.

Mutations: dropping the four reasoning fields reproduces af4e98e and the
canary names all four; answering None instead of the private slot names the
seven private-only fields; restoring the blanket fallback fails the video
chat-completions tests again.
@danielhanchen

Copy link
Copy Markdown
Member Author

Agreed and fixed in af3b980d2. This was a regression I introduced, not a pre-existing one: moving the blanket __getattr__ onto the shared double took the fallback away from every caller that passes a default, and supports_tool_passthrough defaulting to supports_tools is exactly that shape. None is not absent.

The fallback now covers only the names /status mirrors, taken from _InferenceRuntimeFields rather than listed out, so an Optional field added there needs no edit here and a required one is named by the canary. Everything else raises AttributeError as before, and getattr(backend, name, default) keeps its default. Within the runtime set the private slot still comes first, which is what the response model needs for the fields the real backend holds only as _name.

Removing the blanket fallback also exposed the attributes the status route reads straight off the backend rather than through the model-field loop, where an absent one is an AttributeError before the drift check can name it. Those are declared now at the real backend's initial values: requested_spec_mode, requested_parallel_slots, effective_parallel_slots, requested_n_ctx, requested_extra_args, spec_fallback_reason, spec_drafter_kind.

Mutations: dropping the four reasoning fields reproduces af4e98e2f and the canary names all four; answering None instead of the private slot names the seven private-only fields; restoring the blanket fallback fails the video chat-completions tests again, which is your case.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: af3b980d23

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

danielhanchen added a commit to Datta0/unsloth-staging-3 that referenced this pull request Sep 16, 2026
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 16, 2026
@danielhanchen
danielhanchen merged commit b5f26f6 into main Sep 16, 2026
37 of 43 checks passed
@danielhanchen
danielhanchen deleted the fix/status-runtime-fields-double branch September 16, 2026 07:48
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…lothai#11076)

`Backend CI` has been red on main since the reasoning-budget controls landed, with three
multi-account tests answering `{"detail":"Failed to get status"}`, a message naming neither
the field nor the cause.

Four reasoning fields were added to `_InferenceRuntimeFields` and they are not Optional,
which is right: `LlamaCppBackend.__init__` sets `_reasoning_budget = -1` and
`_reasoning_budget_message = ""`, so the real backend never answers None for them.
`_llama_runtime_fields` mirrors every field in that model off the backend, and the test
doubles answered None for anything nobody set, so /status raised ValidationError and the
route returned 500. The PR that added the fields is correct; the doubles were not.

## What changed

`FakeLlamaCppBackend` carries the runtime surface /status mirrors, at the values
`LlamaCppBackend.__init__` gives them. The same block was being re-declared by hand in the
per-test fakes, which is what the shared double exists to end. Fields the real backend holds
only as `_name` are declared under that name, so the double claims nothing production cannot
read.

The blanket `__getattr__` several fakes carried defeated that fallback: answering None for
the public name hides the private slot that has the value. It lives on the shared double now,
scoped to the names /status mirrors and taken from the model rather than listed. Everything
else raises `AttributeError` as before, so `getattr(backend, name, default)` keeps its
default; a blanket version broke `supports_tool_passthrough` defaulting to `supports_tools`,
which Codex caught during review.

Attributes the status route reads straight off the backend rather than through the model-field
loop are declared too, at the real backend's initial values.

## Coverage

The existing canary drives /chat/completions and never reaches this. A second one builds the
/status runtime payload from the bare double and validates it, failing with the offending
field in the message.

Mutation-tested: removing the four reasoning fields reproduces the original break and the
canary names all four; answering None instead of the private slot names the seven
private-only fields; restoring the blanket fallback fails the video chat-completions tests.

All nine files that use the double pass, 110 tests. `(Python 3.13, rest)` is green here,
against red on main.

The two remaining red jobs are inherited from main and fixed elsewhere: the studio shard by
unslothai#11065, and the python shard's kaggle launcher flake by unslothai#11085.
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