From 58237f0e7abdb1de3466e23bc3a27699a50f111c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 23 Jun 2026 02:33:35 +0000 Subject: [PATCH 1/3] feat(video): quality=high routes to true 720p I2V (single-chunk longform); --longform flag - orchestrator: --longform forces the I2V generative path even for chunks=1 (hero single clip); long-form triggers on (longform or chunks>1). - gateway: high preset -> longform=True (single-chunk I2V-720P + mci), refine_mode cleared; cmd passes --longform. seconds->frames only when not longform. - tests: single-chunk longform; high preset asserts longform. 22 pass. Co-authored-by: FluffyAIcode --- services/agent_gateway/server.py | 25 +++++++++++-------- services/distributed_wan/grpc_orchestrator.py | 6 ++++- tests/tools/test_agent_gateway.py | 10 +++++--- tests/tools/test_distributed_wan_pipeline.py | 20 +++++++++++++++ 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/services/agent_gateway/server.py b/services/agent_gateway/server.py index 6745fa2ef..c5d87e30d 100644 --- a/services/agent_gateway/server.py +++ b/services/agent_gateway/server.py @@ -160,9 +160,12 @@ def _auth(x_api_key: Optional[str] = Header(default=None)): "standard": {"fw_width": 480, "fw_height": 256, "fw_frames": 13, "proposer_steps": 6, "refine_steps": 16, "out_width": 832, "out_height": 480, "frames": 25, "fps": 12, "interpolate": 1, "interp_method": "linear", "refine_mode": ""}, + # high = the true 720p generative hero path: single-chunk I2V (longform) on the CUDA i2v worker, + # + optical-flow (mci) smoothing. Slower (~minutes) but matches the validated quality. "high": {"fw_width": 512, "fw_height": 288, "fw_frames": 17, "proposer_steps": 8, - "refine_steps": 24, "out_width": 1280, "out_height": 720, "frames": 25, - "fps": 24, "interpolate": 2, "interp_method": "mci", "refine_mode": "single"}, + "refine_steps": 22, "out_width": 1280, "out_height": 720, "frames": 25, + "fps": 24, "interpolate": 2, "interp_method": "mci", "refine_mode": "", + "longform": True, "chunk_frames": 25, "chunk_overlap": 4}, } @@ -203,15 +206,17 @@ def resolved(self) -> dict: p["seed"] = self.seed p["seconds"] = self.seconds or 0.0 p["chunks"] = self.chunks or 1 - p["chunk_frames"] = self.chunk_frames or 25 - p["chunk_overlap"] = self.chunk_overlap if self.chunk_overlap is not None else 4 - # Long-form (opt-in): derive chunk count from target seconds when longform is requested. - if self.longform and p["chunks"] == 1 and p["seconds"] > 0: + p["chunk_frames"] = self.chunk_frames or p.get("chunk_frames", 25) + p["chunk_overlap"] = self.chunk_overlap if self.chunk_overlap is not None else p.get("chunk_overlap", 4) + # longform = explicit request OR preset (high). Single-chunk longform = the true-720p I2V path. + p["longform"] = bool(self.longform or p.get("longform", False)) + # Long-form: derive chunk count from target seconds when longform is requested. + if p["longform"] and p["chunks"] == 1 and p["seconds"] > 0: net = max(1, p["chunk_frames"] - p["chunk_overlap"]) want = round(p["seconds"] * p["fps"]) if want > p["chunk_frames"]: p["chunks"] = max(1, math.ceil((want - p["chunk_overlap"]) / net)) - if p["chunks"] == 1 and p["seconds"] > 0: # single-pass: seconds drives frame count + if not p["longform"] and p["chunks"] == 1 and p["seconds"] > 0: # single-pass: seconds->frames p["frames"] = max(2, round(p["seconds"] * p["fps"])) p["quality"] = self.quality return p @@ -252,9 +257,9 @@ def _run_video_job(job: Job): cmd += ["--seconds", str(p["seconds"])] if p.get("refine_mode"): # quality preset / explicit override of refine topology cmd += ["--refine-mode", p["refine_mode"]] - if p.get("chunks", 1) > 1: # long-form (autoregressive I2V continuity) - cmd += ["--chunks", str(p["chunks"]), "--chunk-frames", str(p["chunk_frames"]), - "--chunk-overlap", str(p["chunk_overlap"])] + if p.get("longform") or p.get("chunks", 1) > 1: # I2V generative path (single or multi-chunk) + cmd += ["--longform", "--chunks", str(p.get("chunks", 1)), + "--chunk-frames", str(p["chunk_frames"]), "--chunk-overlap", str(p["chunk_overlap"])] if POOL_MODE: cmd.append("--no-refine") # each pooled worker is a single framework-only GPU (Mac MLX) elif GW_MODE == "pipeline": diff --git a/services/distributed_wan/grpc_orchestrator.py b/services/distributed_wan/grpc_orchestrator.py index 9ba6cd678..f1d9ba1ec 100644 --- a/services/distributed_wan/grpc_orchestrator.py +++ b/services/distributed_wan/grpc_orchestrator.py @@ -227,6 +227,9 @@ def main(): help="interpolation: 'linear' (blend) or 'mci' (ffmpeg motion-compensated / " "optical-flow — RIFE-class smoothness; falls back to linear if unavailable).") # Long-form (ADR 0015 Phase 2): chunked autoregressive generation with I2V continuity. + ap.add_argument("--longform", action="store_true", + help="force the I2V generative path even for a single chunk (chunks=1) — the " + "true-720p hero path on an i2v worker. >1 chunks is multi-chunk continuity.") ap.add_argument("--chunks", type=int, default=1, help=">1 enables long-form: N chunks generated autoregressively (chunk N+1 seeded " "by the last frame of chunk N via I2V) and crossfade-stitched.") @@ -250,7 +253,8 @@ def main(): # seeded by the last frame of chunk N via I2V (continuity), then crossfade-stitched. Runs on an # i2v-capable worker (the CUDA box with CUDA_I2V_MODEL); falls back to independent T2V chunks # (no continuity) with a warning if no i2v worker is present. - if args.chunks > 1: + if args.longform or args.chunks > 1: + args.chunks = max(1, args.chunks) i2v_workers = [w for w in workers if "i2v" in w.ops] cont = bool(i2v_workers) ow, oh = args.out_width, args.out_height diff --git a/tests/tools/test_agent_gateway.py b/tests/tools/test_agent_gateway.py index 5fcaff47c..40e2ac73b 100644 --- a/tests/tools/test_agent_gateway.py +++ b/tests/tools/test_agent_gateway.py @@ -33,6 +33,7 @@ def client(tmp_path, monkeypatch): " ap.add_argument(a)\n" "ap.add_argument('--no-refine',action='store_true')\n" "ap.add_argument('--single-refine',action='store_true')\n" + "ap.add_argument('--longform',action='store_true')\n" "ap.add_argument('--refine-spread')\n" "x=ap.parse_args()\n" "print('[orch] framework: 5%',flush=True)\n" @@ -125,8 +126,9 @@ def _mode_fixture(tmp_path, monkeypatch, *, workers, mode_env): "for a in ['--prompt','--out','--frames','--fw-width','--fw-height','--fw-frames','--proposer-steps','--refine-steps','--seed','--out-width','--out-height','--refine-spread','--fps','--interpolate','--interp-method','--refine-mode','--seconds','--chunks','--chunk-frames','--chunk-overlap']: ap.add_argument(a)\n" "ap.add_argument('--no-refine',action='store_true')\n" "ap.add_argument('--single-refine',action='store_true')\n" + "ap.add_argument('--longform',action='store_true')\n" "x=ap.parse_args()\n" - "flags={'single_refine':x.single_refine,'no_refine':x.no_refine,'refine_spread':x.refine_spread,'workers':os.environ.get('WAN_WORKERS',''),'fps':x.fps,'interpolate':x.interpolate,'interp_method':x.interp_method,'refine_mode':x.refine_mode,'out_width':x.out_width,'frames':x.frames,'seconds':x.seconds,'refine_steps':x.refine_steps,'chunks':x.chunks,'chunk_frames':x.chunk_frames,'chunk_overlap':x.chunk_overlap}\n" + "flags={'single_refine':x.single_refine,'no_refine':x.no_refine,'refine_spread':x.refine_spread,'workers':os.environ.get('WAN_WORKERS',''),'fps':x.fps,'interpolate':x.interpolate,'interp_method':x.interp_method,'refine_mode':x.refine_mode,'out_width':x.out_width,'frames':x.frames,'seconds':x.seconds,'refine_steps':x.refine_steps,'chunks':x.chunks,'chunk_frames':x.chunk_frames,'chunk_overlap':x.chunk_overlap,'longform':x.longform}\n" "print('[orch] refine: 100%',flush=True)\n" "p=pathlib.Path(x.out); p.parent.mkdir(parents=True,exist_ok=True); p.write_bytes(b'MODEMP4')\n" "print('FLAGS '+json.dumps(flags),flush=True)\n" @@ -195,8 +197,9 @@ def test_quality_presets(tmp_path, monkeypatch): # high: seam-free full-frame generative refine on the best refiner, hi-res, smoother fh = _job_flags(c, c.post("/v1/videos", json={"prompt": "hero clip", "quality": "high"}).json()["job_id"]) assert fh["out_width"] == "1280" and fh["fps"] == "24" and fh["interpolate"] == "2" - assert fh["refine_mode"] == "single" and fh["refine_steps"] == "24" - assert fh["interp_method"] == "mci" # high uses optical-flow interpolation + assert fh["interp_method"] == "mci" # high uses optical-flow interpolation + assert fh["longform"] is True # high = true 720p I2V generative path + assert fh["refine_mode"] is None # longform supersedes refine topology # draft: proposer-only direct fd = _job_flags(c, c.post("/v1/videos", json={"prompt": "draft clip", "quality": "draft"}).json()["job_id"]) assert fd["refine_mode"] == "direct" @@ -252,6 +255,7 @@ def test_pool_mode_two_macs(tmp_path, monkeypatch): "for a in ['--prompt','--out','--frames','--fw-width','--fw-height','--fw-frames','--proposer-steps','--refine-steps','--seed','--out-width','--out-height','--fps','--interpolate','--interp-method','--refine-mode','--seconds','--chunks','--chunk-frames','--chunk-overlap']: ap.add_argument(a)\n" "ap.add_argument('--no-refine',action='store_true')\n" "ap.add_argument('--single-refine',action='store_true')\n" + "ap.add_argument('--longform',action='store_true')\n" "ap.add_argument('--refine-spread')\n" "x=ap.parse_args()\n" "assert x.no_refine, 'pool mode must pass --no-refine'\n" diff --git a/tests/tools/test_distributed_wan_pipeline.py b/tests/tools/test_distributed_wan_pipeline.py index 41b7f57ba..0cda4be4d 100644 --- a/tests/tools/test_distributed_wan_pipeline.py +++ b/tests/tools/test_distributed_wan_pipeline.py @@ -168,6 +168,26 @@ def test_orchestrator_longform_chunks(tmp_path): gen.stop(0) +def test_orchestrator_longform_single_chunk(tmp_path): + """--longform with chunks=1 (quality=high path) -> a single I2V generative clip at out-res.""" + gen, p_gen = _serve(["framework", "t2v", "i2v"]) + import time as _t + _t.sleep(0.5) + try: + out = tmp_path / "hero.mp4" + env = {**os.environ, "WAN_WORKERS": f"127.0.0.1:{p_gen}"} + proc = subprocess.run( + [sys.executable, str(DWAN / "grpc_orchestrator.py"), "--prompt", "a fox", "--longform", + "--chunks", "1", "--chunk-frames", "13", "--out-width", "64", "--out-height", "48", + "--out", str(out)], env=env, capture_output=True, text=True, timeout=120) + assert out.exists(), proc.stdout + proc.stderr + info = json.loads([l for l in proc.stdout.splitlines() if l.startswith("ORCH_DONE")][-1].split(" ", 1)[1]) + assert info["mode"] == "longform" and info["continuity"] == "i2v" and info["chunks"] == 1 + assert info["px"] == [48, 64] + finally: + gen.stop(0) + + def test_orchestrator_refine_mode_single_fps_interp(tmp_path): """--refine-mode single (quality path) + --fps/--interpolate: forces a seam-free full-frame refine on the best refiner and the output frame count reflects interpolation.""" From 202c61aaf3e4056aca5fb935f8093b9f31bd077f Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 23 Jun 2026 02:39:36 +0000 Subject: [PATCH 2/3] =?UTF-8?q?docs(loop-log):=20iteration=2040=20?= =?UTF-8?q?=E2=80=94=20deploy=20PR#5=20to=20public=20gateway=20+=20quality?= =?UTF-8?q?=3Dhigh->720p=20I2V=20(verified=20public)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: FluffyAIcode --- docs/adr/0001-kakeya-integration-loop-log.md | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/adr/0001-kakeya-integration-loop-log.md b/docs/adr/0001-kakeya-integration-loop-log.md index 9b5128f76..9715373c9 100644 --- a/docs/adr/0001-kakeya-integration-loop-log.md +++ b/docs/adr/0001-kakeya-integration-loop-log.md @@ -1122,6 +1122,30 @@ auto-recovery. (Caveat: the ~84 G I2V model re-downloads unless `HF_HOME` is on --- +## Iteration 40 — Gap A closed: deploy PR#5 to agent.kakeya.ai + wire quality=high → true 720p I2V + +**Honesty correction:** Iter 36–39 results were from DIRECT orchestrator runs. The live public gateway +was still PR#4 (no presets/refine-mode/chunks/mci) — confirmed by `grep` on the deployed code + +`healthz mode=distributed`. So `agent.kakeya.ai` was serving distributed-tiled (~480p mix), NOT the +720p I2V I had summarized. Owned + fixed. + +**Deployed:** head repo → `main` (PR#5) then the `quality=high→I2V` follow-up; gateway restarted. +Wired `quality=high` to the **true-720p hero path**: orchestrator `--longform` forces the I2V +generative path even at chunks=1; `high` preset → `longform=True` (+ mci x2). Multi-chunk continuity +via `chunks=N` / `longform+seconds`. + +**Verified through the PUBLIC endpoint** (`agent.kakeya.ai`, not direct): +- multi-chunk: `{chunks:2,out 1280x720}` → `mode=longform continuity=i2v px=[720,1280] frames=46` → + public download ffprobe **h264 1280×720, 46f, 2.875s**. +- one-flag hero: `{quality:"high"}` → `mode=longform chunks=1 px=[720,1280] frames=47` → public + ffprobe **h264 1280×720, 47f, 1.96s**, gen≈211 s. + +**Honest tiers now:** default/`standard` = fast distributed tiled (~480p, ~2 s); `high` = true 720p I2V +generative + optical-flow (~3.5 min); `longform`/`chunks` = multi-chunk continuity (minutes×N). Gap B +(full OpenMontage agent + all skills behind the gateway; `agent_runtime=false`) remains — separate plan. + +--- + ## Open follow-ups (next iterations) - **Phase 2b — native gRPC transport.** Add an optional `kakeya` Python SDK transport for the bounded-memory long-context path (W3), behind the same tool, once the proto From dc35a3857ccf91dde8196b23360a74aaec10e274 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 23 Jun 2026 02:52:49 +0000 Subject: [PATCH 3/3] feat(gateway-ui): expose Quality (high=720p I2V default) + Length selectors so UI users get the hero path Root cause of 'UI output is poor': the web form posted a bare prompt -> default standard -> distributed tiled (~480p, 2s). Now the UI sends quality (default high=720p I2V) + length (short/5s/8s -> longform multi-shot). Co-authored-by: FluffyAIcode --- services/agent_gateway/server.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/services/agent_gateway/server.py b/services/agent_gateway/server.py index c5d87e30d..95e64e235 100644 --- a/services/agent_gateway/server.py +++ b/services/agent_gateway/server.py @@ -417,15 +417,32 @@ def index(): border:1px solid #1c2942;border-radius:10px;padding:12px;font-size:12.5px;color:#a9c2e6} video{width:100%;border-radius:12px;margin-top:12px;background:#000} input[type=password]{padding:10px;border-radius:8px;border:1px solid #2a3a59;background:#0e1830;color:#e7eefc} +select{padding:10px;border-radius:8px;border:1px solid #2a3a59;background:#0e1830;color:#e7eefc;font:inherit} +label{color:#8fa6c8;font-size:13px;display:block;margin-bottom:4px} +.opts{display:flex;gap:14px;flex-wrap:wrap;margin-top:12px}

OpenMontage — Agent Video

-

Describe a clip. The distributed cluster (MLX proposer + CUDA refiner) renders it.

+

Describe a clip. The distributed cluster (MLX proposer + CUDA / I2V refiner) renders it.

+
+
+
+
+
+
-

Direct text→video via /v1/videos. First render can take a few minutes.

+

High = native 720p generative (I2V) — best quality, a few minutes. Standard = fast ~480p draft. Longer = multi-shot I2V continuity (minutes × shots).