Repository navigation
fix(provider): serve OpenRouter's variable-frame-rate readiness video on GLM-5.3-Flash - #1559
jonathan308 wants to merge 3 commits into
Conversation
… on GLM
OpenRouter's provider-readiness test input-video-base64 failed on
glm-5.3-flash with 400 invalid_media. The clip is a variable-frame-rate
QuickTime movie (211 frames in 10.833 s), and GLM5NextProcessor refused it
with unsupported("variable-frame-rate video"), which the scheduler maps to
multimodal_rejected and then invalid_media.
- Bump mlx-swift-lm to the GLM5Next decoder fix: frames are indexed in
presentation order and timed by the track's average rate, as in the
reference loader (Layr-Labs/mlx-swift-lm#340).
- Admit data:video/mov (OpenRouter's documented QuickTime label) and
data:video/x-m4v on the shared media ingest. MemoryBackedVideoAsset
still identifies MP4 or QuickTime from the bytes.
- Scheduler-level regression test with the real OpenRouter fixtures and a
label-alias ingest test; docs and changelog fragment.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Threat model review — advisoryReviewed head Review not completed for this head. Previous findings are superseded, not confirmed resolved. Reviewers: anthropic/claude-sonnet-5.5: first pass completed; anthropic/claude-opus-5.5: selected depth completed (4 batches); openai/gpt-6.1-sol: selected depth completed (2 batches) Scan incomplete: 1 file(s) could not be fully read as text. Binary, Git LFS and submodule changes require manual review. Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging. Human review required: CI did not complete the security review. A maintainer must review the saved findings and remaining scope. A green advisory job is not security clearance; do not manually rerun the paid scan. Coverage: 37/37 source units; cross-file integration complete. 0 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned. Cost this run: $0.0000 reported, $0.0000 reserved with unknown cost; 0 paid request(s), 0 reused batch(es), 0 provider cache-hit tokens. Saved findings and earlier report · Historical findings are not confirmed resolved. Bedrock: 21 request(s), 821523 uncached + 0 cache-read + 79449 cache-write input / 13161 output tokens; 0 request(s) with unknown usage. OpenRouter backup used 0 time(s). Dollar amounts above cover OpenRouter only; AWS billing is reconciled separately. |
… the changelog Required refactor pass; no behavior change. - Bump libs/mlx-swift-lm 54227bab -> 6aef0a5d (Layr-Labs/mlx-swift-lm#340), which removes decodeFrames' frame-rate parameter left unused by the variable-frame-rate fix and updates two comments that still described constant-frame-rate-only decoding. - The shared inline-video path also serves MiMo V2.6: MiMoV26EncodedMediaIngress calls MediaIngest.decodeVideo directly, so it admits the new video/mov and video/x-m4v labels too. Say so in the changelog fragment.
Owner decision. OpenRouter sends data:video/quicktime;base64, which every model already admits: Nemotron Super passed OpenRouter's base64 readiness test with OpenRouter's label, and the recorded request size fits that 28-character header exactly. The aliases also made the shared ingest accept labels that Nemotron Super, in the provider and the coordinator, still refuses. - MediaIngest.decodeVideo again admits only data:video/mp4;base64 and data:video/quicktime;base64; MediaIngest.swift, MediaIngestTests.swift and the T-050 threat-model wording match master. - The routing test keeps the real video/quicktime and video/mp4 readiness cases and drops the video/mov variant. - Docs and the changelog fragment keep only the variable-frame-rate fix. The SDK pin and the GLM regression test are unchanged.
Summary
OpenRouter's provider-readiness test for
glm-5.3-flashfailsinput-video-base64with HTTP 400{"error":{"code":"invalid_request_error","message":"invalid media input"}}. The coordinator sends that message only for the provider failure codeinvalid_media.Root cause, proven with the real OpenRouter clip.
input-video-base64.movis a variable-frame-rate (VFR) QuickTime movie: 211 frames in 10.833 s with 31 different sample durations. Frame 1 is at 0.342 s, but1 / nominalFrameRatepredicts 0.051 s.GLM5NextProcessor.decodeFramesrequired every timestamp to be within a quarter frame ofindex / nominalFrameRate, so it threwunsupported("variable-frame-rate video"). The provider then mapped it:Fix: SDK pin
7bed8216 → 54227bab(Layr-Labs/mlx-swift-lm#340; now6aef0a5d, see Refactor pass). The decoder now follows the reference loader: Transformers' PyAV path usesaverage_rateand frame count, and puts frame i ati / fps. Frames are indexed in presentation order and timed by the track's average rate. AVFoundation'snominalFrameRatefor this clip is 19.447004, equal to FFmpeg'savg_frame_rate4220/217. Timestamps must be finite and strictly increasing. The 2 FPS sampler, all limits, and constant-frame-rate clips are unchanged.Label aliases dropped. An earlier revision of this PR also let the shared
MediaIngest.decodeVideoadmitdata:video/mov;base64,anddata:video/x-m4v;base64,. By owner decision,8ef69dde3removes them:data:video/quicktime;base64,, which every model already admits. Nemotron Super admits onlyvideo/mp4andvideo/quicktime, and it passed OpenRouter's base64 readiness test with OpenRouter's label. The recorded request size also fits that 28-character header exactly.video/movorvideo/x-m4vgetinvalid_media, as onmaster.MediaIngest.swift,MediaIngestTests.swiftanddocs/threat-model.yamlnow matchmaster. The routing test keeps the realvideo/quicktimeandvideo/mp4cases. The VFR fix and its regression test are unchanged.Before
flowchart LR classDef bad fill:#fde2e1,stroke:#c0392b,color:#000 classDef ok fill:#e3f4e1,stroke:#2e7d32,color:#000 classDef io fill:#e8eefc,stroke:#3559b7,color:#000 R["OpenRouter readiness video_url<br/>data:video/quicktime or data:video/mp4"]:::io --> I["MediaIngest.decodeVideo<br/>label ∈ {mp4, quicktime}"] I --> P["GLM5NextProcessor.decodeFrames<br/>|pts − i/fps| ≤ ¼ frame?"] P -- "VFR (input-video-base64.mov)" --> X["unsupported: variable-frame-rate video"]:::bad X --> E["invalid_media → 400"]:::bad P -- "CFR (input-video-url.mp4)" --> S["2 FPS sample → engine"]:::okAfter
flowchart LR classDef ok fill:#e3f4e1,stroke:#2e7d32,color:#000 classDef io fill:#e8eefc,stroke:#3559b7,color:#000 classDef bad fill:#fde2e1,stroke:#c0392b,color:#000 R["OpenRouter readiness video_url<br/>data:video/quicktime or data:video/mp4"]:::io --> I["MediaIngest.decodeVideo<br/>label ∈ {mp4, quicktime}, unchanged"] I --> P["GLM5NextProcessor.decodeFrames<br/>pts finite and increasing?<br/>frame i at i / average fps"] P -- "VFR or CFR (both clips)" --> S["unchanged 2 FPS sampler → placements → engine"]:::ok P -- "pts not finite or not increasing" --> X["invalidInput → invalid_media → 400"]:::badBlue: request. Red: refusal. Green: served. Only
decodeFrameschanges; the label rule is the same before and after.Evidence
The new scheduler-level test is
GLM5NextMediaRoutingTests.openRouterReadinessVideosReachTheEngineInsteadOfInvalidMedia. It uses the real OpenRouter fixtures from the SDK test resources, pinned by SHA-256, and runs them through the real request decode, GLM prompt normalization, shared ingest,GLM5NextProcessorat the published processor budgets,glm5NextInputError, scheduler error mapping andProviderLoop.sanitizedInferenceFailure. Only the tower and engine are stubbed; no weights are loaded. It sendsinput-video-base64.movasdata:video/quicktimeandinput-video-url.mp4asdata:video/mp4, the way the coordinator inlines the URL clip.masterSDK pin, new test). This is the original run's output without the lines for the since-removedvideo/movcase and alias test:video/mp4URL fixture already passed onmaster.8ef69dde3):input-video-base64.mov→ 11 temporal pairs on a 1512×560 canvas (40×108 patches, 1080 tokens per pair).input-video-url.mp4→ 5 pairs on 1288×728 (52×92, 1196 tokens per pair).Regression suites on
8ef69dde3, run afterswift build --build-testsandscripts/stage-test-metallib.sh, with isolatedDARKBLOOM_STATE_FILEandDARKBLOOM_LOADED_MODELS_FILE:174 passed, 1 skipped, 0 failed. Swift Testing's total counts the skipped test. The total was 176 before the alias test was removed. The skip is pre-existing:
realTokenizerReproducesTheReferencePromptIDsruns only whenNEMOTRON_SUPER_REFERENCE_DIRis set. Because of it, the runner's no-skip check exits 1. The existing label-refusal test,decodeVideo fails closed on a non-MP4 data URI(data:video/webm), passes.The SDK suites
GLM5NextProcessorTests|GLM5NextVisionTestspassed (21 tests); see #340. The alias removal does not change the SDK pin. On8ef69dde3,make docs-check(192 files OK),make changelog-check(2 valid fragments) andmake docs-impact-check BASE=origin/master(5 changed files, coverage OK) pass.Coordinator check, read-only against platform
masterf512258: the GLM estimator (mediawork.Profile.EncodedVideo) accepts both clips under anydata:…;base64label. It prices the.movat 13,130 tokens, above the provider's bound of 11 × (1080 + 2 + 11) + 2 = 12,025, and the.mp4at 7,256, above 5 × (1196 + 2 + 11) + 2 = 6,047. No platform change is needed for GLM.Merge Danger
Door: two-way. No wire, protocol, persisted state or capacity-quotation change. A revert restores the refusals.
Blast Radius: GLM-5.3-Flash video decoding
index / average fps, as in the reference loader. CFR clips produce the same frames, grids and timestamps.MediaIngest.decodeVideostill admits onlydata:video/mp4;base64anddata:video/quicktime;base64, the same two labels asNemotronSuperLocalImageBinding.admittedVideoDataURIPrefixes. The SDK change touches onlyGLM5NextProcessor, so Gemma, Qwen, MiMo and Nemotron Super video are unaffected.Limitations
GLM53_REAL_VISIONlane) was not performed.GLM5NextOfficialVisionReferenceTestsneedsGLM53_REFERENCE_FIXTURE_DIR, which is not available here, so it skipped.ordinaryFactoryRunsTextHTTPImageAndProtectedEmbeddedMTP(withDARKBLOOM_TEST_GLM5_MANAGED_SYNTHETIC=1) fails on load withmetadata("tokenizer lacks the <think> tokens"). That happens in synthetic-fixture tokenizer validation, before any media code runs, and this PR does not touch it.Refactor pass
This is the required refactor pass from
AGENTS.md. It replaces the "Required refactor pass: not run" item under Limitations. It only cleans up code and wording and does not change behavior. It adds one signed commit,eb79154e3.Changes
54227bab → 6aef0a5d. The pin overmasteris now7bed8216 → 6aef0a5d. The new SDK commit isrefactor(glm5next): drop decodeFrames' unused frame-rate parameterin Layr-Labs/mlx-swift-lm#340.GLM5NextProcessor.decodeFrames'fpsparameter unused. Timing comes fromGLM5NextDecodedVideo.framesPerSecond, which isnominalFrameRate. The commit removes the parameter.decodeFramesdoc comment and the file header's list of local changes.MiMoV26EncodedMediaIngresscallsMediaIngest.decodeVideodirectly, andMiMoV26OrdinaryServingPolicyadmits videos. So MiMo V2.6 also admits thevideo/movandvideo/x-m4vlabels. The fragment now says "(GLM, Gemma, Qwen and MiMo)". The Blast Radius list under Merge Danger, "Shared ingest (GLM, Gemma, Qwen, Diffusion Gemma)", should also include MiMo V2.6.Reviewed and kept
MediaIngest.admittedVideoDataURIHeaders. The lowercased lookup behaves like the old case-insensitive compare for these ASCII labels.MemoryBackedVideoAssetstill identifies the container from the bytes. The aliases stay; dropping them is a product decision.GLM5NextMediaRoutingTestshelpers.GLMMediaMarkerTokenizermust mirror the SDK'sGLM5NextTestTokenizer, because the provider tests cannot import the SDK's test types.openRouterVideouses the repo's usual#filePathfixture lookup and keeps the SHA-256 pins.PreparedCaptureis small and documented.vlmDecodeVideoLabelAliases,inference.md,cli-reference.mdand the T-050 threat-model wording are accurate. No current doc still says that variable-frame-rate video is refused. The dated reportdocs/reports/2026-10-21-glm53-flash-single-mac-qualification.mdstill says it was refused. That report is a frozen record of that run, so it stays as written.Out-of-scope finding, not edited
NemotronSuperLocalImageBinding.admittedVideoDataURIPrefixesis documented as "The inline movie labelsMediaIngest.decodeVideoadmits." After this PRdecodeVideoadmits four labels, so that comment is stale. The narrower two-label list for Super is intended. The file is outside this PR's diff and belongs to the Nemotron Super video work.Note, resolved by the alias removal (
8ef69dde3):decodeVideoagain admits exactly those two labels, so the comment is accurate again and needs no follow-up.Validation after the change
Note: these results predate the alias removal; the current results are under Evidence. Validation was run from
provider-swiftafter the change, reusing the build output. Test state used a fresh temporaryDARKBLOOM_STATE_FILEandDARKBLOOM_LOADED_MODELS_FILE.realTokenizerReproducesTheReferencePromptIDsneedsNEMOTRON_SUPER_REFERENCE_DIR. Because of that skip, the runner's no-skip check exits 1.GLM5NextProcessorTests|GLM5NextVisionTestspassed, 21 tests in 4 suites with no skips; see fix(coordinator): schedule the read-cache purge janitor #340.make docs-check(192 files OK),make changelog-check(2 valid fragments) andmake docs-impact-check BASE=origin/master(coverage OK) pass..swift-format. The provider has no swift-format config or gate (the pre-commit hook skips Swift), and this pass changed no provider Swift file.ordinaryFactoryRunsTextHTTPImageAndProtectedEmbeddedMTP: the failure is pre-existing and unrelatedDARKBLOOM_TEST_GLM5_MANAGED_SYNTHETIC=1, so CI never runs it. ThemasterCI run 39874274817 on this PR's basecf3c45107passed, and its Provider Unit Tests log showsTest ordinaryFactoryRunsTextHTTPImageAndProtectedEmbeddedMTP() skipped.GLM5NextManagedLoadthrowsmetadata("tokenizer lacks the <think> tokens")whenGLM5NextThinkingTokenizer(base:)cannot resolve both<think>and</think>.GLM5NextManagedFixturetokenizer has only<unk>,<s>,</s>,xand the six media tokens.GLM5NextProcessorvideo-decoding commits.master. A separatemasterbuild was not run.Need help on this PR? Tag
@codesmith-botwith what you need.