Cutting Agent Token Costs with S3 Offloading and Paging
Agents that work over large structured data often re-inject the full payload into the model's context on every tool call. In Flightscape's crew training-schedule agent, built with LangGraph on Amazon Bedrock AgentCore, this pushed most requests past 15 seconds and filled the context window before reasoning finished on larger datasets.
Agents that work over large structured data often re-inject the full payload into the model's context on every tool call. In Flightscape's crew training-schedule agent, built with LangGraph on Amazon Bedrock AgentCore, this pushed most requests past 15 seconds and filled the context window before reasoning finished on larger datasets.
The authors' fix is to keep the conversation light and move bulk data out of it, in three composable layers. First, heavy artifacts — the request, response, and validation JSON — are written to Amazon S3, and AgentCore memory persists only references to them; at the start of a turn the agent rehydrates the live state from those references, and at the end it dehydrates back. References are content-addressed: the SHA-256 hash of the canonical JSON bytes becomes the key, so identical payloads map to the same object and re-serializing an unchanged request skips the upload. Second, oversized list results are no longer returned in full; the tool stores the list in S3 and returns a count, a small sample, and a handle, and the model calls a paging tool with offset and limit when it needs more. Third, oversized dictionaries get a compact descriptor that preserves structural cues instead of the full nested data. On a representative 23 MB payload, the authors report token use down up to 71% and average latency down up to 80%, with one turn dropping from nearly 2 minutes 46 seconds to about 15 seconds. Full data stays retrievable through handles, so capability is preserved; the numbers come from the authors' own benchmark runs rather than an independent comparison.
If your agent handles large JSON, find which tool outputs dominate the context window, then offload artifacts to object storage first and add paging and compaction as needed. Expect the biggest wins from never sending full payloads by default, and treat the reported 71%/80% figures as a single-workload result to validate on your own data.