Inspiration
Before a film or television production can be released, its insurer has to issue an Errors and Omissions policy, and no insurer will issue one without a script clearance report. The report is a legal audit of the screenplay that identifies anything in it which might belong to somebody in the real world. That includes character names that might match a real person, businesses and brands that might be registered trademarks, street addresses and phone numbers that might reach a real household, songs and artwork that are still under copyright, and any depiction of a real institution that its owner would object to.
The work is currently done by hand. A researcher reads every page, lists everything that falls into those categories, looks each one up against trademark registries and public records, and then writes an opinion on whether the production can use it as written. It takes several weeks and it is expensive.
The part that makes it worse is that the report only describes one version of the script. Screenplays are revised continuously during production, and revised pages are circulated on coloured paper so the crew knows which version they are holding, starting with white and moving through blue, pink, yellow, green and goldenrod. Every one of those revisions invalidates the report, because the clearance house has no record of what it already examined. A production that revises six times either commissions the audit six times or shoots pages that were never cleared.
What it does
CLEARCUT performs the same audit using a sequence of six agents, and stores the outcome so that later drafts of the same screenplay only require the differences to be examined again.
The screenplay is uploaded as a Final Draft PDF, a Fountain file or plain text. The parser reads scene headings and pagination directly from the file so that every finding can be cited to the page and scene it came from, which is how clearance reports are conventionally written.
The first agent reads the screenplay one scene at a time and lists everything in it that falls into one of seventeen clearance categories, recording the exact wording, the page and the scene. Reading scene by scene keeps the extraction accurate, but it cannot tell how the screenplay treats a subject overall, because that usually depends on scenes that appear much later. A hospital whose name is printed on a document in one scene looks harmless until a later scene reveals the document was forged. So a second pass reads the entire screenplay and produces a written summary of every wrongful act it contains, who commits it, and which named businesses, people and places are involved in each, and then marks each subject according to the role it plays in that summary. This matters because the legal position depends on both facts together. A real company mentioned in passing is usually fine to name. The same company shown committing fraud is not.
The second agent divides the list into subjects that an existing industry rule already settles and subjects that need to be looked up. Phone numbers are an example of the first. North American numbering reserves 555-0100 through 555-0199 for fiction, so a number inside that range is safe and a number outside it is not, and no research will change that answer. Vehicle registration plates are settled the same way for the opposite reason, since registration records are not public and searching for a plate returns nothing whether or not it is issued. For everything else, this agent writes the specific question that needs answering, phrased around the legal test that applies to that category rather than as a keyword search.
The third agent answers those questions. It is built with Google's Agent Development Kit and has three tools available to it. The first runs a web search and returns sources with excerpts. The second runs multi-step research for questions a single search cannot settle, such as tracing who controls the publishing and recording rights to a song. The third enumerates how many real businesses or people share a given name, which is what decides whether a common surname is usable. The agent chooses which tools to use for each subject and how many times, based on the category and on whether the screenplay depicts that subject negatively. In testing, a common surname with a neutral depiction required one search, a song required two tools and thirteen sources before the publisher and the administering company were both identified, and a named hospital shown producing falsified records required twenty.
The fourth agent issues a ruling on each subject, choosing between clear, clear with caution, must change, licence required, and refer to counsel. The standard it applies depends on the category. Songs almost always require two separate licences, one from the publisher for the composition and one from the record label for the recording, unless the work has entered the public domain. Artwork depends on whether copyright was renewed rather than on the date it was created. Character names depend on whether a real person of that name exists in the same profession or location as the character. After all the rulings are made, subjects that share a real-world referent are compared against each other, because an email address and the domain it belongs to can otherwise receive different verdicts from two correct applications of two different standards, and a report containing that contradiction is not defensible.
The fifth agent handles anything ruled must change. It proposes a replacement that keeps the same register, period and syllable count so that dialogue still reads correctly, and then sends that replacement back through the research and ruling stages to confirm the replacement is itself usable. Suggestions that fail are recorded and another is tried.
The sixth agent produces the report as a PDF with blocking items first, each finding showing the page it appears on, the wording as written, the ruling, the reasoning and the sources it relied on.
A person reviews and approves each of these six stages before the next one runs, and their decisions change what happens downstream rather than being recorded as comments. A subject that the reviewer dismisses is removed before any research is spent on it. A ruling the reviewer overrules is the ruling that appears in the report.
When the report is approved, every ruling is written to a per-production ledger, storing the subject, its category, the verdict, the reasoning, the sources and which draft it was first cleared in. When a later draft is uploaded, its subjects are compared against that ledger and only the differences are examined again. A subject carries forward only if its name, its category and the way the screenplay depicts it are all unchanged, because a company can keep its name between drafts while a newly added scene changes what the film shows it doing, and carrying the old ruling forward in that case would move a defamation risk into the finished film without anyone seeing it.
How I built it
The screenplay parsing, the extraction, the depiction assessment, the rulings and the replacement suggestions all run on Gemini through Vertex AI. The research agent is built with the Agent Development Kit, version 2.8, using its Agent and Runner classes, with the three research tools registered as ordinary Python functions whose signatures and docstrings the toolkit turns into the tool definitions the model sees.
The lookups are performed by Parallel. Its Search API answers the single-question lookups, and its Task API handles the multi-step research the agent escalates to.
The application is a FastAPI service that also serves the browser interface, running on Cloud Run. Both API keys are held in Secret Manager and mounted at runtime rather than included in the image. Images are built by Cloud Build. The ledger and the review sessions are stored in Cloud Storage, because Cloud Run gives each instance temporary local disk that is discarded when the instance is replaced, and a ledger that disappears when the service restarts would defeat its purpose.
Model responses and research results are cached on disk by a hash of the full request, so repeating a run costs nothing and produces the same output, which matters because a clearance report is a document somebody signs.
Challenges I ran into
Gemini 3.x models enable extended reasoning by default. On the extraction task this caused requests to hang indefinitely, while the identical request with reasoning disabled returned in about three seconds. The SDK's own timeout setting is not applied on that code path, so each request is now wrapped in a deadline enforced outside the SDK, and a request that exceeds it is abandoned and retried against the next model.
Model names differ between the AI Studio and Vertex AI endpoints, and availability varies by region, so the list of models to try is chosen according to which endpoint is in use. Requests move down that list on failure, models that fail repeatedly are moved to the end for the remainder of the run, and quota errors that reset daily are not retried at all since retrying cannot succeed.
The first Cloud Run deployment started successfully, reported healthy, served the interface and produced no findings at all. The deployment script had been written before the move to Vertex AI and did not set the environment variable that selects it, so the container was calling the AI Studio endpoint instead, and the service account it runs as had never been granted permission to call Vertex AI. Both are now handled by the deployment script.
Accomplishments that I'm proud of
The measurement harness, which scores a run against two sample screenplays with hand-written expected results covering thirty-eight subjects.
It identified an error in those expected results. The fixture recorded Edward Hopper's painting Nighthawks as requiring a licence. The system ruled it public domain, on the grounds that its copyright was never renewed after the initial twenty-eight year term, citing the Art Institute of Chicago's own records. The fixture was corrected.
It also identified a failure that no other check caught. A business that most of the film takes place inside was absent from four runs out of five, because its name only ever appears in scene headings and the extraction instructions were being read as referring to action and dialogue. The test suite passed, the interface worked and the report generated normally throughout.
What I learned
How reliably the depiction assessment performs depends on how much is asked of a single model call. Judging every subject against a full screenplay in one request produced results between 62% and 100% on identical input. Separating it into one call that records what the screenplay depicts and a second that judges subjects against that record reduced the standard deviation from 14.7 to 3.1.
Results over five runs per draft, each with an empty cache:
| Draft | White draft | Blue draft |
|---|---|---|
| Subjects found, of those expected | 100% (sd 0.0) | 100% (sd 0.0) |
| Depiction assessed correctly | 86.2% (sd 4.7) | 87.8% (sd 5.4) |
| Rulings matching the expected verdict | 68.9% (sd 2.7) | 67.1% (sd 2.9) |
The first row is the one that governs whether the system is usable, because a subject that is never found is never reviewed and never appears in the report, whereas a subject found unnecessarily costs a reviewer a few seconds. The third row is measured against one experienced reading of standard practice rather than against settled law, and where the system and that reading differ, the system rules more conservatively.
The method and the complete results are in docs/stability.md in the repository.
What's next
Extending the expected results beyond two drafts of one screenplay, and developing the ledger from a record of one production's clearances toward the wider set of rights a studio tracks, including music cue sheets and chain of title.
Built With
- cloud-build
- cloud-run
- cloud-storage
- css
- docker
- fastapi
- gemini
- google-adk
- google-cloud
- html
- javascript
- parallel
- pydantic
- pypdf
- pytest
- python
- reportlab
- secret-manager
- uvicorn
- vertex-ai
Log in or sign up for Devpost to join the conversation.