Saltar al contenido
ES EN

How to Replicate an AI Agent's Overnight Optimization on Your Repo

A practical guide inspired by Google's ADK case: per-repo skills, a measurable goal, and human review for an agent to optimize your code.

AI for developers

Google has shared how they let an agent work unsupervised for 11 hours on the Agent Development Kit codebase, over 200,000 lines of Python. The result was two accepted optimizations. The interesting part isn't the model, but the method, and that can be adapted to any repository. Here's a summary of how to approach it, based on InfoQ's report and Google's original article.

Diagram of an AI agent analyzing a large code repository overnight
An agent can traverse an entire repository unsupervised, but someone needs to review the output.

What You Need

Before launching anything, it's good to have three pieces in place. First, a reliable test suite: the ADK has nearly 17,000 unit tests, and the agent ran all of them before finishing. Second, a way to measure performance before and after. Third, written repository guidelines for the agent, like those Google keeps in .agents/skills.

  • A coding agent with a persistent goal mode (Google used /goal in Antigravity).
  • Unit tests that run completely in a reasonable time.
  • Benchmarks to compare numbers before and after.
  • A human available to review the pull request the next day.

The Steps, in Order

  1. Do a short test run to discover which testing and benchmarking conventions the agent ignores.
  2. Write these conventions as skill files, like an onboarding guide for a new engineer, and ask the agent to load only what it needs to avoid filling its context window.
  3. Draft a single, measurable goal: no noticeable overhead, public API intact, one test per change, and a single pull request with before-and-after figures.
  4. Explicitly prohibit merging: the agent opens the pull request, never integrates it.
  5. Launch the long run and review the logs upon completion: guide reading, baselines, proposals, self-review, and complete tests.
  6. Review each change as if it were written by a person and discard anything that doesn't meet the bar.

How to Formulate the Goal

Google summarized its request in a single instruction with clear limits. We recommend adapting that structure to your project, changing the performance areas that matter to you. The essential thing is that the goal is verifiable and includes the constraint of not touching the public API.

/goal Reduce framework overhead at startup and during long sessions.
Keep the public API and what the model receives unchanged.
Back each change with a test that detects regressions.
Open a single pull request with before-and-after figures. Do not merge it.

What to Expect from the Result

In the ADK, the two accepted improvements filtered events before copying session history and lazily loaded heavy packages. They reduced the overhead of preparing the session in memory by 40% and cold import time by 21%. In a 158-turn execution with tools, the total dropped from 65.6 to 56.1 seconds.

Beware of expectations: Google also reported four modifications rejected after review due to concerns about reliability, maintainability, compatibility, or measurable benefit. Expect that some of what the agent proposes will not be used, and that reviewing, debugging, and testing remain the bottleneck. A single case also doesn't prove it will work the same way in any codebase.

Comparison of execution times before and after a performance optimization
Small gains per call accumulate in executions with many iterations.
Tip Demand before-and-after figures in the pull request description and also measure in your environment: a millisecond improvement only matters if it is repeated tens or hundreds of times, as in the ADK's tool-based workflows.

To learn more: Chinese edition · Events.

Original source: infoq.com

Article generated with AI.larebelion

Kernel

· Head of Technology · Spain

«An agent working overnight only saves time if, on Monday, the review costs less than what it optimized.»

Comentarios

Publicar un comentario