News

AWS details four layers of context engineering in its Deep Insight agent code

Published 3 min readAI-assisted · human approved
TL;DR

AWS published Part 2 of a series on context engineering for production agents. It walks through four layers in Deep Insight, an open source data analysis agent, and says one change cut per-script context growth by about 95 percent.

Why it matters

If your agents run out of context mid-task, this post gives a concrete pattern to copy: isolate agents, cap their outputs, push heavy content to files, and verify. The numbers are AWS's own, measured on its reference code.

Image from AWS Machine Learning Blog
Image: AWS Machine Learning Blog. It belongs to its owner; see our image policy.

Original source

What happened

AWS published a technical how-to on its Machine Learning Blog on 4 November 2026. It is Part 2 of a three-part series on production AI agents. The post is AWS's own, so the performance figures below are AWS's claims.

The authors argue that context is a main bottleneck once agents do real work like data analysis and report generation. They group existing guidance, mostly from Anthropic's engineering posts and the Strands Agents SDK, into four layers. They then show each layer in Deep Insight, their open source multi-agent data analysis project.

Read the original AWS post for the full code.

Key details

  • Layer 1, architecture: each agent gets its own context window. Only compressed results go to the orchestrator. AWS says this keeps even the Coder agent, the heaviest user, under 25K tokens.
  • Layer 2, prompts: each agent's prompt sets an output token budget. The listed budgets are 1,000 to 1,500 tokens for Coder, 800 for Validator and 1,000 for Reporter.
  • Layer 3, filesystem: heavy content stays in files outside the context window.
  • Layer 4, verification: independent agents and safeguards catch errors and prevent context overflow.
  • Shared state: a Python dictionary named shared_state holds four things: messages, clues, full_plan and history.
  • Example workload: a request to analyze sales data and produce a DOCX report uses over 150K tokens across 15 minutes. That is against a 200K window for Claude Sonnet 4.5 on Amazon Bedrock.
  • Headline results: AWS says one tool that writes and runs scripts reduces the context each script adds by about 95 percent. It also says pulling in skills only when needed lowers system prompt size by about 97 percent.

Try it

# After the Coder agent finishes, pass on only a compressed result
clues += CLUES_FORMAT.format("coder", response["text"])

Why it matters

Long tasks can fill a window quickly. The post says the window can overflow mid-task, stale context can hurt accuracy, and errors can force a full re-run. Per-token pricing also makes bloated context cost more.

The patterns are not tied to one product. AWS notes the agents-as-tools pattern in the Strands Agents SDK gives you the isolation at the framework level, so you do not have to build it by hand.

Part 3, on moving Deep Insight from development to production, is listed as coming soon.

FAQ

What is context engineering? It is the practice of managing what goes into an LLM's limited context window so an agent keeps performing well. AWS describes it as spanning architecture, prompts, tools and verification.

What is Deep Insight? It is an open source multi-agent data analysis solution from AWS authors. It uses the Strands Agents SDK together with Amazon Bedrock AgentCore and serves as the reference implementation in the series.

Are the 95 and 97 percent figures independent? No. They come from AWS's own post about its own reference implementation, and the source shows no outside testing.

Checked claims

ClaimStatusEvidence
Deep Insight is an open source multi-agent data analysis solution that serves as the reference implementation.confirmedan open source multi-agent data analysis solution built on the Strands Agents SDK and Amazon Bedrock AgentCore
AWS says a single write-and-execute tool reduces the context added per script by about 95 percent.confirmeda single write-and-execute tool cuts the tokens each script adds to context by about 95 percent
AWS says on-demand skill loading reduces the system prompt by about 97 percent.confirmedloading skills on demand shrinks the system prompt by about 97 percent
Per-agent context isolation keeps even the heaviest agent, the Coder, under 25K tokens.confirmedkeeps even the Coder, which uses the most, under 25K tokens total
A sample sales-report task consumes over 150K tokens across 15 minutes.confirmedTogether they consume over 150K tokens across 15 minutes.
Each agent's prompt sets a maximum response token count.confirmedspecifies a maximum response token count

· Editorial policy

Question for readersHow do you keep long-running agent tasks from overflowing the context window, and which of these four layers has helped you most?

Discussion · 0

No comments yet. Start the discussion.

Sign in to join the discussion.