This post was originally published on this site

I watched the discussion on agentic loops grow louder over the past few months. But for me, the reality is simpler: prompt engineering has shifted from individual tasks to systems design, and the harness around the model (not the model itself) is now my primary constraint in software engineering. In this article, I’ll show you how to build and verify those harnesses so you can move from single-turn instructions to durable agentic loops in Google Antigravity.

Not all tasks are equal

You can categorize the work that we give to our agents into five distinct tiers, scaling from a quick question up through Agile tasks, stories, and epics to a continuous system:

  1. A simple question: This does not require an agent; an assistant can answer it.

  2. A task / idea: This is one where a single prompt can zero-shot it. Use Google AI Studio to quickly transform ideas to functional prototypes.

  3. An app / larger feature / story: The kind of work that required weekly planning and splitting into subtasks before AI. Use loops for execution and full-featured agents, like Google Antigravity. This tier is also where your steering moves upstream: You lock in the spec, the plan, and the executable tests before any loop runs.

  4. A project / epic: A few features that make a cohesive story when connected. Loops here might help with planning too. This is also where one needs to go beyond simple turn-based prompting.

  5. A system: An overview of all of the projects and tasks. This is where you write AGENTS.md project instructions, create skills, set up sidecars, wire up verification gates, and configure an instrument cluster to keep themselves on top of everything. Loops at this level make the biggest difference and come with similarly higher risks.

how-to-build-durable-agentic-systems-with-google-antigravity-from-instructions-to-loops_fig1-five-tiers-to-loops

Figure 1: Five tiers of engineering work, from single prompts to verified agentic loops.

Why the loop?

The baseline of software development is shifting. This shift represents a basic law of human nature: we seek the highest leverage possible, moving from manual labor to delegation, and finally to orchestration. Because attention is the new bottleneck, anything that lets the work continue with less interruption could make a move in the right direction. By early 2026, empirical research of open-source projects estimated that coding agent adoption had reached between 22% and 29% of more than 128,000 active repositories on GitHub. Those who become proficient in agentic workflows now operate with a level of leverage that elevates their entire team’s productivity. However, it also increases the cognitive load on everyone who is taking responsibility at the systemic level.

To understand this shift, let’s trace the technical lineage of loops and set some high level expectations.

Academic foundations

The academic seed was Yao et al.’s ReAct paper in October 2022, which interleaved reasoning traces with tool calls. ReAct beat reinforcement learning baselines by 34% on ALFWorld and 10% on WebShop by reasoning before acting, mirroring human nature: we perform better when verbalizing plans. Then came AutoGPT in early 2023, raising millions in venture funding. While early iterations of ReAct frequently spun in infinite loops, it proved developers wanted hands-off automation, highlighting the need for structural guardrails.

Stateless experimentation

In mid-2025, developers ran stateless bash loops that piped prompts into command-line agents and reset context files on every tick. Resetting context prevents cognitive bloat and acknowledges that human memory limits also apply to models. Stateless bash loops worked only because the durable state lived outside the model: in Git history, in progress files, and in the test suite. It successfully built self-hosting compilers over months of automated runs. By spring 2026, major tool environments absorbed this pattern, shipping native commands like /goal to let agents run unattended loops.

The mathematics of autonomy

Consider a theoretical example:

If you put your agent in a flat sequential chain to complete multiple tasks in a row, the agent’s success rate degrades exponentially. When each of its individual steps operates as an independent probability event, a sequence of N steps has a cumulative success rate of pN. For instance, if you run a task requiring 20 consecutive file modifications with a model that has p = 0.95 accuracy, then you face a success rate of only 36%. Without your structural interventions, they will fail almost certainly.

Is 0.95 a real number? Treat it as an illustrative per-step reliability, not as a benchmark result. Even a frontier model reaches reliable multi-step outcomes only when it runs inside a verified harness. If your own per-step reliability sits closer to 75%, then the raw chain is already under 6% by step 10. The verification around the model sets the ceiling, which is why the loop matters.

This is why you need evaluation loops. A verification gate should not force your agent to retry indefinitely (which causes infinite spinning runaways). Instead, it should pinpoint where the error occurred and allow the model exactly one targeted retry to fix it. If your agent has a 95% base accuracy, and your evaluation loop has a 95% chance of spotting and fixing the error on that single retry, the effective step success probability rises to 0.95 + (0.05 x 0.95) = 99.75%.

