Reviewing a Bedrock Agent: From “Works” to “Works Efficiently”
I recently reviewed a Bedrock agent that was functionally correct — it answered queries, used tools properly, and produced accurate results.
👉 But it wasn’t efficient.
This is a quick summary of what was happening and what improved.
🧠 Initial Behavior: Reactive Execution
The agent followed a step-by-step loop:
Cycle 1 → resolve date via tool
Cycle 2 → fetch primary data
Cycle 3 → fetch additional data
Cycle 4 → fetch metadata
Cycle 5 → final response
What was happening?
No upfront planning
Data discovered incrementally
Each missing piece triggered another call
All operations were sequential
⏱️ Why a time tool existed
The agent handled queries like:
“first 10 days of last month”
Since LLMs don’t reliably know the current date, a time tool was added to:
ensure correct date calculations
avoid inconsistent outputs
👉 It solved correctness
👉 But added an extra cycle every time
🚨 Core Issue
The agent was reactive instead of planned
Do something → realize missing data → do more → repeat
Instead of:
Understand everything → execute once
🚀 Improvements
1. Provide current date directly
Removed dependency on time tool
Eliminated one full cycle
2. Upfront planning
The agent now:
identifies all required data
plans execution before acting
3. Parallel execution
Independent data is now fetched together instead of sequentially
4. Dependency awareness
Independent data → parallel
Dependent data → separate step only when required
✅ Final Execution Patterns
No dependency
Cycle 1 → fetch all data (parallel)
Cycle 2 → final response
With dependency
Cycle 1 → fetch base data (parallel)
Cycle 2 → fetch dependent data
Cycle 3 → final response
No comments:
Post a Comment