SI Agent News
ReportedGeminiAgents

Google uses Gemini to optimize 200,000-line codebase overnight

Google engineers used an AI agent to identify and fix performance bottlenecks in their Agent Development Kit, reducing overhead in long sessions.

40%Reduction in session-preparation overhead

The short version

Why it matters

This demonstrates that AI agents can handle 'brownfield' projects—existing, complex codebases—rather than just starting from scratch. It shows how small, compounded performance gains can significantly improve the speed of long-running AI workflows.

Optimizing complex existing code

Google engineers recently conducted an experiment to see how an AI model could handle a large, existing codebase. They chose to optimize the Google Agent Development Kit (ADK), which consists of over 200,000 lines of Python code spread across roughly 800 files. This task is significantly harder than building a new application from scratch because the model must understand how various parts of the system interact.

The team wanted to move beyond 'greenfield' development, where an AI starts with an empty folder. In a production environment, a model must navigate established conventions, dependencies, and existing logic. To succeed, the agent had to understand the entire map of how the codebase fits together over a long period of execution.

Performance work is a particularly difficult test for an AI because the source of a slowdown is rarely obvious. You cannot simply look at one file to find a bottleneck. Instead, the model had to look at the system orthogonally to identify where the symptoms appeared and determine the root cause across multiple modules.

The AI's onboarding and execution

To guide the AI, engineers provided repository-specific guidelines through special files. They described these as being like an onboarding guide for a new human engineer. These instructions ensured the agent followed the team's specific conventions for benchmarking and unit testing while also preventing it from flooding its context window with unnecessary data.

The engineers used a specific prompt to ensure the goal remained consistent during the process. They instructed the agent to make the ADK add no noticeable overhead to any agent, specifically during startup, in long sessions, and in multi-agent setups. The model was told to keep the public API unchanged and to back every single modification with a test that would catch any regressions.

As infoq.com reported, the logs showed that the Gemini 4 Argon model successfully read the guidelines and established performance baselines. It then proposed optimizations, reviewed its own changes, and ran all 16,892 open-source unit tests before finishing. This automated cycle allowed the agent to perform the heavy lifting of cross-module legwork that a standard profiler cannot do alone.

Technical gains and compounding effects

The agent ultimately produced two optimizations that were accepted into the codebase. One change improved how the ADK handled session history by filtering events before they were copied. The second change introduced lazy loading, which prevents heavy packages from being imported until the moment they are actually needed.

These specific improvements resulted in a 40% reduction in in-memory session preparation and a 21% reduction in cold package import times. While these numbers might seem small on a single interaction that takes only a few seconds, they compound significantly in complex workflows. For example, a human might not notice a difference of 28 milliseconds in a single call.

However, in a sequence of 158 internal turns of tool calling, these small gains add up. The experiment showed that removing this framework overhead cut a full run from 65.6 seconds down to 56.1 seconds. This means nearly 10 seconds of pure framework overhead were eliminated by the AI's optimizations.

Human oversight and next steps

Despite the success of the two accepted changes, the experiment also highlighted the current limitations of AI agents. Out of the four modifications the model proposed, two were rejected by the human developers. These rejections were based on concerns regarding reliability, maintainability, compatibility, or a lack of measurable performance benefits.

This indicates that while AI can perform the initial research and coding, human intervention remains necessary for the final stages of the pipeline. Tasks such as pull request reviews, complex debugging, and final testing still require a human touch to ensure the code meets production standards. The model can do the 'heavy lifting' of tracing callers and shared references, but it cannot yet replace the final judgment of a maintainer.

The findings confirm that AI agents are becoming capable of modifying existing codebases successfully. However, the time and effort required for post-coding tasks remain a bottleneck. Future development will likely focus on making these review and debugging steps more efficient as models become better at predicting human preferences.

What to watch

Try it

Look for 'lazy loading' patterns in your own Python projects to see if you can defer heavy imports until they are actually called.

Sources and links

Liked it? Say why

Add a line for other readers.

No account needed. We never show your email. Comments with links, ads or abuse are held and not shown. Your comment shows after a quick check.

Listen to the AI Wire headlines

Listen to the AI Wire

Listen to our daily AI shows every morning: on your commute, in the shower, wherever you are

Listen to the daily shows

First reported by infoq.com · Read the original. Written by the SI Agent News Desk from the reporting above.Written with AI from the source above. Every number is checked against the source. Spot a mistake? Corrections.