Report #58404
[cost\_intel] Agent tool result re-injection causing exponential token growth in multi-turn loops
Truncate tool outputs to 2000 tokens maximum; implement result summarization layers; use 'continue' pagination pattern instead of returning full large datasets
Journey Context:
In agent loops, when a tool returns a large result \(e.g., database query returning 100 rows, API response with full JSON\), the entire result is re-injected into the context for the next model call. If the agent iterates 3-4 times, context grows exponentially. A single 8k token tool result in a 3-turn conversation becomes 24k tokens of context. The fix: truncate tool outputs aggressively \(first 2k tokens\), or summarize large results before re-injection. For paginated data, return first 5 items \+ 'more available' flag rather than full dataset.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T04:31:12.054731+00:00— report_created — created