That arithmetic assumes the check is independent of the worker, so the gate has to be an outside check. Compilers, test suites, and linters give you that for free, and behavioral evaluations let you assert on discrete tool calls and intermediate actions in seconds instead of waiting on a full end-to-end benchmark. For semantic judgments that a deterministic test cannot make, I pair models from different families so the reviewer does not share the worker’s blind spot.

Even if fixing fails, just spotting the error with a 95% accuracy, lets you jump in and manually realign the system while keeping the same 99.75% subagent accuracy and only paying the cost of human-in-the-loop intervention.

The table below shows the probability of completion across different chain lengths, comparing raw models to this single-retry course-correction topology:

Chain Length

95% Accuracy

95% x 95% Loop

3 Steps

86%

99%

5 Steps

77%

99%

10 Steps

60%

98%

15 Steps

46%

96%

20 Steps

36%

95%

30 Steps

21%

93%

50 Steps

8%

88%

What about context bloat?

If each step in a chain adds approximately 1% of context in tokens, you end up with a chain that is not much longer than 50 steps before we require compression. A 95% base accuracy that can be evaluated (and course corrected with 95% accuracy for each dimension that we care about) should keep you at good success rates for such individual running agents. If you establish a scalable way to divide and conquer problems, you can apply similar principles to drive your subagents. As we can see, at 20 steps, a 95% accuracy paired with a single-retry corrective loop yields a 95% end-to-end success rate (assuming the correction itself stays under our 20 steps soft limit) while keeping context size reasonable. Note that there is no explicit requirement for the correction to be AI or human driven, but rather it needs to produce accurate and verifiable results.

This is where you divide problems into tasks that require a small number of steps each. If a problem is more complex, it remains approachable, but it must be divided into smaller subproblems, and so on. For our example, this means allocating up to 20 steps for each level agent, task, and trajectory and another 20 steps for the next level supervisory agent to consolidate contributions. To prevent drift, establish separate evaluations at all subagent and supervisory levels with a final acceptance criteria.

Lastly, you must evaluate these metrics at least once for each level to verify that they measure the right target before running automation at a higher level. These are general estimations, but help you quickly decide whether you should split a problem, repeat a step, or commit results and move on.

In practice, your numbers will look different, but the scaling laws will be similar.

How to build a durable system

What started as a source of friction has now become one of my primary driving curiosities: how do we build automation when we still have a lot to learn about the craft itself? I have a few ideas.

To build a loop that does not run off a cliff, you must establish core guardrails that will keep accuracy high and will allow us to debug and intervene whenever necessary. Specifically, these are the pillars I identified:

  1. Durable state: Git-backed checkpoints ensure that your agent can resume work after a crash.

  2. Verification gates: Automated test suites and compilers deterministically check that the changes are correct. Write the acceptance criteria and the tests upstream, before implementation starts, and make one rule explicit in your project instructions: an agent cannot pass a gate by deleting or weakening a test. When done properly, gates can have >95% accuracy. However, you should be on the lookout for edge cases you might have forgotten about. Especially if verification, evaluation, or manual validation success rates diverge for any of your features.

  3. Evals: Anything that cannot be deterministically verified but is important should have an evaluation or benchmark which you can later inspect for accuracy. Try to write them in a way that will keep answers to a simple yes or no and accuracy high, ideally over 95%. If you’re getting results that point to confusion or unexpected failures, you probably need to split the criteria into simpler ones.

  4. Halt conditions: Turn limits (as we saw above, 20 seems to be the sweet spot) and token or dollar cost ceilings stop runs before API budgets get out of control.

  5. Standardized skills and instructions: Reusable utilities, documented in the SKILL.md format, preferably bundled with code and source of truth references. Pair them with an AGENTS.md that holds the project invariants every run load. Skills stay on disk until their description matches the task, so they do not eat into the 20-step context window.

These pillars don’t name a model version, but rather a model family. Individual model leads last only weeks. The asset that survives each release is the harness and its processes: the AGENTS.md instructions every run loads, the SKILL.md modules loaded only when relevant, the isolated Cloud Run sandbox where the loop runs around the clock, the deterministic checks, and the cross-model review. When a run fails or you have to intervene, patch your harness along with the code: a new test, a line in AGENTS.md, a note in the skill. The next run inherits the lesson even though its context starts from zero.

