AWS cuts token use and latency for large-JSON agents
AWS Machine Learning Blog details three composable strategies used in Flightscape’s Training Schedule Optimization agent: offloading large artifacts to Amazon S3, paging tool results, and compacting context. The production agent handles JSON payloads larger than 20 MB and provides more than 40 tools for crew scheduling, resource allocation, and business-rule validation. On AWS’s internal benchmark with a 23 MB payload, the optimizations reduced token consumption by up to 71% and average latency by up to 80%.
The account provides a practical architecture for production agents that repeatedly process large structured inputs without repeatedly injecting full payloads into the model context.
As enterprises build production agents with dozens of tools and large structured inputs, token consumption and latency become the primary blockers to a good user experience. When these agents process large JSON data, every additional tool invocation injects the full payload into the large language model (LLM) context window, causing token usage and response latency to spike. Over multi-turn conversations, this pressure compounds, driving up costs and degrading response quality. Effectively managing context-window pressure in agentic systems is key to reliability and responsiveness at scale. In this post, we share three composable strategies we used to build a production agent for Flightscape that handles 20 MB+ JSON payloads. You can apply them to reduce token costs, lower latency, and maintain full reasoning capability across extended sessions. Together, these optimizations reduced token consumption by up to 71% and cut average latency by up to 80% across our benchmark runs on a representative 23 MB payload.
Solution overview
Flightscape is an airline operations platform that helps airlines plan and manage their crews, flights, and operations. As part of Flightscape’s crew management capabilities, we built a Training Schedule Optimization agent that verifies crew training schedule assignments against business rules. With 40+ tools and JSON inputs in megabytes, this agent could answer complex queries across crew assignments, scheduling, and resource allocation. Although the agent delivered the required functionality, average request latencies exceeded 15 seconds across most calls. Every tool call injected its full payload into the model context, inflating token counts and costs. On larger datasets, the context window filled up before the agent could finish reasoning. The following diagram (Figure 1) details the agentic architecture and data flow:
#Flightscape Training Schedule Optimization agent#Flightscape#Amazon Bedrock AgentCore#Amazon S3#LangGraph#LangChain#Amazon Bedrock Guardrails