# The Hidden Tax in Your AI Agent: How Tool Call Roundtrips Are Killing Performance

- Canonical: https://www.baristalabs.io/blog/agentic-tool-call-optimization-roundtrips
- Published: 2026-02-28
- Author: Sean McLellan
- Excerpt: A game developer shaved 10x off his LLM runner overhead this week by attacking the roundtrip problem. Here is the teardown -- and what it means for anyone building agentic pipelines.

AI Development

Sean McLellan

Lead Architect & Founder

February 28, 2026 6 min read

Sebastian Aaltonen, a veteran game engine developer, posted a thread this weekend that deserves more attention than it got. In a week full of model announcements, he quietly dropped something more useful: a systematic breakdown of how he made his custom LLM runner [over 10x faster](https://x.com/SebAaltonen/status/2027847942527127556) in a single week -- without switching models or upgrading hardware.

The lever he pulled was not compute. It was architecture.

Specifically: the roundtrip problem.

## What a Roundtrip Actually Costs You

Here is what the naive agentic loop looks like in most implementations:

1. Send full prompt + history to the model
2. Model responds with a tool call (JSON)
3. Execute the tool
4. Send the **entire history again** -- prompt + all prior tool calls + responses -- plus the new result
5. Model responds with the next tool call
6. Repeat

Every iteration ships the entire accumulated context back to the API. On iteration one that is a few hundred tokens. By iteration ten, you might be sending 20,000+ tokens per call just to communicate what already happened. And each of those calls carries network latency on top of inference latency.

Aaltonen frames the two optimization targets clearly:

> Example
> 
> "We have two optimization targets: minimize the amount of tokens we dump to the LLM and minimize the amount of roundtrips, since each roundtrip sends all tokens again. Roundtrips also add latency as you need to send data to server and wait for the LLM again. Thus roundtrips are the most important thing to optimize. But since each roundtrip sends all the tokens again, optimizing the number of tokens each tool call adds is massively important too. Both must be optimized."

This is the core tension. Tokens and roundtrips are multiplicative, not additive. A 50% reduction in tokens per call combined with a 50% reduction in roundtrip count does not save you 50% -- it saves you 75%.

## Before: The Naive Pattern

Most tutorial-level agent implementations follow a single-tool-call-per-response pattern:

- LLM decides it needs to read a file: one roundtrip
- LLM decides it needs to check a directory: another roundtrip
- LLM decides it needs to search for a symbol: another roundtrip
- LLM has enough context to act: one final roundtrip

Four roundtrips. Each one carries the full growing context. If the first call added 500 tokens to history, and the second added another 500, the third call is already shipping 1,500 tokens of context overhead before you even get to your actual prompt.

At GPT-4o pricing, this is not just slow -- it is expensive. At o3 pricing, it is punishing.

Practical next step

Before this becomes a project, check the pilot risk.

If this article has you thinking about an AI agent inside a real workflow, start with the boring questions first: who approves the action, what data can the agent see, where does a human stay in the loop, and how will you know the pilot worked? BaristaLabs can use those readiness questions to help pressure-test a practical first pilot before you scope a build.

[Review pilot readiness with BaristaLabs](https://www.baristalabs.io/contact?offer=ai-pilot-readiness-checklist&placement=inline&source=blog&slug=agentic-tool-call-optimization-roundtrips)

Built for automation, agent, and compliance conversations. No PHI or sensitive workflow data required.

## After: What High-Performance Runners Do Differently

**Batch tool calls per response.** Modern model APIs -- including the OpenAI function calling spec -- support returning multiple tool calls in a single response. If the model can predict that it will need to read three files and query one database, it can issue all four calls simultaneously and get all four results in a single roundtrip. Most agent frameworks do not exploit this by default.

**Compress the history.** Instead of appending raw tool responses verbatim, summarize completed sub-tasks into compact state objects. "Read config.yaml: found DB connection string" is 8 tokens. The full YAML file is potentially thousands. The LLM only needs the result, not the transcript.

**Structure tool outputs for minimal token footprint.** Design your tool response schemas to return exactly what the next decision step needs -- no more. If your file-reading tool returns the entire file but the LLM only needs line counts and imports, you are paying for tokens it will never use.

**Use state machines instead of open-ended history.** For bounded workflows (form processing, data extraction, code review), structured state objects can replace the full message history entirely. The model receives current state, not a transcript of how it got there. This caps context growth regardless of task complexity.

## The Real-World Impact

Aaltonen reports gains that compound: fewer roundtrips mean less time waiting, and less time waiting means faster feedback on whether your tool design is even working. Debugging a 10-roundtrip workflow is an order of magnitude harder than debugging a 2-roundtrip one.

For production deployments, the implications extend beyond speed:

- **Cost ceiling**: A naive 10-roundtrip workflow at 5,000 tokens per call burns 50,000 tokens per task. An optimized 3-roundtrip workflow at 1,500 tokens per call burns 4,500 tokens. Same outcome, 11x cheaper.
- **Reliability**: Every roundtrip is a failure point. Network errors, rate limits, and context window overflows all become less likely when you send fewer, smaller requests.
- **Predictability**: Compact history means more consistent behavior. Long histories tend to cause the model to fixate on earlier decisions or lose track of the current goal.

## A 30-Minute Audit You Can Run Today

If you have an agentic pipeline in production or staging, here is a fast way to quantify your roundtrip overhead:

1. Add logging to capture `(call_number, prompt_token_count, completion_token_count)` for every model call in a sample task
2. Chart prompt token count by call number -- a linear increase signals naive history appending
3. Count how many tool calls appear in each completion -- anything below 1.5 average means you are leaving batching gains on the table
4. Identify your three highest-token tool responses and ask: does the model actually use all of that in the next step, or just a summary?

The pattern that surfaces in almost every audit: the first two calls are efficient, and everything after call three is paying compound interest on earlier verbosity.

## Framework Support Varies Widely

It is worth noting that roundtrip optimization is not uniformly supported across popular frameworks:

- **LangChain / LangGraph**: Multi-tool-call batching requires explicit configuration; default behavior is sequential
- **AutoGen**: Supports parallel tool calls in group chat patterns but not single-agent flows by default
- **OpenAI Assistants API**: Tool batching is supported in the function calling spec but depends on model behavior
- **Custom runners** (like Aaltonen's): Full control, full responsibility

If you are using a managed framework, check whether it is requesting parallel tool calls in the API payload (`parallel_tool_calls: true` in the OpenAI spec). If it is not, you are almost certainly leaving performance on the table.

## The Stack Question

None of this requires a new model. The gains Aaltonen achieved came from rethinking the communication layer between the model and the tools it calls -- the part most developers treat as boilerplate.

For teams evaluating whether to build custom runners versus using managed frameworks: this is one of the strongest arguments for the custom path. Frameworks optimize for developer experience. Custom runners can optimize for token efficiency and roundtrip minimization. The gap is measurable and, at scale, financially significant.

Related: [How AI Agents Are Reshaping Workflow Orchestration for Small Business](https://www.baristalabs.io/blog/ai-agents-workflow-orchestration-small-business-guide) -- and [The 3 Endpoint Decisions That Change Agent Rollouts](https://www.baristalabs.io/blog/the-3-endpoint-decisions-that-change-agent-rollouts) for more on structuring agentic deployment decisions.

AI Pilot Readiness Checklist

Turn the idea into a pilot you can defend.

AI agent articles are easy to bookmark and hard to operationalize. Use the readiness questions as a shared way to decide whether a workflow is specific enough, safe enough, and measurable enough to pilot. If they surface a strong candidate, BaristaLabs can review it with you and help shape a first version that fits your systems, approval process, and risk tolerance.

[Turn this into a pilot plan](https://www.baristalabs.io/contact?offer=ai-pilot-readiness-checklist&placement=end&source=blog&slug=agentic-tool-call-optimization-roundtrips) [Talk through a pilot candidate with BaristaLabs](https://www.baristalabs.io/contact?offer=ai-pilot-readiness-checklist&intent=pilot-readiness-review&placement=end&source=blog&slug=agentic-tool-call-optimization-roundtrips)

Please do not submit PHI, customer records, credentials, or confidential workflow exports.

Practical AI Workflow Notes

## Enjoyed this? Get our plain-English workflow notes.

We send occasional short notes on putting AI to work in everyday operations, from taming messy documents and customer follow-ups to simple reporting and safety guardrails.

Email address

Send me the notes

A relaxed way to stay in touch if you're still exploring and aren't ready to chat yet.

Occasional emails with practical ideas only. Unsubscribe anytime.

Next step

## What should you automate first?

Spot the repeatable work worth automating, then build systems that save time without adding complexity.

[Map your automation opportunities](https://www.baristalabs.io/contact?placement=sidebar&source=blog&slug=agentic-tool-call-optimization-roundtrips)

- Workflow maps cover systems, handoffs, human approvals, monitoring, and failure paths.
- Discovery narrows repetitive work into the first automation candidate before tool selection.

![Sean McLellan profile photo](https://www.baristalabs.io/profile-sean-mclellan.jpg)

## Sean McLellan

Lead Architect & Founder

Sean McLellan is the founder and lead architect at BaristaLabs. He brings more than two decades of software architecture experience to BaristaLabs products and client work for small teams. Client work starts with an assessment of one workflow. Fixed-scope discovery then defines a bounded pilot, explicit human-review boundaries, and the source-traceable proof needed for the next decision.

[More articles by Sean McLellan](https://www.baristalabs.io/authors/sean-mclellan)

[Twitter](https://twitter.com/seanmclellan) [GitHub](https://github.com/seanmclellan)
