Purdue's Multi-Agent AI Boosts Microservice Throughput by 36% for $1.28
A four-agent pipeline reasons across microservice boundaries using static analysis, hitting 36% throughput gains on a Java retail benchmark for about a dollar per run.
ProTakeaways
- Purdue team builds four-agent framework for whole-system microservice optimization using static analysis plus LLM reasoning.
- Prototype achieves 36.58% throughput gain and 27.81% response time reduction on TeaStore benchmark.
- Agents split into summarization, analysis, optimization, and evaluation roles operating over shared persistent state.
- Uses CodeQL for extracting call graphs and dependencies, LangGraph for agent orchestration.
- Full run costs $1.28 and 24 minutes using GPT-5.2, consuming about 1.6M tokens.
- Code available at PurdueDualityLab/agentic-code-optimization; correctness validated via JUnit test suites.
Most AI code optimizers today act like a junior engineer with tunnel vision. They stare at one function, tweak a loop, maybe swap a data structure, and move on. That works for tight numerical kernels, but the biggest wins in real systems usually hide in the seams between services, in how components share connections, hold locks, or serialize data. A new paper from Purdue, Amazon Robotics, and Loyola University Chicago argues that fixing this needs more than a smarter prompt. It needs a team of agents that can read a whole system the way a performance engineer would.
The work, titled Beyond Local Code Optimization, introduces a multi-agent framework that combines static program analysis with LLM reasoning to find and fix cross-component bottlenecks. On the TeaStore microservice benchmark, the prototype delivered a 36.58% increase in throughput and a 27.81% reduction in average response time, while preserving correctness.
Why local edits keep missing the point
LLM-based code optimization has mostly followed a pattern: feed the model a function, ask for a faster version, run tests. This works for localized optimizations, but real-world performance bottlenecks often emerge from interactions across multiple components and layers of a software system, such as databases, middleware, and shared infrastructure. As a result, purely function- or file-level reasoning struggles to capture whole system behavior or identify cross-cutting bottlenecks.
Think of the classic anti-patterns nobody catches at function scope: a REST client being reinstantiated on every call across six services, a stray synchronized method choking a hot path, or a fresh JSON mapper allocated per request. Each looks fine in isolation. Together they wreck throughput.
Four agents, one shared brain
The framework splits performance engineering into a stateful pipeline where agents operate over persistent representations produced by earlier stages, preserving architectural relationships, cross-component dependencies, and optimization context to enable whole system reasoning. The four roles are:
- Summarization Agent extracts what the system is. It is actually three sub-agents. A Component Summarization Agent extracts the structural architecture of the software system, mapping services, endpoints, and dependencies. A Behavior Summarization Agent models interprocedural control flow, database interactions, and concurrency constructs. An Environment Summary Agent captures build configs, compilers, and deployment artifacts.
- Analysis Agent ranks bottlenecks. It consumes structured representations of the system, such as call graphs, hotspots, dependency information, and static signals such as database access patterns and service interaction topologies, then produces an evidence-backed priority list with source locations and impact estimates.
- Optimization Agent writes the diffs. Critically, all modifications are constrained to be non-breaking, disallowing changes to public APIs or service interfaces, which keeps downstream services from breaking.
- Performance Evaluation Agent validates. Candidates that fail unit tests are rejected outright, then survivors are profiled under representative workloads and compared against baselines.
How the pipeline is wired together
The prototype is roughly 29 Python source files and a total of 8,000 lines of code. Orchestration uses LangGraph to implement the pipeline as a directed graph of modular agents (summarization, analysis, optimization, and evaluation) with explicit control flow and shared state, with LangSmith tracking intermediate states for reproducibility.
The static analysis backbone is CodeQL. CodeQL models source code as a queryable database over abstract syntax trees, control flow graphs, and call graphs, and the team wrote language-specific query packs that serialize component structure and execution patterns into a language-agnostic form the agents can consume. That decoupling matters, because it means the LLM never has to guess about call graphs. It reads facts extracted by a proven tool.
What the agents actually found
On TeaStore, a six-service Java retail app connected over REST APIs, the system converged on three optimizations that read like a performance engineer's greatest hits:
- HTTP client reuse. A Jersey client was being created per RESTClient constructor. The fix: a singleton with a shared connection pool to eliminate duplicate pools across microservices.
- Lock removal. A
synchronizedmethod on a maintenance-mode setter was blocking threads on the request path. Replaced with avolatileboolean for lock-free reads. - ObjectMapper sharing. A
new ObjectMapper()was being allocated per request insideAbstractUIServlet. Replaced with a shared static final instance.
The end-to-end numbers, measured under 800,000 requests via JMeter:
| Metric | Original | Optimized | Change |
|---|---|---|---|
| Throughput (req/sec) | 1197.79 | 1635.89 | +36.58% |
| Avg response time (ms) | 12.84 | 9.27 | -27.81% |
| P50 latency (ms) | 13.00 | 9.00 | -30.77% |
| P90 latency (ms) | 23.00 | 18.00 | -21.74% |
| P99 latency (ms) | 26.00 | 23.00 | -11.54% |
The full optimization run consumes approximately 1.6M tokens, costs $1.28, and takes roughly 24 minutes. That is cheap enough to run in CI, though the LLM used was gpt-5.2 at temperature 0.7.
The real breakthrough, and the caveats
The headline is the throughput number, but the deeper contribution is the architecture. By having static analysis do the heavy lifting on program structure and reserving the LLM for interpretation and code synthesis, the framework sidesteps a common failure mode where models hallucinate call graphs or invent dependencies. The agents reason from grounded evidence linked to source file locations, which also makes their suggestions auditable.
There are honest limits. This is a proof of concept on a single Java application. In the current prototype, correctness validation and performance evaluation are conducted separately from the system, with full integration into the automated pipeline left to future work. The team plans to expand to DeathStarBench and compare against baselines like SysLLMatic and agentic tools such as OpenCode and Codex. Generalization across languages, larger repos, and open-source LLMs is all future work.
For anyone maintaining a microservice stack, the useful takeaway is not that AI will rewrite your architecture tomorrow. It is that whole-system optimization is becoming tractable when you give agents the right scaffolding, and that scaffolding does not have to be exotic. Static analysis plus a graph of agents with clear roles gets you measurable wins for the price of a coffee.