Hi everyone,
Following Smitha Kolan’s deep dive on building autonomous, self-correcting multi-agent systems using the Google Agent Development Kit (ADK), our engineering team implemented the Loop Agent + Validation Checker architecture to solve an enterprise domain-parsing challenge: ingesting and structuring multi-scene screenplay documents for physical film and television production.
The Problem with Single-Shot Ingestion
In media production, screenplays adhere to strict formatting standards (Courier 12pt, slugline syntax, character cues, parentheticals, and fractional page counts calculated in eighths of a page).
Single-shot LLM prompts frequently introduce edge-case hallucinations: dropping scene headers, miscalculating running page-eighths, or missing non-dialogue character mentions needed for cast day-out-of-days (DOOD) matrices. For production operations, even a minor parsing error cascades into bad scheduling and budget variance.
Our Architecture: ReAct & Self-Correcting Loops
Inspired by the ADK RobustBlogWriter pattern, we decoupled ingestion into an isolated, self-healing loop:
-
Parser Agent (
Gemini 1.5 Pro/Flash): Extracts raw scene text, assigns slugline metadata (INT/EXT,DAY/NIGHT), breaks down page-eighths, and tags production elements (Cast, Props, Vehicles, Wardrobe). Writes output to the shared state keyparsed_scene_payload. -
Deterministic & Semantic Validation Checker Agent: Evaluates the state payload against strict schema and mathematical rules:
-
Do fractional page lengths strictly conform to base-8 fractions?
-
Are standard scene sluglines formatted cleanly without stray characters?
-
Are tagged elements categorized strictly within domain taxonomy?
-
Output: Emits
OKon clean audit, orRETRY: [Missing Slugline / Fraction Mismatch]with actionable diagnostic notes.
-
-
Loop Agent Wrapper: Manages up to 3 automated retry passes in memory. The parser consumes the checker’s explicit diagnostic feedback, self-corrects the payload, and validates before persisting a single byte to our SQLite WAL database.
-
Root Orchestrator: Sits upstream, holding no heavy breakdown logic itself, dispatching the parsing loop, schedule sentinel loops, and ledger audit loops as modular subagent tools.
Questions for the Community & ADK Team
As we move this architecture into production workloads across active productions, we would love input on three architectural questions:
-
Context & State Pruning Across Loops: In multi-pass loops with large scene chunks, what is the recommended pattern within ADK for pruning or compressing intermediate error tracebacks in shared state so subagent context windows don’t accumulate unnecessary token bloat on pass 2 and 3?
-
Hybrid Validation Agents (AST/Regex + LLM): Have teams found it more efficient to implement the
ValidationCheckeras a pure Python programmatic agent (deterministic AST/Regex assertions) rather than an LLM agent, or does a hybrid approach yield better error recovery prompts back to the generator? -
MCP Tool Structuring: For those wiring ADK root agents to external database backends (e.g., Model Context Protocol servers), what is the preferred pattern for ensuring transactional rollbacks if a multi-agent loop aborts after exceeding its retry limit?
Kudos to Smitha and the Google Cloud Tech team for providing such a clean, production-grade mental model with ADK. Looking forward to hearing how others are structuring domain-specific validation loops!
Sabrina J. Swenson
Founder & CEO, FAST OS / Swenson Media