Architecting Antigravity: Agentic IaC, The Paper Tiger, & Conversational Scaffolding
Architectural Context & The Friction Problem
Building a factory that generates highly specialized, horizontal AI agents requires strict physical separation of concerns. As part of the Antigravity Agent Builder (AG_agentbuilder) ecosystem, we engineered a Master Scaffolder—a meta-agent designed to intake user ideas and output deterministic, ready-to-run directory blueprints for specialized worker agents.
However, extracting precise architectural parameters from operators faced a severe friction bottleneck. Initially, we forced users into a rigid, 10-point intake interview. While this guaranteed we gathered the necessary data (Success Criteria, Risk Level, Agent DNA), it crushed the creative brainstorming process and felt overly bureaucratic.
To resolve this conflict, we refactored the Master Scaffolder into a Conversational Brainstorming Protocol backed by Step 0: The MCP Discovery Protocol. Before any design begins, the Scaffolder dynamically queries its local environment to map all active Model Context Protocol (MCP) servers—from custom security monitors and Rust compilers to database and container tools.
The scaffolding engine now acts as a fluid brainstorming partner, engaging users organically to shape their ideas before internally synthesizing the conversation into our strict architectural schema. By separating the conversational UX from the underlying strict data extraction, we achieved high user engagement while maintaining absolute architectural integrity in the final blueprints.
Alternative Approaches Considered (The "Paper Tiger" Problem)
When designing the output of the AG_agentbuilder, our primary challenge was bridging the gap between static Markdown files and actual runtime execution. We refer to this as the "Paper Tiger" problem: generating beautiful, deterministic blueprints (AGENTS.md, SKILL.md, session_state.md) is useless if they are just a highly organized folder of text files with no execution engine.
We initially evaluated standard heavy orchestration frameworks like LangChain, CrewAI, or LangGraph. This would involve compiling the agent configurations directly into framework-specific Python objects. However, we quickly rejected this approach. Heavy frameworks introduce opaque execution traces, severe token bloat, and make it nearly impossible to debug infinite loops. They lock the architecture into rapidly depreciating abstractions.
Instead, we decided to ground the model using Stateless Python Orchestration (orchestrator.py), directly informed by the Antigravity Sourcebook (Gemini DEEP Antigravity Agentic IaC Optimization.md). The builder automatically outputs a lean, local Python orchestrator script alongside the Markdown files. This script treats agents as basic structs and tool executions as explicit state transitions, passing memory via transient session_state.md handoff files using an OpenAI Swarm-inspired pattern. This direct, zero-framework approach completely eliminates the "Paper Tiger" problem without trapping the user in a heavy graph ecosystem.
Zero-Trust Guardrails Deep-Dive
To enforce a highly deterministic, zero-trust architecture, the Antigravity factory implements a strict file topology. We do not trust the LLM to govern its own runtime permissions or manage massive contexts effectively.
Our architecture executes three primary guardrail strategies:
- The Tripartite Markdown Inheritance Model: We split monolithic prompts into three layers to prevent instruction drift, drawing from OpenClaw and Hermes patterns. SOUL.md handles global safety invariants, AGENTS.md handles local operational rules, and TASK.md handles the ephemeral user goal.
- YAML Agent DNA (CONTROL_MATRIX.yaml): To prevent infinite LLM loops and unauthorized API mutations, all execution policies are stripped from the prompt and placed in a strict YAML configuration (the Agile V governance pattern). The Python orchestrator enforces these parameters deterministically—such as retry_limit: 3, temperature settings set strictly to 0.0, and tool whitelists—regardless of LLM hallucinations.
- The Popov Router Pattern (Dynamic Skills): Preloading hundreds of SKILL.md files into the context window triggers token exhaustion and instruction competition. Instead, we use a single lightweight Router Agent that queries a .catalog-index.json via MCP and explicitly loads exactly one skill body at a time.
Before proposing any architecture, the Master Scaffolder runs an internal Quality Control Gate. If the user's request results in a monolithic "Super-Agent" or lacks programmatically testable success criteria, the system pushes back and forces architectural refinement.
Deployment & Multi-Environment Workflow
The blueprints generated by AG_agentbuilder are designed for immediate, local execution, avoiding the need for out-of-the-box GUI deployment. The output is a highly structured, GitOps-ready directory topology:
ag_agentbuilder/
├── orchestrator.py # Lightweight, stateless Python execution loop
├── evals.json # LLM-as-a-Judge validation schemas and regression tests
├── sessions/
│ └── session_state.md # Ephemeral, compacted memory handoff files
├── agents/
│ └── ag_planner/
│ ├── CONTROL_MATRIX.yaml # Agent DNA: Permissions, parameters, and metadata
│ └── AGENTS.md # Context layer: Role, constraints, and instructions
└── skills/
├── .catalog-index.json # Server-side searchable metadata index for dynamic loading
└── architecture_audit/
└── SKILL.md # Specialized, dynamically loaded skill logic
- Configuration Layer: The YAML CONTROL_MATRIX.yaml defines the Agent DNA and circuit breakers.
- Context Layer: Markdown-KV files provide highly structured, token-efficient context.
- Execution Layer: The orchestrator.py script routes LLM calls and executes verified MCP tools.
- Validation Layer: evals.json enforces LLM-as-a-Judge semantics and strict AST schema compliance.
By standardizing this output, developers can drop the generated folder into any environment and immediately begin execution via standard Python network sockets, maintaining environment parity across local and remote instances.
Lessons Learned & Future Scaling (Roadmap)
Building the AG_agentbuilder highlighted the necessity of separating the conversational UX from the rigid output schemas, and the critical importance of keeping orchestration stateless and grounded in physical file structures.
Our immediate roadmap focuses on three key architectural milestones:
- Implementing Markdown-KV Standards: Updating all template generation to use Markdown-KV (Key-Value) structures over standard tables, as empirical benchmarks demonstrate this increases LLM extraction accuracy by up to ~60.7%.
- Dynamic XML Delimiters: To eliminate the "Markdown Trojan" vulnerability (where injected user context mimics header structures), we are wrapping all untrusted runtime data in strict XML boundaries (<external_data>).
- Automated Event Compaction: As agents hand off tasks via session_state.md, the file grows rapidly. We are building a tiered summarization mechanism that compresses intermediate tool execution steps into dense summaries before passing the context state to the next agent, preserving the active token window.