AWS has published a detailed context-engineering pattern for production AI agents, using its open-source Deep Insight project to show how long-running analysis can be divided, compressed and verified. The approach combines separate agent contexts, behavioural controls in prompts, file-based tools and independent verification rather than relying on a larger context window alone.
The 4 November technical article says a single write-and-execute tool in the reference implementation reduces the tokens added by each script by about 95 per cent. Loading skills only when they are needed cuts the system prompt by about 97 per cent. Those figures are specific to the example, but they illustrate the scale of waste that can accumulate when agents repeatedly carry code, outputs and instructions through every turn.
Large windows can still fill quickly
A 200,000-token context window appears generous until an agent combines data exploration, code generation, charting, statistical checks and document creation. AWS describes a representative sales-analysis and DOCX-report task that consumes more than 150,000 tokens across about 15 minutes. If all activity remains in one conversation, stale information competes with new evidence and an error late in the process can force an expensive rerun.
Context engineering treats the window as a managed resource. The goal is not merely to shorten prompts, but to decide which information belongs with which agent, what can live outside the model, and how results should be checked before they move to the next stage.
Layer one separates specialised contexts
Deep Insight uses a hierarchy of specialised agents including a coordinator, planner, plan reviewer, supervisor and tool-focused roles for coding, validation, reporting, tracking and auditing. Each receives its own context rather than inheriting the complete history of the system.
The orchestrator passes compressed results between roles. A shared state retains the previous agent’s final message, short clues, a checklist and a compact activity history. It does not copy every intermediate exchange. AWS says this keeps even the busiest coding role under roughly 25,000 tokens in the reference workflow.
Isolation also limits error propagation. A reporting agent does not need every failed experiment from data exploration, and a validator can inspect an output without being anchored by the reasoning that produced it. The trade-off is coordination: summaries must preserve the facts the next role genuinely needs.
Layer two controls behaviour at the prompt
Separate agents still waste context if their instructions invite verbose output or unnecessary repetition. The prompt layer sets explicit output formats, tells roles what not to carry forward and places boundaries around tool results. Clear hand-off contracts make compression predictable instead of leaving every agent to decide how much history to repeat.
This layer is especially useful for routine metadata, plans and status messages. A short structured clue can communicate a validated result more efficiently than a natural-language recap of the entire process. However, prompt rules are not a complete defence because models can still produce oversized outputs or need access to large artefacts.
Layer three moves heavy artefacts to files
The tool layer externalises code, datasets, charts and reports to files. Agents receive references and targeted excerpts instead of embedding the full contents in conversation. A combined write-and-execute tool can place a script on disk, run it and return only the information required to continue.
This is a practical distinction for data work. Generated tables and execution logs can be enormous but may only matter if a check fails. Storing them outside the model context keeps them available for audit while avoiding repeated token charges. It also makes recovery easier because a later agent can inspect the saved artefact without recreating every previous step.
Layer four verifies independently
The final layer adds reviewers and safeguards. Validation agents check calculations and outputs, tracking agents compare progress with the plan, and auditors look for omissions or context growth. Independent verification is valuable because compression can hide a mistake as easily as it hides noise.
The layered design accepts that no single technique is sufficient. Multi-agent separation can lose information at hand-offs. Prompt controls can be ignored or become brittle. File-based context can hide relevant details. Verification compensates for those weaknesses and can trigger a focused retry rather than restarting the entire workflow.
Implications for Bedrock builders
Deep Insight is built with the Strands Agents SDK and Amazon Bedrock AgentCore, with additional AWS infrastructure used to operate the agents. The pattern is therefore directly relevant to teams building long-horizon workflows on Bedrock, but the principles are not limited to one cloud or model.
The most important message is architectural: context size is not the same as context quality. Production agents need deliberate information boundaries, durable external state and evidence-driven hand-offs. A larger window can postpone failure, while context engineering changes how much unnecessary material reaches the window in the first place.
Teams adopting the pattern should measure their own workloads rather than assume the reference savings will transfer unchanged. Useful metrics include tokens per completed task, hand-off error rates, retry scope, time to recover from a failed step and the percentage of artefacts that require full reloading. Those measurements can reveal whether added orchestration complexity is paying for itself.
AWS’s example gives builders something more concrete than a collection of prompt tips. It presents context management as a four-layer production discipline, with each layer designed to catch the limitations of the one before it.