Platform built-in systems

Platforms like Google Antigravity have codified these patterns (/grill-me and /goal) into built-in primitives, shifting the work from custom scripts to platform capabilities for most straightforward use cases. The same harness files travel with the repository whether you run Google Antigravity 2.0, the agy CLI, or Antigravity inside VS Code, JetBrains, or Cursor. I would encourage you to give these a try. Do remember, however, to keep an eye on trajectory lengths and look for model confusion.

I myself frequently rely on the /goal primitives in Google Antigravity 2.0 when coordinating multi-turn tasks that require extensive validation and measurements before completion. To anchor this execution, use the /grill-me command for an interactive interview to lock in design constraints, invariants, and the tests that decide success before running /goal loops.

Constructing the metrics for this technical article and then editing it is just one example of how I use these execution loops.

By pairing /goal with /grill-me, you can establish an effective pair-programming dynamic: alignment on intent, followed by autonomy in execution.

Custom DIY loops

To understand the evolution of loops, compare two distinct architectures for DIY agentic loops:

Stateless five-liner

Geoffrey Huntley’s “Ralph” loop is a prime example of stateless architecture. Here’s the simplest working version of an Antigravity CLI loop:

code_block
<ListValue: [StructValue([('code', 'limit=20rnfor ((i=1; i<=limit; i++)); dorn agy -p "$(cat prompt.md)" –sandbox || breakrn ./commit-and-test && breakrndone'), ('language', 'lang-py'), ('caption', )])]>

While simple, the stateless loop is fragile for multi-file coordination because resetting context discards thinking logs.

A good agent skill could fix much of this limitation by instructing the model to output relevant progress reports in wiki-like markdown files and track changes by looking at git logs.

Still, this complexity has led to developer challenges in larger multi-agent environments, for which custom loops seem to hold the promise.

So what if you want to go to the deep end?

If you want to write a custom loop from scratch, here is a practical Python implementation using the Google Antigravity SDK. Specifically, this loop does the following actions:

  • Initializes a supervisor session.

  • Executes a task.

  • Verifies the output with the real test suite.

  • Feeds the actual failure output back for exactly one targeted retry.

  • Enforces strict call and token budgets.

Not every task inside it is equal, so neither is the model. The supervisor and the implementer run on Gemini 4 Carbon because orchestration, architecture, and the complex fixes need frontier reasoning, codebase search goes to Gemini 4 Hydrogen, and verification goes to a deterministic script that costs no tokens at all. The Guide to AI Tokenomics covers the budgeting side of this split. Far from being a production-ready solution, this is an experimental starting point that you can adapt to suit your individual needs:

how-to-build-durable-agentic-systems-with-google-antigravity-from-instructions-to-loops_fig2-supervisory-harness-loop

Figure 2: Budgeted supervisory verification loop in the Google Antigravity SDK.

