Skip to content

provider: Nemotron Super serves JSON output, tools and WebP/GIF/BMP with images and video - #1922

Merged
jonathan308 merged 7 commits into
devfrom
feat/nemotron-media-tools
Nov 12, 2026
Merged

jonathan308 merged 7 commits into
devfrom
feat/nemotron-media-tools

Conversation

@davidtai

@davidtai davidtai commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Nemotron 3.5 Super's media route now serves image and video requests that carry response_format, tools, tool_choice, parallel_tool_calls or min_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 of invalid_media for 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 400 invalid media input.

What changes

Commit 1, structured output, tools and settings with media (rulings R1 and the refusal names):

  • Image and video requests 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 (imagePromptTokens, videoPrompt). The bridge runs the plan's bridgeRequest. NemotronSuperLocalOutput already parsed, withheld and validated tool calls and JSON answers for both routes.
  • NemotronSuperLocalImageBinding.parseEncodedBody becomes encodedBody(_:). 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.
  • Super advertises native_media_controls (new optional ModelInfo field, omitted when nil; ToolChoiceEnforcementPolicy.advertisesNativeMediaControls), set by the scan exactly as native_media_tools is. 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 with is_vision.
  • Super advertises 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.
  • Refusal codes (SuperHTTPErrors.map): invalid_request for request controls and a prompt beyond the context; unsupported_media (new MediaIngest.MediaError.unsupportedMedia) for media the route does not serve; media_too_large for limits; invalid_media only for corrupt media. Rendered text that names <image> or <video> is invalid_request, as on the text route.
  • Removed the unused NemotronSuperLocalLoad.localImagePrompt wrapper.

Commit 2, image formats (ruling R2):

  • NemotronSuperImageDecode sniffs 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. WebP EXIF/XMP chunks set the orientation with the existing Pillow rules, read only from an extended-format (VP8X) file under their VP8X flags, as libwebp's ParseVP8XChunks stores them.
  • NemotronSuperImageIORaster reads 8-bit gray, gray-alpha, RGB, RGBA (both byte orders) and RGB palettes without drawing, and drops alpha as Pillow's convert("RGB") does. Premultiplied samples are divided by alpha first. Other RGB layouts are drawn once in the image's own colour space.
  • The route admits the data:image/webp, data:image/gif and data:image/bmp labels (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 refusal invalid_media 400.

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_object and json_schema (streamed and complete), invalid JSON 422 and stream error, tools with tool_choice auto, named and required, parallel_tool_calls: false, min_p: 0, JSON with tools; refused min_p: 0.1 is Invalid inference request., a TIFF label is Media input is not supported.; a refusal-code table.
  • The live HTTP test also covers media in a tool result (<tool_response> then <image>), tool_choice: none with media, parallel_tool_calls: false with 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 (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; 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.
  • Updated binding, owner, video, golden, long-context, charge and format tests for the new signatures and codes.

CI: run 42545456472 (head 725837fab1) found three stale expectations, fixed in cb5db4b0bc; run 42546906134 passed. After the review fixes, run 42549599724 (head 23c20d6f70) refused to build one test (a redeclared name), fixed in 71bbd101c1. Run 42550131625 (head 71bbd101c1) passed. Run 42557880693 (head 48071e27f4, adds native_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_object and one with tools, against the pinned checkpoint.

Components touched

  • provider-swift (Swift CLI)
  • docs

Protocol / interface changes

  • Yes. One new optional ModelInfo field, native_media_controls (omitted when nil, so other models' wire is unchanged). Super now sends it and native_media_tools: true (an existing field), and media refusals use the existing failure codes invalid_request, unsupported_media and media_too_large where they used invalid_media. The coordinator shows 400, 415 and 413; all three stop after one attempt (outcome.IsTerminalClientErrorCode). Platform owner review requested for both.

Documentation impact

  • Canonical documentation updated: 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.md and changelog.d/nemotron-super-webp-gif-bmp.md; changelog.py check passes.

Notes for reviewers

Refactor Pass

Not done: this agent cannot start the dedicated refactor subagent. The parent session owns this gate.

🤖 Generated with Claude Code

davidtai and others added 2 commits November 8, 2026 19:17
…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>
@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference Error Error Nov 9, 2026 3:43am UTC
d-inference-console-ui-dev Error Error Nov 9, 2026 3:43am UTC
d-inference-landing Ready Ready Preview Nov 9, 2026 3:43am UTC
darkbloom-status Ready Ready Preview Nov 9, 2026 3:43am UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 9, 2026 3:43am UTC

Request Review

…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>
davidtai and others added 2 commits November 8, 2026 20:11
…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>

@jonathan308 jonathan308 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.

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:

  1. The real-model check from the PR's own test plan: one image request with response_format: json_object and one with tools, on a Super Mac against the pinned checkpoint. It hasn't run anywhere yet.
  2. #1871's fragment contradicts this PR. changelog.d/nemotron-video-decode-allowance-retryable.md:4 says the video's own limits are still invalid_media 400. 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.
  3. The docs claim more than production does. docs/reference/protocol-messages.md:373 ("The coordinator requires it … during rollout") and docs/architecture/inference.md:825-827 are true only with platform #729, which is on platform dev only. Name #729 and pin the link, as the native_media_tools row does.
  4. #1921 overlaps this PR in 3 files (docs/provider/direct-mode.md, NemotronSuperLocalImageHTTP.swift, NemotronSuperVideoBindingTests.swift), around SuperHTTPErrors.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.

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>
@jonathan308
jonathan308 merged commit f0bf2e9 into dev Nov 12, 2026
28 of 31 checks passed
@davidtai
davidtai deleted the feat/nemotron-media-tools branch November 18, 2026 11:42

This branch had an error being deployed

2 failed and 3 active deployments
Preview – d-inference-landing — 48071e27 Deployed Nov 9, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — 48071e27 Deployed Nov 9, 2026 by vercel[bot]
Preview – darkbloom-status — 48071e27 Deployed Nov 9, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — 48071e27 Deployed Nov 9, 2026 by vercel[bot]
Preview – d-inference — 48071e27 Deployed Nov 9, 2026 by vercel[bot]
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