Repository navigation
provider: Nemotron Super serves JSON output, tools and WebP/GIF/BMP with images and video - #1922
Merged
Merged
Conversation
…me refusals Image and video requests to Nemotron 3.5 Super now take the same request plan as text (NemotronSuperRequestPlan). The media prompt renders the plan's messages (with the tool-choice and response-format instructions), its declared tools and its controls; the bridge runs the plan's bridgeRequest; NemotronSuperLocalOutput already validated tool calls and JSON answers for both routes. So response_format (json_object, json_schema), tools, tool_choice, parallel_tool_calls and min_p: 0 are served with media, and the media route refuses exactly the controls the text route refuses. The production rejection ledger shows 86 % of the Super media refusals were response_format with media. - NemotronSuperLocalImageBinding.runEncoded takes the plan; parseEncodedBody becomes encodedBody(_:), which keeps only the media rules. Owner.localImagePrompt/localVideoPrompt render from the plan. - NemotronSuperPromptContract.imagePrompt/videoPrompt take declared tools and controls, as render does for text. - Super advertises native_media_tools, so the coordinator routes forced tool choice with media and media in tool results to new Macs. - Refusals name their cause by failure code (SuperHTTPErrors.map): invalid_request for request controls and context overflow, unsupported_media (new MediaIngest.MediaError.unsupportedMedia) for media the route does not serve, media_too_large for limits, and invalid_media only for corrupt media. - Remove the unused NemotronSuperLocalLoad.localImagePrompt wrapper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The coordinator already fetches and inlines WebP, GIF and BMP images, and
every Super Mac refused them. NemotronSuperImageDecode now sniffs their
signatures and decodes frame 0 with ImageIO (NemotronSuperImageIORaster)
to the same RGB8 input as PNG and JPEG, then the same orientation writer
and normalizeRGB.
- The header (ImageIO type must match the signature; frame-0 size from
header properties) is read before any raster, so the byte, pixel and
resize-workspace limits apply unchanged. Other ImageIO types (TIFF,
HEIC, ...) stay unsupportedEncoding.
- WebP EXIF and XMP chunks resolve orientation with the existing Pillow
rules (NemotronSuperImageOrientation).
- Samples are read without drawing for 8-bit gray, gray-alpha, RGB, RGBA
(both 32-bit byte orders) and RGB palettes; alpha is dropped as
Pillow's convert("RGB") does, premultiplied samples are divided first.
Other RGB layouts are drawn once in the image's own colour space.
- The media route admits data:image/webp, image/gif and image/bmp labels.
- Tests: lossless WebP (cwebp from png-rgb8.png) matches Pillow's
reference raster; WebP EXIF orientation; GIF and BMP built in the test
decode to their source raster; every sample layout; the live HTTP
format test serves each format.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…bP overrun case CI 42545456472 found two expectations the named refusals change (encodedVideoPlan over the context now throws contextExceeded) and a WebP metadata case whose chunk header did not fit, so it never reached the overrun check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sult media tests - SuperHTTPErrors.map: the spent decode allowance maps inside the video switch (retryable requestRejected); the unreachable pre-check is gone. - WebP EXIF/XMP are read only from an extended-format file (VP8X first) under its EXIF (0x08) / XMP (0x04) flag, as libwebp's ParseVP8XChunks stores them for Pillow. NemotronSuperImageIOContainer moves to its own file, like the PNG and JPEG containers. - A rendered placeholder (<image>/<video> in message text, a tool declaration or a response-format instruction) is invalid_request, as literal <image> is on the text route; the comment now says what the video and image checks cover. - The model ID is checked once by the plan and once by the engine guard; the binding and owner prompt checks are gone. - Tests: media in a tool result on the HTTP and coordinator paths (<tool_response> then <image>), tool_choice none with media, parallel_tool_calls false with two calls (422), prompt order (tools, format instruction, media slot), coordinator invalid JSON (422, generation_failure), hostile GIF headers (65535 x 65535 screen, frame larger than its screen, 64 frames), a transparent GIF and a lossy WebP with alpha. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI 42549599724 refused the build: `call` redeclared the script array of the same test, and the inline literal could not be typed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A coordinator can require this per-model capability before it sends a Nemotron Super request with image or video and a JSON response_format or non-empty tools, so Macs without the media route's plan reuse do not receive them during rollout. It is advertised the way native_media_tools is: ModelInfo carries native_media_controls (omitted when nil), the scan sets it from ToolChoiceEnforcementPolicy.advertisesNativeMediaControls (the Super serving identity with image input and a template that renders), and a cluster member drops it with is_vision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
davidtai
marked this pull request as ready for review
November 9, 2026 16:39
jonathan308
reviewed
Nov 9, 2026
jonathan308
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed for 0.10.12 (moved out of 0.10.11 by the owner). Changes needed before merge; the code itself looks right.
Good: it merges cleanly into today's dev and the release branch. The merge builds, the CPU suites pass, and 4 deliberate mutants were each caught. No coordinator change is needed for it to serve. "Darkbloom sandbox integrity" is a missing provenance receipt (infra), not a test failure.
Before merging:
- The real-model check from the PR's own test plan: one image request with
response_format: json_objectand one withtools, on a Super Mac against the pinned checkpoint. It hasn't run anywhere yet. - #1871's fragment contradicts this PR.
changelog.d/nemotron-video-decode-allowance-retryable.md:4says the video's own limits are stillinvalid_media400. With this PR they're 413 (media_too_large) or 415 (unsupported_media). Clients will see 400 → 413/415, so say so in the fragment. - The docs claim more than production does.
docs/reference/protocol-messages.md:373("The coordinator requires it … during rollout") anddocs/architecture/inference.md:825-827are true only with platform #729, which is on platformdevonly. Name #729 and pin the link, as thenative_media_toolsrow does. - #1921 overlaps this PR in 3 files (
docs/provider/direct-mode.md,NemotronSuperLocalImageHTTP.swift,NemotronSuperVideoBindingTests.swift), aroundSuperHTTPErrors.map. Whichever merges second needs the conflict resolved: #1921's reason inside this PR's video switch.
Full write-up: the reviewer's notes are available on request.
This was referenced Nov 10, 2026
jonathan308
added a commit
that referenced
this pull request
Nov 10, 2026
… bytes #1922 admitted five data-URI labels, so a JPEG sent as `data:image/jpg` (or `image/JPEG`, `image/pjpeg`) was still refused although NemotronSuperImageDecode already sniffs the format from the bytes, as the reference loader and the coordinator's fetch do. `NemotronSuperLocalImageBinding.isInlineBase64Image` admits `data:image/<subtype>[;attribute=value]...;base64,`, the type in any case (RFC 2045), a header of at most 256 bytes. A remote or file URL, percent encoding, a non-image label, `DATA:` and `;BASE64` stay `unsupported_media` (`data:` and `;base64` are matched as the coordinator and MediaIngest.dataFromDataURI read them). A TIFF, HEIC or SVG under an image label is refused by the decoder, also `unsupported_media`. Docs (image-format reference, inference, direct mode) and #1922's WebP/GIF/BMP fragment say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308
added a commit
that referenced
this pull request
Nov 10, 2026
… becomes 413/415 #1922's review items 2 and 3: - protocol-messages.md and inference.md said the coordinator requires `native_media_controls` during rollout. Only a coordinator with platform #729 (on platform dev, not yet in production) does; without it such requests reach any Super Mac and a Mac without this build refuses them. Both now name #729 with a pinned link to `BuildNeedsNativeMediaControls`. - #1871's fragment shipped in 0.10.11 saying a video's own limits stay `invalid_media` (400). That fragment is removed by the 0.10.12 release branch's master merge, so editing it would conflict; #1922's own fragment now says those limits, like the rest, were `invalid_media` (400) before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 10, 2026
This was referenced Nov 12, 2026
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Nemotron 3.5 Super's media route now serves image and video requests that carry
response_format,tools,tool_choice,parallel_tool_callsormin_p: 0, as the text route does. It also decodes WebP, GIF (frame 0) and BMP images. Media refusals now name their cause by failure code instead ofinvalid_mediafor everything.The production rejection ledger (8.8 h, 2,093 Super media refusals) shows 86.3 % were
response_format(JSON output) with media and 1.5 % tools with media. Every Super Mac refused them with HTTP 400invalid media input.What changes
Commit 1, structured output, tools and settings with media (rulings R1 and the refusal names):
NemotronSuperRequestPlan). The media prompt renders the plan's messages (with the tool-choice and response-format instructions), its declared tools and its controls (imagePromptTokens,videoPrompt). The bridge runs the plan'sbridgeRequest.NemotronSuperLocalOutputalready parsed, withheld and validated tool calls and JSON answers for both routes.NemotronSuperLocalImageBinding.parseEncodedBodybecomesencodedBody(_:). The model ID is checked once by the plan and once by the engine guard. It keeps only the media rules. The media-only control gate and the owner's tools and format gates are gone. The media route now refuses exactly what the text route refuses.native_media_controls(new optionalModelInfofield, omitted when nil;ToolChoiceEnforcementPolicy.advertisesNativeMediaControls), set by the scan exactly asnative_media_toolsis. A coordinator can require it before it sends a Super request with media and a JSON response format or tools, so Macs without this build are not sent them during rollout. A cluster member drops it withis_vision.native_media_tools(ToolChoiceEnforcementPolicy.advertisesNativeMediaTools). The coordinator then routes forced tool choice with media, and media in tool results, to Macs with this build. Older Macs keep the coordinator's refusal.SuperHTTPErrors.map):invalid_requestfor request controls and a prompt beyond the context;unsupported_media(newMediaIngest.MediaError.unsupportedMedia) for media the route does not serve;media_too_largefor limits;invalid_mediaonly for corrupt media. Rendered text that names<image>or<video>isinvalid_request, as on the text route.NemotronSuperLocalLoad.localImagePromptwrapper.Commit 2, image formats (ruling R2):
NemotronSuperImageDecodesniffs WebP, GIF and BMP. ImageIO must report the same type. The frame-0 size comes from the header, so the byte, pixel and resize limits apply before any raster exists. WebPEXIF/XMPchunks set the orientation with the existing Pillow rules, read only from an extended-format (VP8X) file under theirVP8Xflags, as libwebp'sParseVP8XChunksstores them.NemotronSuperImageIORasterreads 8-bit gray, gray-alpha, RGB, RGBA (both byte orders) and RGB palettes without drawing, and drops alpha as Pillow'sconvert("RGB")does. Premultiplied samples are divided by alpha first. Other RGB layouts are drawn once in the image's own colour space.data:image/webp,data:image/gifanddata:image/bmplabels (the coordinator's sniffed labels).No mlx-swift-lm change is needed: the media prefill takes prompt tokens and does not read tools.
Before and after
Before: media request → raw-body control gate (refuses tools, format,
min_p,parallel_tool_calls,prompt_cache_key) → prompt from raw messages, no tools → every refusalinvalid_media400.After: media request → the text route's plan (validates controls, inserts tool-choice and format instructions) → media rules only → prompt from the plan's messages and tools → the same output validation as text → refusals by cause (
invalid_request,unsupported_media,media_too_large,invalid_media).Test plan
PR CI only (no builds or tests on the laptop). Tests drive the real route with the tiny synthetic Super owner:
NemotronSuperMediaControlsHTTPTests(new): live loopback HTTP on the Super hook, image and video:json_objectandjson_schema(streamed and complete), invalid JSON 422 and stream error, tools withtool_choiceauto, named and required,parallel_tool_calls: false,min_p: 0, JSON with tools; refusedmin_p: 0.1isInvalid inference request., a TIFF label isMedia input is not supported.; a refusal-code table.<tool_response>then<image>),tool_choice: nonewith media,parallel_tool_calls: falsewith two calls (422), and the prompt order (tools block, format instruction, media slot).NemotronSuperManagedSlotTests.coordinatorImagesServeJSONOutputAndTools(new): the sealed coordinator path, JSON output, invalid JSON (422,generation_failure), forced tool choice, media in a tool result, and named failure codes.NemotronSuperImageIOFormatTests(new): lossless WebP (cwebpfrompng-rgb8.png) matches Pillow's reference raster; WebP EXIF orientation; GIF and BMP built in the test decode to their source raster; every sample layout; limits from the header; VP8X-gated WebP metadata; hostile GIF headers (65535 x 65535 screen, a frame larger than its screen, 64 frames); a transparent GIF and a lossy WebP with alpha.CI: run 42545456472 (head
725837fab1) found three stale expectations, fixed incb5db4b0bc; run 42546906134 passed. After the review fixes, run 42549599724 (head23c20d6f70) refused to build one test (a redeclared name), fixed in71bbd101c1. Run 42550131625 (head71bbd101c1) passed. Run 42557880693 (head48071e27f4, addsnative_media_controls): build, both provider unit shards, Provider Tests and the cluster jobs pass. The two Vercel failures (d-inference,d-inference-console-ui-dev) are also red on #1921 and are unrelated.Real-model check still needed on a Super Mac (not run: needs David's go for GPU work): one image request with
response_format: json_objectand one withtools, against the pinned checkpoint.Components touched
Protocol / interface changes
ModelInfofield,native_media_controls(omitted when nil, so other models' wire is unchanged). Super now sends it andnative_media_tools: true(an existing field), and media refusals use the existing failure codesinvalid_request,unsupported_mediaandmedia_too_largewhere they usedinvalid_media. The coordinator shows 400, 415 and 413; all three stop after one attempt (outcome.IsTerminalClientErrorCode). Platform owner review requested for both.Documentation impact
docs/architecture/inference.md,docs/provider/direct-mode.md,docs/reference/nemotron-super-image-formats.md,docs/developer/test.md,docs/reference/protocol-messages.md,docs/architecture/model-registry.md,scripts/nemotron-qualification/README.md.docs-impact-check --base origin/dev: OK.Changelog
changelog.d/nemotron-super-media-structured-output-tools.mdandchangelog.d/nemotron-super-webp-gif-bmp.md;changelog.py checkpasses.Notes for reviewers
SuperHTTPErrors.map(the transient-video and decode-allowance branches, which this PR also changes: the spent allowance now maps inside the video switch),NemotronSuperVideoBindingTests.spentDecodeAllowanceIsARetryableRefusaland the decode-allowance row ofdocs/provider/direct-mode.md. When Refuse media decode faults with error reason media_memory_unavailable #1921 lands first, this branch mergesorigin/dev(no rebase) and keeps Refuse media decode faults with error reason media_memory_unavailable #1921'smediaMemoryUnavailablemapping and error-reason assertions with this PR'swire(.limit) == (.mediaTooLarge, 400).prompt_cache_keystays refused on both routes. The coordinator deletes it before dispatch, so it only reaches the local API.Refactor Pass
Not done: this agent cannot start the dedicated refactor subagent. The parent session owns this gate.
🤖 Generated with Claude Code