Why Your AI Agent Is Slow (Hint: It's Not the Model)
When developers complain about slow AI agents, the first instinct is to blame the LLM. Switch models, upgrade tier, throw more compute at it.
But in most production agent systems, the bottleneck isn't the model at all — it's tool chain depth.
The Hidden Slowdown
Imagine your agent pipeline looks like this:
Tool A (fetch data) → Tool B (transform) → Tool C (write result)
Each tool waits for the previous one to finish. If Tool B hits a slow API or a lock, the entire chain stalls. Meanwhile your LLM is sitting idle, waiting.
This is tool chain depth: the more sequential your tool calls, the more chances for one slow link to poison everything.
Two Fixes That Actually Help
1. Parallelize Independent Tool Calls
Not all tools depend on each other. If your agent needs to fetch user data AND check inventory AND look up pricing, those three reads are often independent. Run them in parallel.
In practice, this means designing your agent's tool call sequence with a dependency map:
Parallel: [fetch_user, check_inventory, get_pricing]
→ depends_on: []
Sequential: [calculate_total]
→ depends_on: [fetch_user, check_inventory, get_pricing]
Simple to design. Significant latency reduction.
2. Add a Timeout Escalation Rule
Every external tool call should have a timeout, and the timeout should trigger a defined behavior — not silence.
A simple rule you can add to any SOUL.md or agent config:
If any tool call has not returned in 8 seconds:
- Write the pending task and context to escalation_log.json
- Surface the issue to the outbox
- Do not retry indefinitely
This pattern prevents one slow tool from cascading into a hung agent. Instead of waiting forever, the agent escalates and moves on.
Why Agents Wait When They Shouldn't
The default behavior for most agent frameworks is to block on tool calls. It's the safe default — you can't act on data you don't have yet.
But "blocking" and "waiting forever" are different things. A well-designed agent knows:
- What it's waiting for
- How long is too long
- What to do when that threshold is hit
Without explicit timeout rules, agents become passive. They're not stuck — they're just very, very patient.
The Real Bottleneck Checklist
Before blaming the model, check:
- Are sequential tool calls actually sequential by necessity? If not, parallelize.
- Do all tool calls have explicit timeouts? If not, add them.
- What happens when a tool times out? If the answer is "nothing," that's your bug.
- Is any tool calling another tool? Nested tool calls multiply latency. Flatten where possible.
- Are you logging tool call durations? You can't optimize what you can't measure.
Speed Is a Design Choice
Fast agents aren't lucky — they're designed. Parallelism, timeouts, and escalation rules aren't edge cases. They're the architecture.
If you're running production AI agents and want battle-tested configs for these patterns, the Ask Patrick Library has working examples: askpatrick.co
The circuit breaker, escalation rule, and parallelism patterns are all in there — ready to drop into your own SOUL.md.
Top comments (0)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.