Performance and cost
AWS Details Amazon Bedrock AgentCore JSON Strategies That Cut Agent Tokens Up to 71% and Latency Up to 80%
AWS describes how a Flightscape crew-scheduling agent on Amazon Bedrock AgentCore used S3 artifact offloading, on-demand result paging and dictionary compaction to cut tokens by up to 71% and average latency by up to 80% on a 23 MB payload.
AWS has published a set of context-management techniques for agents that process large JSON payloads, drawn from a Training Schedule Optimization agent it built for Flightscape, an airline operations platform. According to the post, the agent is built with LangGraph, LangChain's open-source orchestration framework, runs on Amazon Bedrock AgentCore, and uses 40-plus tools to check crew training assignments against business rules. AWS says most calls in production exceeded 15 seconds on average because every tool invocation injected its full payload into the model's context; on larger datasets the context window filled up before the agent finished reasoning.
The first of three composable strategies moves heavy artifacts out of conversational state. Request JSON, response JSON, validation reports and cached statistics are written to Amazon Simple Storage Service (Amazon S3), while AgentCore memory persists only lightweight references. References are derived from the payload itself: the JSON is serialized with sorted keys and compact separators, and the SHA-256 digest of those bytes becomes the key. AWS says this content addressing makes writes idempotent, so an unchanged request reuses an existing object instead of being uploaded again, and the S3 wrapper keeps an in-process cache to avoid duplicate round trips within one invocation. When a session resumes, the agent rehydrates full state from the references.
The second strategy targets oversized list results from tools. AWS says some single tool responses exceeded 80,000 tokens. Lists above a threshold are now stored whole in S3, and the model first receives a total count, a small sample and a result handle; it can then call a paging tool with an offset and limit to fetch only the slice it needs. The third strategy compacts oversized dictionaries into descriptors: list fields report a count and sample, nested dictionaries report only a key count, and scalar values stay inline where useful, with the full payload still reachable through the handle. A character limit acts as a fallback.
AWS reports before-and-after runs on the same dataset and questions. In a five-question conversation, it says total token usage fell from roughly 289,500 to roughly 82,900, about 71%, while average trace latency fell from 15.4 seconds to 3.1 seconds, nearly 80%. Across 100 sample questions, total tokens dropped from 23.6 million to 8.5 million, a 64% reduction, and average trace latency from 7,930 ms to 2,461 ms, a 69% reduction. For the heaviest single query, which listed valid crews across every validation category, input tokens fell from about 32,000 to about 8,000, output tokens from about 2,800 to 477, and turn latency from about 165 seconds to 9.9 seconds, a 94% reduction.
It is reasonable to infer from these figures that the gains come mainly from stopping full payload injection every turn: the model receives compact summaries first and pulls detail only on demand, shifting long conversations from compounding token cost toward a demand-driven access pattern. The percentages are AWS's own measurements on a representative 23 MB payload and should not be read as a general guarantee across models or datasets; results will depend on tool output shapes and how an agent fetches data. AWS says companion code is available in a GitHub repository and lists prerequisites including an AWS account with Amazon Bedrock model access, an S3 bucket, AgentCore memory enabled for session persistence, a LangGraph-based agent with tool-calling support, and Python 3.12+ with boto3, langchain-core and langgraph. For developers building agents over large structured data, the approach offers a way to cut cost and latency without changing the underlying model.