World's first open-source, agentic video production system. 12 production pipelines, 100+ tools, 700+ agent skill and production-knowledge files. Turn your AI coding assistant into a full video production studio.
Python agentagentic-aiaiclaudecopilotcursorelevenlabsffmpegfluximage-generationopen-sourceopenaipythonremotionstable-diffusiontext-to-speechtext-to-videovideo-generationvideo-production
fix(providers): retain native image references when selecting routes (#709)
Rudy Mizrahi Celekliadcfce543457
diff --git a/tests/tools/test_schema_media_native_references.py b/tests/tools/test_schema_media_native_references.pynew file mode 100644index 00000000..0095c180--- /dev/null+++ b/tests/tools/test_schema_media_native_references.py@@ -0,0 +1,114 @@+"""Native reference inputs must reach the selected generation request."""++import base64+from pathlib import Path+import json+from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer+from threading import Thread+from urllib.parse import urlparse++import pytest++from tools.graphics.atlas_refresh_image import AtlasRefreshImage+from tools.video.ltx_api_video import LTXAPIVideo+from tools.video.wan_atlas_video import WanAtlasVideo+++CASES = [+ (AtlasRefreshImage, "images", ["https://owned.example/source.png"], "edit", {}),+ (WanAtlasVideo, "image", "https://owned.example/source.png", "image_to_video", {}),+ (LTXAPIVideo, "image_uri", "https://owned.example/source.png", "image_to_video", {"duration": 6, "resolution": "1920x1080"}),+]+++def gateway(monkeypatch):+ import tools.schema_media as module+ from tools.provider_jobs import request_json++ calls = []+ media = "data:application/octet-stream;base64," + base64.b64encode(b"owned-output").decode()++ class Handler(BaseHTTPRequestHandler):+ def log_message(self, *args):+ pass++ def respond(self, data):+ content = json.dumps(data).encode()+ self.send_response(200)+ self.send_header("Content-Length", str(len(content)))+ self.end_headers()+ self.wfile.write(content)++ def do_POST(self):+ payload = json.loads(self.rfile.read(int(self.headers["Content-Length"])))+ calls.append(("POST", self.path, {"json": payload}))+ self.respond({"data": {"id": "owned-atlas"}} if self.path.startswith("/atlas/") else {"id": "owned-ltx"})++ def do_GET(self):+ calls.append(("GET", self.path, {}))+ self.respond({"data": {"status": "completed", "outputs": [media]}, "status": "completed", "result": {"video_url": media}})++ server = ThreadingHTTPServer(("127.0.0.1", 0), Handler)+ thread = Thread(target=server.serve_forever, kwargs={"poll_interval": 0.01})+ thread.start()++ def local_request(method, url, **kwargs):+ family = "atlas" if "atlascloud" in url else "ltx"+ local_url = f"http://127.0.0.1:{server.server_port}/{family}{urlparse(url).path}"+ return request_json(method, local_url, **kwargs)++ try:+ monkeypatch.setattr(module, "request_json", local_request)+ for name in ("ATLASCLOUD_API_KEY", "LTX_API_KEY"):+ monkeypatch.setenv(name, "owned-offline-key")+ yield calls+ finally:+ server.shutdown()+ server.server_close()+ thread.join(timeout=5)+ assert not thread.is_alive()++[email protected]("tool_type,field,reference,operation,extra", CASES)+def test_native_reference_selects_reference_route(tool_type, field, reference, operation, extra, gateway, tmp_path):+ tool = tool_type()+ result = tool.execute({"prompt": "Keep this source", field: reference, **extra, "output_path": str(tmp_path / "out.media")})+ assert result.success, result.error+ submission = next(kwargs["json"] for method, _, kwargs in gateway if method == "POST")+ assert submission.get(field) == reference, "The advertised source reference was lost before submission"+ assert result.data["operation"] == operation+ assert Path(result.data["output"]).read_bytes() == b"owned-output"+ assert sum(method == "POST" for method, _, _ in gateway) == 1++[email protected]("tool_type,field,reference,operation,extra", CASES)+def test_explicit_text_route_cannot_silently_drop_native_reference(tool_type, field, reference, operation, extra, gateway, tmp_path):+ tool = tool_type()+ result = tool.execute({"prompt": "Keep this source", field: reference, "operation": "generate", **extra, "output_path": str(tmp_path / "out.media")})+ assert not result.success, "Unsupported source input must be rejected before paid submission"+ assert field in result.error+ assert not any(method == "POST" for method, _, _ in gateway)++[email protected]("tool_type,field,reference,operation,extra", CASES)+def test_explicit_reference_route_preserves_native_reference(tool_type, field, reference, operation, extra, gateway, tmp_path):+ result = tool_type().execute({"prompt": "Keep this source", field: reference, "operation": operation, **extra, "output_path": str(tmp_path / "out.media")})+ assert result.success, result.error+ assert next(kwargs["json"] for method, _, kwargs in gateway if method == "POST")[field] == reference++[email protected]("tool_type,field,reference,operation,extra", CASES)+def test_text_only_request_keeps_text_route(tool_type, field, reference, operation, extra, gateway, tmp_path):+ result = tool_type().execute({"prompt": "A tree", **extra, "output_path": str(tmp_path / "out.media")})+ assert result.success, result.error+ assert result.data["operation"] == ("generate" if tool_type is AtlasRefreshImage else "text_to_video")+ assert field not in next(kwargs["json"] for method, _, kwargs in gateway if method == "POST")++[email protected]("tool_type,field,reference,operation,extra", CASES)+def test_canonical_reference_alias_keeps_existing_route(tool_type, field, reference, operation, extra, gateway, tmp_path):+ result = tool_type().execute({"prompt": "Keep this source", "image_url": "https://owned.example/source.png", **extra, "output_path": str(tmp_path / "out.media")})+ assert result.success, result.error+ assert result.data["operation"] == operation+ assert next(kwargs["json"] for method, _, kwargs in gateway if method == "POST")[field] == referencediff --git a/tools/schema_media.py b/tools/schema_media.pyindex ff0d0cfb..66c5bb64 100644--- a/tools/schema_media.py+++ b/tools/schema_media.py@@ -134,11 +134,13 @@ class SchemaMedia(BaseTool):def build_request(self, inputs):model = inputs.get("model", next(iter(self.models)))routes = self.models.get(model, {})- references = bool(- inputs.get("image_url")- or inputs.get("image_path")- or inputs.get("image_urls")- or inputs.get("image_paths")+ native_reference_fields = ("images", "image_input", "image", "image_uri")+ references = any(+ inputs.get(field)+ for field in (+ "image_url", "image_path", "image_urls", "image_paths",+ *native_reference_fields,+ ))operation = (inputs.get("generation_mode")@@ -158,6 +160,9 @@ class SchemaMedia(BaseTool):raise ValueError(f"Unsupported model/operation: {model}/{operation}")schema = self.contracts[endpoint]["input_schema"]props = schema["properties"]+ for field in native_reference_fields:+ if inputs.get(field) and field not in props:+ raise ValueError(f"{endpoint} does not accept {field}")payload = {k: v for k, v in inputs.items() if k in props and k != "model"}payload.update(inputs.get("provider_params") or {})if self.provider == "atlascloud":