Long-Horizon Agentic Coding Test: Building a Video-Generation SaaS Platform from Scratch

    This article reports a stress test in which an AI coding tool was asked to build a commercial-grade UGC video-generation SaaS platform from scratch under spec-driven development (SDD). The platform lets users upload images and automatically generates short product-promotion videos. The article covers the five technical domains involved, the three-phase SDD workflow, key architecture details such as asynchronous generation, idempotent credit handling, and row-level security, plus the results and pitfalls from a roughly three-hour build. The conclusion is that AI coding has reached a new level, but it replaces execution rather than judgment; the reusable lesson is to front-load architecture decisions and use specifications as anchors against context drift.

    Over the past year, the capability boundary of intelligent coding tools has expanded rapidly. At first they could complete only a few lines of code; later they could generate single-file scripts. Recently, industry discussion has shifted from “does the generated web page look good?” to three harder directions: agentic capabilities, long-horizon tasks, and system engineering. The core question is this: can a large model act like a senior architect, autonomously decompose system-level requirements, and stay contextually coherent, on track, and not forgetful during multi-hour automated tasks?

    To test this, I designed a deliberately demanding experiment: have an intelligent coding tool build a commercial-grade UGC video-generation SaaS platform from scratch. Users upload images, and the system automatically generates short product-promotion videos. The whole process used spec-driven development (SDD), requiring the tool to follow a strict “research → architecture → development” flow. This article reviews the full process and extracts a reusable methodology.

    Why This Project Is a Touchstone for Long-Horizon Tasks

    Many people think asking AI to write code means generating a demo page. But a truly commercial-grade SaaS platform grows exponentially in complexity. This project spans at least five technical domains:

    1. Backend services: Build RESTful APIs on a mainstream Python web framework such as FastAPI to handle user requests, task submission, and status queries.
    2. Database design: Use a relational database such as PostgreSQL to design user tables, task tables, and credit ledger tables, and configure row-level security (RLS) policies to ensure multi-tenant data isolation.
    3. Asynchronous task scheduling: Video generation usually takes minutes, so it must not run as a synchronous blocking call. A message queue and polling/callback mechanism are required.
    4. Authentication and billing: Phone-number OTP login, JWT token issuance and refresh, user credit deduction, and refunds on failure—every link in the chain must work correctly.
    5. Frontend interaction: Upload components, generation progress display, historical work lists, and credit balance display require a complete user interface.

    This is not a “write code” problem at all; it is a “system architecture” problem. In the past, few small development teams would have dared to touch it. That is exactly what makes it a good scenario for testing long-horizon task capability: the task chain is long, modules are tightly coupled, and any design mistake in one link will erupt later across the system.

    The Product Logic Behind the Topic

    Why choose a video-generation platform? There is a counterintuitive observation behind this choice. I previously enjoyed sharing automation workflows and teaching people how to chain model APIs to generate videos. But after deeper conversations with cross-border e-commerce practitioners, I found that they do not want to learn workflows at all. They only care about ROI: is the cost per video 0.5 yuan or 5 yuan? Can it reliably produce thousands per day? Is there a ready-made platform where one click produces a video?

    This shift in understanding is critical: in the AI era, turning tools directly into products is more valuable than teaching users to build tools. So the goal became clear: build a SaaS website where users upload product images and the system automatically composes promotional short videos, delivering the “fish” directly to users. This also meant the project had to have real production-grade characteristics, not a toy demo.

    Methodology: How Spec-Driven Development Constrains AI

    Directly telling AI “build me a video-generation website” almost inevitably fails—it gets stuck in local implementation and loses the global picture. I adopted spec-driven development and split the task into three mandatory phases:

    Phase 1: Research and requirements specification. The AI was required to first output a complete requirements document: user roles, core flows, feature list, and non-functional requirements such as concurrency, availability, and cost. The document had to be detailed down to the input and output parameters of every API, not vague generalities.

    Phase 2: Architecture design. After requirements were confirmed, the AI was required to output an architecture diagram and technology-selection notes: how services are layered, how the queue is selected, how table schemas are designed, how RLS policies are written, and how idempotent credit deduction is guaranteed. The output of this phase became the “constitution” for subsequent coding.

    Phase 3: Module-by-module development. Implementation strictly followed the architecture document, module by module. After each module, the AI was required to provide self-checks and integration notes to avoid “forgetting earlier parts while writing later ones.”

    The value of this model is that it front-loads human architectural judgment and back-loads AI execution, using documents as anchors in the long context to combat the context drift that is most common in long-horizon tasks.

    Key Architecture Implementation Details

    Several design points are worth expanding on from the actual build:

    Asynchronous generation chain. After a user submits a generation request, the backend immediately returns a task ID and writes it to the task table with status pending, while pushing the task into a message queue. A worker consumes the task and calls the video-generation capability, updating the status to processing during execution. When complete, it writes the result URL and sets the status to success. The frontend queries progress through a polling API. Timeout, retry, and failure compensation must be handled properly; otherwise users’ credits can be deducted for nothing.

    Idempotency of credit deduction. The correct approach is “freeze first, settle later”: freeze credits when the task is submitted, actually deduct them when the task succeeds, and unfreeze and return them on failure. All ledger records go into an independent table for traceability. Under specification constraints, AI can get this right in one pass. But without a spec document, it easily produces a simplified version that deducts directly and ignores failures.

    Row-level security and multi-tenant isolation. Database row-level security policies ensure that each user can query only their own tasks and works, blocking privilege-escalation risk at the storage layer instead of relying on discipline at the application layer.

    Test Results and Pitfalls

    Conclusion first: AI coding has indeed entered the next level, but it replaces execution, not judgment.

    The whole project actually took about three hours to complete, including extra waiting time caused by tight compute resources and slower generation. I also hit pitfalls along the way. For example, in the later stage of a long context, the AI forgot table schema fields defined earlier, causing frontend-backend field mismatches. The solution was to force it to re-reference the relevant definitions in the architecture document before starting each module. Another example: the initial design for asynchronous polling frequency was too aggressive and required manual adjustment.

    Overall, the quality of system-level requirement decomposition and the maintenance of cross-module consistency are already far beyond the category of “code-completion tools.” But the precondition is that the user must have architectural thinking and must use specification documents to frame AI on the correct track. For independent developers and small teams, this means projects that previously required weeks of multi-person collaboration can now produce a working prototype in hours with one person. The value of the tool is not that it thinks for you, but that it lands the results of your thinking at ten times the speed.

    Finally, three suggestions for readers who also want to try long-horizon tasks: first, always write the specification before writing code; second, use the architecture document as a repeatedly referenced anchor against context drift; third, manually review the three chains of billing, authentication, and data isolation—these are where AI is most likely to “look right while actually missing something.”