code_block
tuple[bool, str]:rn “””Verification gate: run the test suite and keep the real failure output.”””rn result = subprocess.run(rn [“go”, “test”, “./…”], cwd=workspace_path, capture_output=True, text=Truern )rn output = (result.stdout + “\n” + result.stderr).strip()rn return result.returncode == 0, outputrnrn# 1. Define subagents with scoped tools and a model that fits each jobrnresearcher = types.SubagentConfig(rn name=”researcher”,rn description=”Searches the codebase and summarizes implementation paths.”,rn system_instructions=(rn “You are a research subagent. Analyze the codebase, find implementation “rn “paths, and report back without modifying any files.”rn ),rn model=”gemini-4-hydrogen”,rn capabilities=types.SubagentCapabilities(rn enabled_tools=[rn types.BuiltinTools.VIEW_FILE,rn types.BuiltinTools.SEARCH_DIR,rn types.BuiltinTools.FIND_FILE,rn ],rn ),rn)rnrnfeature_implementer = types.SubagentConfig(rn name=”feature_implementer”,rn description=”Implements a scoped code change and keeps the tests passing.”,rn system_instructions=(rn “You are a feature implementation subagent. Follow AGENTS.md, write “rn “clean code, run the tests, and fix compiler errors. Never delete or “rn “weaken a test to make it pass.”rn ),rn model=”gemini-4-carbon”,rn capabilities=types.SubagentCapabilities(rn enabled_tools=[rn types.BuiltinTools.VIEW_FILE,rn types.BuiltinTools.EDIT_FILE,rn types.BuiltinTools.CREATE_FILE,rn types.BuiltinTools.RUN_COMMAND,rn ],rn ),rn)rnrn# 2. Expose both subagents to the supervisor, with a 20-call and token budgetrnsupervisor_config = LocalAgentConfig(rn model=”gemini-4-carbon”,rn workspaces=[“./workspace”],rn subagents=[researcher, feature_implementer],rn policies=[policy.allow_all()],rn budget_config=types.BudgetConfig(rn max_model_calls=20,rn max_total_tokens=200_000,rn ),rn system_instructions=(rn “You are a supervisor agent. Delegate codebase exploration to “rn “@researcher and code changes to @feature_implementer. Summarize each “rn “completed step before moving on.”rn ),rn)rnrnasync def run_agentic_loop(prompt: str, max_retries: int = 1) -> bool:rn “””Supervisory loop. We only instantiate and run the supervisor explicitly.”””rn async with Agent(supervisor_config) as supervisor:rn for attempt in range(1, max_retries + 2):rn print(f”[Supervisor Loop] Attempt {attempt}/{max_retries + 1}…”)rnrn # Send prompt to the supervisor; it spawns subagents autonomously as neededrn response = await supervisor.chat(prompt)rn await response.text() # Drain the stream before reading the stop reasonrnrn # Halt condition: the SDK stops the turn when a budget is exceededrn if response.stop_reason in (rn types.StopReason.MAX_MODEL_CALLS_EXCEEDED,rn types.StopReason.MAX_TOTAL_TOKENS_EXCEEDED,rn ):rn print(f”Loop halted: budget exceeded ({response.stop_reason}).”)rn return Falsernrn usage = supervisor.conversation.total_usagern print(f”Tokens used so far: {usage.total_token_count or 0:,} / 200,000″)rnrn # Verification gate: deterministic, and independent of the workerrn success, error_msg = verify_output(“./workspace”)rn if success:rn print(“Goal completed: verification gate passed.”)rn return Truernrn # Exactly one targeted retry, with the real failure outputrn prompt = (rn “The previous attempt failed verification with the following output:\n”rn f”{error_msg}\n”rn “Delegate a targeted fix to @feature_implementer and run the tests again.”rn )rnrn print(“Verification still failing after the retry. Handing over to a human.”)rn return Falsernrnif __name__ == “__main__”:rn asyncio.run(run_agentic_loop(“Refactor types.go to use explicit interfaces.”))’), (‘language’, ‘lang-py’), (‘caption’, )])]>

The preceding implementation defines the following budgets: 

  1. max_model_calls=20, a soft limit, counted across the supervisor’s whole session

  2. max_total_tokens=200_000 as the cost ceiling

The SDK stops the turn and reports a stop_reason when either one trips. max_retries=1 limits each section: the first attempt plus one fix. If the verification still fails after that, the loop returns False and a human takes the seat instead of the model spinning until the budget runs out.

If you prefer not to build and host your own custom SDK loops from scratch, use Antigravity Agent, an autonomous, asynchronous coding agent. Antigravity Agent operates in a secure, isolated Google Cloud sandbox. This way you can create similar agentic loops by using managed agents to orchestrate execution plans under Google managed infrastructure. Alternatively, you can run the preceding loop inside a long-lived Cloud Run sandbox so that the loop keeps working after you close your laptop.

No one size fits all

You must establish a clear boundary for each of your validation systems that lets you  stay in control. No matter how perfect your loop, if you, as the responsible human, cannot sign off on your agent’s output, there is minimal value in any of the artifacts it is producing. The good news is that building a quality evaluation scorecard or a loop algorithm uses a similar process to producing any other type of software artifact. So, much of the execution will be automated.

Finally, to make a sound judgment, you should observe each loop from the inside. As you see things working out, with this acquired confidence you step one level up. This is the only way to learn where the agent struggles and how to improve the process itself.