Last month an agent I had asked to wire up a screen transition stopped right before the same test. I pressed Retry, it stopped again, I pressed it again — and by the fourth time the only thing changing was my credit balance. My stomach had gone a little heavy.
Before the fourth press I finally read the last few lines of the log. It said cannot find module. What I needed was a dependency check, not another Retry.
Here is the short version: Retry is not an "undo" button. It is a tool that works on random failures and only on those. Below I'll walk through how I tell the two kinds apart, how I choose between the ways of retrying, and the three checks I run first.
One caveat. Menu labels and options around Retry differ by version and screen, so the three approaches below — rerun as is, edit the prompt and rerun, resume from a midpoint — are categories I use in my own head, not official fixed names. Map them to whatever your screen actually shows.
When Retry Helps and When It Doesn't
Retry fixes failures whose outcome changes from run to run:
- API rate limits or transient timeouts
- LLM output variance, where the same prompt sometimes works and sometimes doesn't
- Flaky package downloads
- Brief network blips
It does nothing for failures that come out the same every time:
- The prompt is ambiguous and the agent keeps misreading it
- A required file is outside the agent's context (
agents.md, project files) - A real type error or structural code problem
- Missing API keys or insufficient permissions
There is a trap in between. A network blip can interrupt a dependency install and leave the project half-built. The original cause was transient, but every failure after that is deterministic. Restore the state first, then retry.
My rule of thumb: if the same task has failed three times within an hour, I stop pressing Retry, because nothing in the log explains why a fourth run would differ.
Choosing How to Retry
Rerun with the same input
Same prompt, same files, run again.
- Good for: timeouts, rate limits, network flickers
- Bad for: misread instructions, missing dependencies
Edit the prompt, then rerun
This is the one I use most. Once the log shows what the agent misunderstood, I add only that piece.
I keep the edit to one or two sentences. If I rewrite the whole prompt, I can no longer tell which change fixed it, and nothing carries over to the next failure. Small edits accumulate into a personal playbook.
- Good for: ambiguous wording, an unnamed target file, unclear acceptance criteria
- Bad for: a wrong design — start a fresh task instead
Resume from a midpoint
If your screen offers it, resuming helps with late failures in long tasks: steps 1–4 passed, step 5 failed, and you only want step 5 again. Check what your version actually preserves before relying on it. When I suspect the early approach itself, I don't resume; I rebuild from the start.
- Good for: late-stage failures in multi-step tasks
- Bad for: broken early assumptions
Read the Last Ten Lines First
Before pressing Retry I spend about 30 seconds on the log — scanning for keywords, not reading everything.
| Log keyword | Likely cause | First move |
|---|---|---|
429 / rate limit / timeout | Transient | Wait, then rerun |
cannot find module / not found | Missing dependency | Check the install state |
unexpected token / syntax | Structural code issue | Add constraints to the prompt, then rerun |
permission denied / unauthorized | Auth or permissions | Fix keys and access before any rerun |
The real error almost always sits near the bottom. Ten lines read carefully beat hundreds scrolled past.
Where the run stopped matters too. If three files were written and the test step failed, the problem is usually local to test setup. If the very first action failed, the prompt or context never lined up.
For long tasks with output redirected to a file, I keep this helper in ~/.zshrc:
# Pull the most recent error lines from an agent log
# Usage: agentlog ./latest-agent.log
agentlog() {
local log_file="${1:-./latest-agent.log}"
if [ ! -f "$log_file" ]; then
echo "Log file not found: $log_file"
return 1
fi
echo "=== Last 20 lines ==="
tail -n 20 "$log_file"
echo "=== Error lines only ==="
grep -iE "error|fail|exception|denied" "$log_file" | tail -n 5
}
# Expected output:
# === Last 20 lines ===
# (the tail of the task log)
# === Error lines only ===
# Error: ECONNRESET
# Error: timeout after 30000msEven this turns Retry from a guess into a choice.
Three Checks Before Retrying
Deciding from scratch every time wears me down, so these three are fixed.
First, refresh the context. In long sessions the agent's picture of your project goes stale. I don't paste whole files; I point at the path and add one sentence about what changed — for example, "db/schema.ts now has a deletedAt column."
Second, reproduce the failure in a small task. The bigger the failing task, the more each Retry costs. A tiny separate task that triggers the same symptom narrows the cause at a fraction of the spend.
Third, consider switching models. Something that failed on Gemini has passed on a local Gemma 4 setup, and the reverse has happened too. I suspect each model misreads different things. The local side is covered in Antigravity with Ollama and Gemma: Local LLM Routing Design.
Check the Working Tree Before You Retry
The night of that fourth press taught me one more thing. By the time the agent stopped, it had already rewritten a handful of files. I kept pressing Retry on top of that half-finished state, and the failures looked identical each time — not because of the prompt, but because the ground under it was already broken.
Now I run three lines before pressing anything.
# See what actually changed first
git status --short
git diff --stat
# Stash the half-done changes before discarding anything
git stash push -u -m "before-retry"If the changes are within what I expected, I let the agent continue. If it touched files I never mentioned, I stash and then retry. Look at the current state once before fixing it. With the stash kept, I can also read the diff later and trace where the misunderstanding began.
Designing So Retry Stays Rare
If Retry is a daily habit, the problem is usually upstream.
Smaller tasks help most. "Create five files, write tests, deploy" has five places to fail and one redo covering all of them. I aim for units that finish in five to ten minutes.
I also put a one-line goal at the top of each task — for instance, "replace the legacy auth middleware with the session-based one; no behavior change for end users." When Retry keeps failing, I compare the agent's interpretation against that line. About half the time they don't match, and the fix is to correct the instruction, not to retry.
And after three failures in the same place, I close Antigravity and write the situation out by hand in a notebook. Typing never surfaced the assumption I'd missed; a pen somehow does.
For neighboring angles on the same problem, see Fixing Infinite Loops in Antigravity Agents and Optimizing Antigravity Credit Consumption. Retry quality and credit efficiency are two sides of the same coin.
Read the last ten lines before you press it — that is what turns Retry from a hope into a decision.
Next time you reach for Retry, open the last ten lines of the log first.