Skip to content

HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.

fix(media): a vertical film was accepted, and came back landscape

richard-epsillaa4b0f79e81aa
diff --git a/gateway/app.py b/gateway/app.py
index 05cbc5ef..3e72294c 100644
--- a/gateway/app.py
+++ b/gateway/app.py
@@ -8607,10 +8607,15 @@ async def _media_job_resubmit(job: dict, budget: _MediaBudget) -> bool:
async def _media_generate(cap: str, params: dict, hid: str, sid: str, org: str,
- entry_id: str, budget: _MediaBudget) -> dict:
+ entry_id: str, budget: _MediaBudget, shot: str = "") -> dict:
"""Resolve the chain, start the work, and record a job. A refusal leaves no vertex behind when
nothing ran — but a walk that BOUGHT renders and delivered none of them is not nothing, and
- what it spent is written down before the refusal goes back."""
+ what it spent is written down before the refusal goes back.
+
+ `shot` is the canvas label the agent gave this render, and it is a JOB field rather than a
+ provider parameter: no model is told about it, and the job is the only thing that survives the
+ four minutes between the submit and the `place` call that puts the clip on the board.
+ """
providers = await _media_providers()
try:
cand, task_id, payload, doc, tally = await _media_chain(cap, params, providers, budget)
@@ -8625,7 +8630,7 @@ async def _media_generate(cap: str, params: dict, hid: str, sid: str, org: str,
# megabytes; the media id is kept instead and the bytes are re-read from our own store
# if the chain has to advance (see _media_job_resubmit).
"params_json": json.dumps(_media_params_stored(params)),
- "params": params, "status": "running",
+ "params": params, "status": "running", "shot": shot,
"model": str(cand.get("model") or ""), "provider": str(cand.get("provider") or ""),
"provider_task_id": task_id, "attempts_json": json.dumps(attempts),
"attempts": attempts, "next_poll_at": now + 20_000, "poll_backoff_s": 20,
@@ -9075,11 +9080,17 @@ async def _media_tool_call(name: str, args: dict, hid: str, sid: str, org: str,
f"limit for one session. Nothing was generated. Ask the person whether to carry "
f"on — you cannot raise the limit yourself.", True)
params: dict = {}
- note = ""
+ notes: list[str] = []
if name == "generate_video":
params = {"prompt": str(args.get("prompt") or ""),
"seconds": float(args.get("seconds") or 0),
"allow_watermark": bool(args.get("allow_watermark"))}
+ if args.get("aspect"):
+ # CARRIED, not dropped. It goes into `params` and therefore onto the job, which is
+ # what makes it hold on the poll walk too: a chain that advances re-resolves out
+ # of the same params, so the second candidate is filtered by the same rule as the
+ # first and cannot quietly hand back a landscape clip.
+ params["aspect"] = str(args["aspect"])
cap = "text_to_video"
elif name == "generate_image":
size = str(args.get("size") or "1024x1024")
@@ -9111,7 +9122,8 @@ async def _media_tool_call(name: str, args: dict, hid: str, sid: str, org: str,
# The budget is opened HERE, around the whole generation, because it belongs to the
# call and not to the walk: the synchronous shapes bill inside `_media_generate` too.
async with _media_budget_for(sid) as budget:
- job = await _media_generate(cap, params, hid, sid, org, entry_id, budget)
+ job = await _media_generate(cap, params, hid, sid, org, entry_id, budget,
+ shot=str(args.get("shot") or ""))
except _MediaNoModel as e:
return _tool_text(e.text, True)
except media_plane.MediaError as e:
@@ -9123,18 +9135,38 @@ async def _media_tool_call(name: str, args: dict, hid: str, sid: str, org: str,
out["seconds"] = params["seconds"]
allowed = cand.get("durations_s")
if allowed:
- note = (f"This model renders {' and '.join(str(a) for a in allowed)} s only; "
- f"{params['seconds']:g} s was requested and accepted.")
+ notes.append(f"This model renders {' and '.join(str(a) for a in allowed)} s only; "
+ f"{params['seconds']:g} s was requested and accepted.")
elif cand.get("duration_ignored"):
# Measured: it takes the duration and returns whatever length it likes. Anything
# that needs an exact length has to read the one that actually landed.
obs = cand.get("duration_observed_s")
- note = ("This model does not honour a requested duration"
- + (f" — the clip measured came back {float(obs):g} s" if obs else "")
- + ". check_jobs reports the real length once it lands; cut from that "
- "rather than from the seconds you asked for.")
+ notes.append("This model does not honour a requested duration"
+ + (f" — the clip measured came back {float(obs):g} s" if obs else "")
+ + ". check_jobs reports the real length once it lands; cut from that "
+ "rather than from the seconds you asked for.")
+ # THE SHAPE THAT WAS ACTUALLY SECURED, on the same footing as the model that ran. It can
+ # only be the one asked for — a candidate that could not hold it was skipped — so what is
+ # worth saying is HOW, because "it was told" and "it is only ever that" are different
+ # promises and only one of them survives the model being swapped.
+ if params.get("aspect"):
+ out["aspect"] = params["aspect"]
+ told = media_plane.aspect_size(cand, params["aspect"])
+ if told:
+ notes.append(f"{cand['model']} was asked for a {told} frame.")
+ elif cand.get("resolution"):
+ notes.append(f"{cand['model']} renders {cand['resolution']} and nothing else, "
+ f"which is {params['aspect']}.")
if name == "generate_image":
- out["size"] = params["size"]
+ # ONLY WHAT THE PROVIDER WAS ACTUALLY TOLD. This used to echo the requested size on
+ # every call, including the rank-1 gemini models whose params are ["prompt"] and which
+ # are never sent one — a number printed beside the model that never received it.
+ told = media_plane.size_for(cand, params)
+ if told:
+ out["size"] = told
+ else:
+ notes.append("This model cannot be told a frame size, so the one you asked for "
+ "was not sent. check_jobs reports the size that actually landed.")
if job.get("usd"):
out["estimated_usd"] = round(float(job["usd"]), 4)
if job.get("attempts"):
@@ -9149,8 +9181,8 @@ async def _media_tool_call(name: str, args: dict, hid: str, sid: str, org: str,
out["spoken_text"] = job["spoken_text"]
out["verbatim"] = media_plane.levenshtein_ratio(
params.get("text") or "", str(job["spoken_text"])) >= 0.9
- if note:
- out["note"] = note
+ if notes:
+ out["note"] = " ".join(notes)
return _media_json_text(out)
if name == "check_jobs":
@@ -9270,9 +9302,18 @@ async def _media_tool_call(name: str, args: dict, hid: str, sid: str, org: str,
if auto else (0.0, 0.0))
w = float(it.get("w") or media_plane.TILE_W)
h = float(it.get("h") or media_plane.TILE_H)
- shot = str(it.get("shot") or "")
+ # The job's own label is the default, and a label named here overrides it: an
+ # agent that renames a shot while placing it means the rename. Without the
+ # fallback, the `shot` argument on the generate tools promised a grouping that
+ # only happened if the agent typed the same label a second time.
+ shot = str(it.get("shot") or (job or {}).get("shot") or "")
if it.get("text"):
- el = media_plane.text_element(str(it["text"]), x=x, y=y, w=w)
+ # `h` only when it was actually asked for. A caption's height is CAPTION_H and
+ # not the tile default, so passing the computed `h` unconditionally would make
+ # every caption a tile tall — but ignoring an `h` the caller DID send is the
+ # same declared-and-unread defect as the two this commit is about.
+ el = media_plane.text_element(str(it["text"]), x=x, y=y, w=w,
+ **({"h": float(it["h"])} if it.get("h") else {}))
else:
kind = (_MEDIA_KIND.get(str((job or {}).get("capability")), "image")
if job else str((meta or {}).get("kind") or "image"))
diff --git a/gateway/media_plane.py b/gateway/media_plane.py
index 121362c1..0e529885 100644
--- a/gateway/media_plane.py
+++ b/gateway/media_plane.py
@@ -42,6 +42,7 @@ import binascii
import contextlib
import functools
import json
+import math
import os
import pathlib
import re
@@ -175,6 +176,12 @@ def limits_of(cand: dict) -> dict:
out["accepts_input_image"] = bool(cand["accepts_input_image"])
if cand.get("watermark"):
out["watermark"] = True
+ served = aspects_of(cand)
+ if served:
+ # Derived, never declared: the shapes fall out of the frame and the floor this entry
+ # already records. A capability whose media has no shape at all (a line of speech) reports
+ # no key, rather than an empty list that reads as "none of them".
+ out["aspects"] = served
return out
@@ -253,6 +260,17 @@ def can_serve(cand: dict, params: dict) -> str:
return (f"{model} rejects anything under "
f"{int(cand['min_pixels']):,} px and {size} is smaller")
+ aspect = params.get("aspect")
+ if aspect and not aspect_size(cand, str(aspect)):
+ # A CANDIDATE THAT CANNOT HOLD THE SHAPE IS SKIPPED LIKE ANY OTHER, and never quietly
+ # substituted: returning a landscape clip for a 9:16 ask is the same class of defect as a
+ # dashboard printing a number the database never returned. If the whole chain skips, the
+ # tool refuses — see `refusal`, which is built out of these clauses.
+ fixed = aspect_fixed(cand)
+ if fixed != aspect:
+ return (f"{model} only renders {fixed} ({cand.get('resolution')})" if fixed else
+ f"{model} cannot be told an aspect and what it returns was never measured")
+
if cand.get("watermark") and not params.get("allow_watermark"):
return f"{model} watermarks its output"
@@ -334,6 +352,111 @@ def parse_size(size: str) -> tuple[int, int]:
return (int(m.group(1)), int(m.group(2))) if m else (0, 0)
+# ── the aspect ────────────────────────────────────────────────────────────────────
+# AN ASPECT IS A SIZE, everywhere in this catalog. Nothing here honours an `aspect_ratio` field —
+# MiniMax is measured ignoring one and billing anyway — so the only lever any candidate has is the
+# `size` parameter it already declares, and there is no new per-candidate key for aspects at all.
+# Three facts already in the file answer the whole question:
+#
+# `params` lists `size` -> it can be TOLD a shape. That list is this file's statement of which
+# tunables a model honours; MiniMax's deliberately omits `size` and
+# says why in its note, so reading that list IS reading a measurement.
+# `resolution` and no -> it IS one shape and cannot be told another. Its aspect is arithmetic
+# `size` in params on a frame that was already measured, never a second hand-written
+# field that could disagree with the first.
+# neither -> UNKNOWN. Skipped when an aspect is asked for, because "we did not
+# measure it" and "it will be fine" are not the same sentence.
+_ASPECTS = {"16:9": (16, 9), "9:16": (9, 16), "1:1": (1, 1)}
+
+# How far a measured frame may sit from a label and still wear it. 1366x768 — MiniMax's measured
+# output — is 1.7786 against 16:9's 1.7778, the standard near-16:9 panel, 0.05% out. Written as a
+# number rather than left implicit because the alternative is either calling that frame something
+# it is not, or refusing a request every display in the world would answer.
+_ASPECT_TOL = 0.01
+
+# Frame dimensions are built as a multiple of this. Every ratio in `_ASPECTS` then comes out even
+# on both edges, which is what h.264 requires — a computed 1443x2565 would be refused by the
+# encoder at export, one step away from where it was chosen.
+_ASPECT_STEP = 8
+
+
+def aspect_label(w: int, h: int) -> str:
+ """The label a w×h frame wears, or "" when it wears none of them."""
+ if not w or not h:
+ return ""
+ r = float(w) / float(h)
+ for name, (rw, rh) in _ASPECTS.items():
+ want = rw / rh
+ if abs(r - want) <= _ASPECT_TOL * want:
+ return name
+ return ""
+
+
+def aspect_fixed(cand: dict) -> str:
+ """The one shape this candidate always produces, when it cannot be told another — "" if it can
+ be told, or if nothing measured says what it returns.
+
+ A candidate that takes a `size` gets "" even though it has a `resolution`: that number is its
+ default, not a fixture, and reading a default as a limit would skip a model that can do the
+ job.
+ """
+ if "size" in declared_params(cand):
+ return ""
+ return aspect_label(*parse_size(str(cand.get("resolution") or "")))
+
+
+def aspect_size(cand: dict, aspect: str) -> str:
+ """The size to ASK this candidate for so the frame comes back `aspect` — "" when it cannot be
+ told a size at all, or when nothing in its entry says what size to ask for.
+
+ Built out of that model's own numbers: a size it has been verified at when one is the right
+ shape, otherwise the smallest frame of that shape clearing its own floor. The formula
+ reproduces seedream-4.5's verified 1920x1920 at 1:1 and lands exactly on its 3,686,400 px
+ minimum at 16:9 — which is the point. It is arithmetic on measurements, not a table typed by
+ hand, so a model whose limits are corrected in the catalog is corrected here too.
+
+ NOTHING IS INVENTED when there is no basis. A candidate that takes a size and records neither
+ a floor, nor a verified size, nor a resolution gets "" and is skipped — a guessed frame is the
+ same defect as a guessed price.
+ """
+ ratio = _ASPECTS.get(aspect)
+ if not ratio or "size" not in declared_params(cand):
+ return ""
+ rw, rh = ratio
+ target = int(cand.get("min_pixels") or 0)
+ for s in cand.get("sizes_verified") or []:
+ w, h = parse_size(str(s))
+ if aspect_label(w, h) == aspect:
+ return f"{w}x{h}" # measured at this shape: ask for exactly what was verified
+ target = max(target, w * h) # wrong shape, but it still says what scale this model works at
+ if not target:
+ w, h = parse_size(str(cand.get("resolution") or ""))
+ target = w * h
+ if not target:
+ return ""
+ k = math.ceil(math.sqrt(target / float(rw * rh)))
+ k = -(-k // _ASPECT_STEP) * _ASPECT_STEP
+ return f"{rw * k}x{rh * k}"
+
+
+def aspects_of(cand: dict) -> list[str]:
+ """Every shape this candidate can actually deliver. What `list_capabilities` reports, so an
+ agent planning a vertical film learns it cannot have one BEFORE it spends four minutes."""
+ return [a for a in _ASPECTS if aspect_size(cand, a) or aspect_fixed(cand) == a]
+
+
+def size_for(cand: dict, params: dict) -> str:
+ """The size this candidate will be ASKED for — "" when it is told none at all.
+
+ THE ONE PLACE that answer is computed, so what the submit carries and what the tool reports
+ back afterwards cannot disagree. A tool that prints `size: 1024x1024` beside a model whose
+ params are ["prompt"] is printing a number the provider never received.
+ """
+ if "size" not in declared_params(cand):
+ return ""
+ return str(params.get("size") or aspect_size(cand, str(params.get("aspect") or "")) or "")
+
+
# ── the five adapters: building a request ─────────────────────────────────────────
class Submit:
"""One outbound request, plus exactly which tunables it carried.
@@ -386,6 +509,11 @@ def build_submit(cand: dict, base_url: str, params: dict) -> Submit:
tun[name] = value
return value
+ # The caller's own size, or the one that expresses the aspect it asked for — per candidate,
+ # because the walk may end on a different model than it started at and each one is asked in
+ # its own numbers. `None` where this candidate takes no size, so `take` drops it.
+ asked_size = size_for(cand, params) or None
+
if shape == "video-generation":
body: dict = {"model": model, "extra_body": {}}
prompt = take("prompt", params.get("prompt"))
@@ -402,7 +530,7 @@ def build_submit(cand: dict, base_url: str, params: dict) -> Submit:
mode = take("mode", params.get("mode"))
if mode is not None:
body["mode"] = mode
- size = take("size", params.get("size"))
+ size = take("size", asked_size)
if size is not None:
body["size"] = (size.replace("x", "*") if cand.get("size_format") == "W*H"
else size)
@@ -416,7 +544,7 @@ def build_submit(cand: dict, base_url: str, params: dict) -> Submit:
if "n" in allow:
tun["n"] = 1
body["n"] = 1
- size = take("size", params.get("size"))
+ size = take("size", asked_size)
if size is not None:
body["size"] = size
img = take("image", params.get("image"))
diff --git a/gateway/tests/test_media_mcp.py b/gateway/tests/test_media_mcp.py
index 4f493e35..c733cb90 100644
--- a/gateway/tests/test_media_mcp.py
+++ b/gateway/tests/test_media_mcp.py
@@ -848,10 +848,15 @@ def test_list_capabilities_is_free_and_names_what_is_broken(client, harness, ses
# Every limit reported is one that was MEASURED on this model, and nothing else is reported.
# It ignores the duration it is sent — asked 1 s, returned 6.08 s — so the agent is told that
# rather than left to believe the number it asked for.
+ #
+ # `aspects` is in this dict for the same reason and by the same standard: it is arithmetic on
+ # the 1280x720 frame two lines above, not a new claim about the model. It takes no `size`
+ # parameter, so 16:9 is the only shape it can produce and the only one it can be asked for.
assert by["text_to_video"]["limits"] == {"duration_ignored": True,
"duration_observed_s": 6.08,
"resolution": "1280x720",
- "accepts_input_image": False}
+ "accepts_input_image": False,
+ "aspects": ["16:9"]}
assert by["text_to_music"]["available"] is False
assert "paid ElevenLabs plan" in by["text_to_music"]["reason"]
assert by["export"]["available"] is media_plane.have_ffmpeg()
@@ -1044,12 +1049,18 @@ def test_the_provider_url_is_never_persisted(client, harness, session, provider)
def test_an_image_lands_inline_and_says_so(client, harness, session, provider):
"""A synchronous shape renders inside the submit. Reporting it as 'running' would be a lie the
- very next call exposes."""
+ very next call exposes.
+
+ This test used to end `assert out["size"] == "1024x1024"` and that assertion pinned a lie: the
+ model it names has params ["prompt"], is never sent a size, and the 1024x1024 came straight
+ back out of the request. What is asserted now is that the size key is absent — see
+ test_a_size_the_model_cannot_be_told_is_not_reported_as_though_it_were, which pins the reason.
+ """
out = _ok(_call(client, _cred(harness, session), "generate_image",
{"prompt": "a rainy window", "size": "1024x1024"}))
assert out["status"] == "succeeded" and out["media_id"].startswith("med_")
assert out["model"] == "google/gemini-3.1-flash-lite-image"
- assert out["size"] == "1024x1024"
+ assert "size" not in out
def test_a_size_below_a_models_floor_skips_it(client, harness, session, provider):
@@ -1221,6 +1232,156 @@ def test_the_model_that_ignores_a_duration_says_so_rather_than_being_believed(cl
assert body["duration"] == 1
+# ══ the aspect ═══════════════════════════════════════════════════════════════════
+# `aspect` was declared on generate_video, described as a thing the tool does, and occurred
+# EXACTLY ONCE in the whole gateway: in the schema. The generate branch built
+# {prompt, seconds, allow_watermark} and the argument fell on the floor — so an agent asked for a
+# vertical film, was ACCEPTED, and got whatever the model defaults to. Round 5 made it worse in
+# one way: enum validation refuses an INVALID aspect while a VALID one is still ignored, which
+# reads to a model as proof the argument works.
+#
+# Nothing here spends anything. What is asserted is OUR OUTBOUND BODY and OUR REFUSAL — whether a
+# model then obeys is the provider's business and is not what was broken.
+
+def test_a_requested_aspect_reaches_the_provider_request_body(client, harness, session, provider):
+ """THE BUG, stated as the assertion that would have caught it: ask for 9:16 and read what left
+ this process.
+
+ happyhorse is the only text_to_video candidate that lists `size` among the params it honours,
+ so it is the only one that can be TOLD a shape — and it watermarks, so this asks for that too.
+ 1080*1920 is arithmetic on its own measured 1920*1080 frame, in its own W*H format.
+ """
+ out = _ok(_call(client, _cred(harness, session), "generate_video",
+ {"prompt": "a lift door closing", "seconds": 6, "aspect": "9:16",
+ "allow_watermark": True}))
+ assert out["model"] == "happyhorse-1.0-t2v"
+ body = next(c["body"] for c in _calls if c["url"].endswith("/video/generations"))
+ assert body.get("size") == "1080*1920", (
+ f"9:16 was accepted and the submit carried {body.get('size')!r} — the argument is still "
+ f"decorative")
+ assert out["aspect"] == "9:16", "the tool must report the shape it actually secured"
+
+
+def test_an_aspect_nobody_in_the_chain_can_honour_is_refused_and_names_why(client, harness,
+ session, provider):
+ """Never landscape for a 9:16 request. Without allow_watermark the one model that can be told
+ a shape is stood down, and there is no substitute — so this refuses, and the refusal is built
+ out of each candidate's own reason rather than one flat sentence."""
+ text = _err(_call(client, _cred(harness, session), "generate_video",
+ {"prompt": "a lift door closing", "seconds": 6, "aspect": "9:16"}))
+ assert "Nothing was generated" in text
+ assert "only renders 16:9" in text, (
+ f"the fixed-shape models must say what they DO render: {text}")
+ assert "1280x720" in text, "and it names the frame that fact comes from"
+ assert "never measured" in text, "kling can be told nothing and nobody measured it — say so"
+ assert "watermarks its output" in text
+ assert not [c for c in _calls if c["url"].endswith("/video/generations")], (
+ "a refusal for a shape nobody can render must not open a socket")
+
+
+def test_a_model_that_is_already_the_requested_shape_is_asked_for_nothing(client, harness,
+ session, provider):
+ """16:9 is what dreamina renders and it takes no size parameter at all. Honouring the request
+ is therefore selecting it — inventing a `size` field for a model whose params do not list one
+ would be the same silent invention one direction over."""
+ out = _ok(_call(client, _cred(harness, session), "generate_video",
+ {"prompt": "rain", "seconds": 6, "aspect": "16:9"}))
+ assert out["model"] == "dreamina-seedance-2-5-hc" and out["aspect"] == "16:9"
+ body = next(c["body"] for c in _calls if c["url"].endswith("/video/generations"))
+ assert "size" not in body, f"a size was invented for a model that declares none: {body}"
+
+
+def test_animating_a_frame_at_a_shape_nobody_measured_refuses_rather_than_guessing(
+ client, harness, session, provider):
+ """image_to_video is the capability with NO substitute, and both its candidates take no size
+ and have no measured output frame. So a request to animate a still AT a shape cannot be
+ honoured by anything, and the only two honest answers are a refusal or a landscape clip
+ handed back as though it were vertical. This asserts the refusal, and that nothing was spent
+ finding out."""
+ img = _ok(_call(client, _cred(harness, session), "generate_image", {"prompt": "a face"}))
+ _calls.clear()
+ text = _err(_call(client, _cred(harness, session), "generate_video",
+ {"prompt": "the face turns", "seconds": 6, "from_image": img["job_id"],
+ "aspect": "9:16"}))
+ assert "No model is available for image_to_video" in text
+ assert "kling-v3 cannot be told an aspect and what it returns was never measured" in text
+ assert [c for c in _calls if "generations" in c["url"]] == [], "it submitted anyway"
+
+
+def test_an_aspect_survives_the_chain_advancing(client, harness, session, provider):
+ """A walk that falls off its first candidate may not land on one that cannot hold the shape.
+
+ The advance is the path four rounds of this file's bugs lived on, and `resolve` is what makes
+ it safe here: the aspect is in the job's params, so the second candidate is filtered by the
+ same rule as the first — and when nothing else can hold it, this refuses rather than
+ substituting a landscape clip.
+ """
+ provider.fail["happyhorse-1.0-t2v"] = (400, {"message": "unknown model"})
+ text = _err(_call(client, _cred(harness, session), "generate_video",
+ {"prompt": "a lift door closing", "seconds": 6, "aspect": "9:16",
+ "allow_watermark": True}))
+ assert "Nothing was generated" in text
+ submitted = [c["body"].get("model") for c in _calls if c["url"].endswith("/video/generations")]
+ assert submitted == ["happyhorse-1.0-t2v"], (
+ f"the walk tried a model that cannot hold 9:16: {submitted}")
+
+
[email protected]("model,aspect,want", [
+ # Arithmetic on each model's OWN measured floor, not a table someone typed. 2560x1440 is
+ # exactly seedream's 3,686,400 px minimum, and 1:1 lands on the size the file records as
+ # verified — which is how the formula is checked against a measurement.
+ ("bytedance-seed/seedream-4.5", "16:9", "2560x1440"),
+ ("bytedance-seed/seedream-4.5", "9:16", "1440x2560"),
+ ("bytedance-seed/seedream-4.5", "1:1", "1920x1920"),
+ ("openai/gpt-5.4-image-2", "1:1", "1024x1024"),
+ # Neither shape takes a size parameter, and nothing measured says what frame they return.
+ ("google/gemini-3.1-flash-lite-image", "16:9", ""),
+ ("microsoft/mai-image-2.5", "16:9", ""),
+])
+def test_the_aspect_is_translated_per_model_out_of_that_models_own_numbers(model, aspect, want):
+ cand = next(c for c in media_plane.capability("text_to_image")["candidates"]
+ if c["model"] == model)
+ assert media_plane.aspect_size(cand, aspect) == want
+
+
+def test_a_capability_says_which_shapes_it_can_actually_render(client, harness, session, provider):
+ """list_capabilities is the free pre-flight, and an agent planning a vertical film must be able
+ to learn before it spends that this deployment cannot render one."""
+ by = {c["name"]: c for c in _ok(_call(client, _cred(harness, session),
+ "list_capabilities"))["capabilities"]}
+ assert by["text_to_video"]["limits"]["aspects"] == ["16:9"]
+ assert "aspects" not in by["text_to_speech"]["limits"], "a line of speech has no shape"
+
+
+def test_a_size_the_model_cannot_be_told_is_not_reported_as_though_it_were(client, harness,
+ session, provider):
+ """THE SIBLING, found by auditing the same question one argument over.
+
+ generate_image echoed `size` back beside `model` on every call — including the rank-1 gemini
+ models, whose params list is ["prompt"] and which are never sent a size at all. A number the
+ provider never received, printed next to the model that did not receive it, is the same defect
+ as an aspect that is accepted and ignored.
+ """
+ out = _ok(_call(client, _cred(harness, session), "generate_image",
+ {"prompt": "a rainy window", "size": "1024x1024"}))
+ assert out["model"] == "google/gemini-3.1-flash-lite-image"
+ assert "size" not in out, f"a size nothing was told was reported anyway: {out}"
+ assert "cannot be told a frame size" in out.get("note", "")
+ body = next(c["body"] for c in _calls if ":generateContent" in c["url"])
+ assert "size" not in json.dumps(body)
+ # And where it IS told one, it says so — the same key, earned.
+ for c in media_plane.capability("text_to_image")["candidates"]:
+ if c["shape"] == "gemini":
+ app._media_quarantine[c["model"]] = time.time() + 900
+ told = _ok(_call(client, _cred(harness, session), "generate_image",
+ {"prompt": "a", "size": "1920x1920"}))
+ assert told["model"] == "bytedance-seed/seedream-4.5" and told["size"] == "1920x1920"
+ sent = next(c["body"] for c in _calls if c["url"].endswith("/images/generations"))
+ assert sent["size"] == told["size"], (
+ "the size reported and the size submitted are two readings of one fact and must come "
+ "from one place — see media_plane.size_for")
+
+
def test_the_model_that_rejects_an_input_image_is_not_in_the_image_chain():
"""It rejects an input image url outright. Listing it in image_to_video would spend the rank-1
slot of a capability with NO substitute on a model that cannot do it at all."""
@@ -1285,6 +1446,48 @@ def test_placing_a_running_job_is_the_intended_path(client, harness, session, pr
assert _ok(_call(client, tok, "check_jobs", {"job_ids": [jid]}))["jobs"][0]["element_id"]
+def test_a_shot_label_given_at_generate_is_the_one_the_canvas_groups_by(client, harness, session,
+ provider):
+ """`shot` is declared on all three generate tools and described as "Groups the clip with its
+ caption on the canvas". Nothing recorded it: only place and arrange ever read customData.shot,
+ so the grouping the description promises happened only if the agent typed the same label again
+ by hand — and an agent that believed the description did not.
+
+ Recorded on the JOB, because the job is the only thing that survives between the submit and
+ the place call that puts it on the board.
+ """
+ tok = _cred(harness, session)
+ out = _ok(_call(client, tok, "generate_image", {"prompt": "a lift door", "shot": "Shot 3"}))
+ assert asyncio.run(app._media_job_get(out["job_id"]))["shot"] == "Shot 3"
+ _ok(_call(client, tok, "place",
+ {"items": [{"job_id": out["job_id"], "caption": "the doors close"}]}))
+ seen = _ok(_call(client, tok, "describe_canvas"))
+ assert seen["shots"] == [{"name": "Shot 3",
+ "element_ids": [e["id"] for e in seen["elements"]]}]
+
+
+def test_a_height_given_for_a_caption_is_the_height_it_gets(client, harness, session, provider):
+ """A third sibling of the same shape, found by the same audit: `h` is declared on every place
+ item and was read only on the media branch — a text item's height went to the caption default
+ however tall the caller said to make it. An unasked-for height still gets that default."""
+ tok = _cred(harness, session)
+ _ok(_call(client, tok, "place", {"items": [{"text": "a long note", "h": 240},
+ {"text": "an ordinary caption"}]}))
+ els = _ok(_call(client, tok, "describe_canvas"))["elements"]
+ assert [e["h"] for e in els] == [240, media_plane.CAPTION_H]
+
+
+def test_a_shot_named_at_place_still_wins_over_the_one_on_the_job(client, harness, session,
+ provider):
+ """The job's label is a default, not an override: an agent that renames a shot while placing
+ it means the rename."""
+ tok = _cred(harness, session)
+ out = _ok(_call(client, tok, "generate_image", {"prompt": "a lift door", "shot": "Shot 3"}))
+ _ok(_call(client, tok, "place", {"items": [{"job_id": out["job_id"], "shot": "Shot 9"}]}))
+ seen = _ok(_call(client, tok, "describe_canvas"))
+ assert [s["name"] for s in seen["shots"]] == ["Shot 9"]
+
+
def test_packing_is_driven_by_the_tiles_and_not_by_the_captions(client, harness, session,
provider):
"""A caption sits under its clip. Counting it as an occupant puts the next clip level with the