Production AI agents that run data‑analysis pipelines are now being built with a four‑layer context‑engineering approach, as demonstrated in the open‑source Deep Insight project. The change replaces a monolithic prompt that quickly exhausts a 200 K token window with a disciplined stack that isolates context, trims prompt payloads, offloads large artifacts to the filesystem, and validates output with independent agents. Engineers care because unchecked context growth leads to overflow, degraded model recall (often called “context rot”), and higher per‑token charges.
Four Layers of Context Engineering
Deep Insight groups existing guidance into four concrete practices:
- Layer 1 – Architecture: Each agent runs in its own isolated execution environment, preventing one task’s context from contaminating another.
- Layer 2 – Prompt: Prompts embed output‑control rules that limit how much information the model can ingest or return.
- Layer 3 – Tools: Heavy content such as scripts, data files, or generated charts are written to the local filesystem and referenced by path, keeping the LLM’s context lean.
- Layer 4 – Verification: A secondary verification agent reviews results and enforces safeguards before the primary agent proceeds.
Measured Impact in Deep Insight
Applying the four layers yields concrete token savings. A write‑and‑execute tool that previously added the full script to the LLM context now contributes roughly 5 % of the original token count, a reduction of about 95 %. Loading skills on demand trims the system prompt by roughly 97 %. These figures come from the reference implementation that runs on the Strands Agents SDK together with Amazon Bedrock AgentCore.
Architectural, Implementation, and Operational Implications
Adopting this pattern influences several engineering decisions:
- Multi‑Agent Isolation: Deploy each agent as an independent container (e.g., on AWS Fargate). Isolation simplifies scaling and limits the blast radius of a context overflow.
- Prompt Design: Engineers must embed concise behavioral rules and avoid embedding large data blobs directly in prompts.
- Filesystem Externalization: Agents need read/write access to a shared volume or object store. The pattern assumes that files are persisted outside the LLM context, so storage permissions and lifecycle policies become part of the operational checklist.
- Verification Agents: Adding a lightweight verification step introduces an extra execution path. Teams should monitor the latency added by this step and ensure that verification logic itself remains lightweight.
- Platform Stack: The reference uses the Strands Agents SDK, Amazon Bedrock AgentCore, and Bedrock’s Claude Sonnet 4.5 model. Deployments that require private networking can place the Fargate tasks inside an Amazon VPC, as outlined for the upcoming Part 3 of the series.
Related CloudNinjas coverage: AWS.
What This Means For Practitioners
Practitioners should evaluate their current agent pipelines for any single‑prompt designs that approach the 200 K token limit. If such patterns exist, refactor the workflow to adopt the four‑layer stack: isolate agents, tighten prompts, externalize large artifacts, and add a verification step. Track token usage before and after the change to confirm the expected reductions. Finally, plan for secure deployment—consider VPC‑bound Fargate tasks and appropriate storage permissions—to keep the new architecture both efficient and compliant.



