# Why Bigger Context Windows Won't Save Your Agent — Elizabeth Fuentes Leone, AWS

Elizabeth Fuentes Leone, AWS

AI Engineer World's Fair 2026

[Talk page](https://ai.engineer/talks/DrfyORO8RqA-why-bigger-context-windows-wont-save) · [Video](https://www.youtube.com/watch?v=DrfyORO8RqA)

## Why Bigger Context Windows Won’t Save Your Agent

Elizabeth Fuentes Leone shows how to manage growing agent histories in Strands Agents: keep recent conversation, store large outputs elsewhere, share pointers between agents, and give tool work explicit limits and asynchronous handles.

![Selected presentation frame from Why Bigger Context Windows Won't Save Your Agent — Elizabeth Fuentes Leone, AWS at 153 seconds](https://ai.engineer/api/talk-essay-media/460999518a51eaf90b5d8df4ed91db70f66b8697355bdf39a644143e2d4825e9)

A U-shaped attention curve dips at “Lost in the Middle.”

### A log-watching agent accumulates more than it needs

[0:12](https://www.youtube.com/watch?v=DrfyORO8RqA&t=12s)

An agent supervises an application by retrieving its logs. Each retrieval adds another batch to the conversation history. If subsequent invocations carry that history forward, the model receives both the latest logs and the accumulated results of earlier checks. The monitoring task may stay the same while its context keeps growing. Elizabeth Fuentes Leone, an AWS developer advocate, uses this example to explain why large tool outputs can overwhelm an agent.

A larger context window gives the application more room to accumulate data, but capacity alone does not ensure that the model uses all of it well. Fuentes Leone describes an attention “U-curve”: information near the beginning and end remains easier to use, while information in the middle can be neglected. This is a qualitative failure pattern in the talk, rather than a measured threshold that applies to every model or context length. The architectural question is therefore which information should reach the model on this invocation.

Context engineering means “giving the model the information it needs when it needs it.” That includes reducing unnecessary data and considering what the data contains: tool output can bring prompt injection into the context as well as consume tokens. Curating the input serves both the answer and the amount of work required to produce it.

### Four ways to change what enters the context

[3:11](https://www.youtube.com/watch?v=DrfyORO8RqA&t=191s)

The talk organizes context management around four complementary strategies:

- **Externalize:** move large data into persistent storage and retain a memory pointer that identifies it.
- **Select:** retrieve only the information relevant to the current task.
- **Compress:** summarize or compact information so it occupies fewer tokens.
- **Isolate:** separate context across agents, giving each agent the information its work requires.

These strategies act on different parts of the problem. Externalizing changes where data lives; selecting changes what comes back; compression changes how much detail travels; isolation changes who receives it. A log-monitoring system can combine them rather than choose a single technique for every kind of memory.

### Start by managing conversation history

[4:12](https://www.youtube.com/watch?v=DrfyORO8RqA&t=252s)

**Strands Agents** is the open-source, model-agnostic framework used for the examples. Its agent construction supplies the agentic loop behind a system prompt and a set of tools, without requiring the developer to assemble an explicit graph of nodes. The presented setup uses Amazon Bedrock; other model integrations can be supplied through model configuration.

A conversation manager is the first, relatively simple place to control growth:

- **Sliding window:** retain only the most recent messages. Earlier conversation falls out of the model’s immediate context.
- **Summarization:** condense older messages while preserving recent conversation.
- **Combined management:** use summaries of older material alongside retained recent messages.

![Selected presentation frame from Why Bigger Context Windows Won't Save Your Agent — Elizabeth Fuentes Leone, AWS at 307 seconds](https://ai.engineer/api/talk-essay-media/8517a6c80fcaaf3bdea305c3503475803e0dfc01efdd8d3bba88a0a376fab1ec)

A slide compares sliding-window, summarization, and combined conversation management.

The summarizing example preserves the last four messages and configures a summary ratio. The spoken explanation gives conflicting percentages—50% and then 60%—so it does not establish a consistent numeric ratio. The useful mechanism is clear: recent exchanges stay intact, while older exchanges are represented more compactly as the session continues. This gives the agent continuity without replaying every old message in full.

That convenience creates a decision about what may be lost. Keeping recent messages protects the immediate exchange, but the older summary must still carry whatever facts future answers will need. The ending returns to this limitation: a summary can be short and still omit the detail that matters.

### Conversation history is only one kind of memory

[6:42](https://www.youtube.com/watch?v=DrfyORO8RqA&t=402s)

Managing a session’s history does not by itself solve remembering across sessions. A new session may need something learned earlier, even though that earlier conversation is no longer present. The talk separates three forms of memory by the information they retain:

- **Short-term memory:** recent conversation history within the current session, managed with the conversation techniques above.
- **Long-term memory:** information saved for later retrieval, with a vector database offered as a storage approach. Prompts can determine which kinds of information from a conversation should be saved.
- **Relationship memory:** entities and their connections, represented in a graph. Fuentes Leone points to Neo4j as a place to learn more about this approach.

![Selected presentation frame from Why Bigger Context Windows Won't Save Your Agent — Elizabeth Fuentes Leone, AWS at 430 seconds](https://ai.engineer/api/talk-essay-media/24e21f0c2caa4e5f6a30a77de24d2c7bb8cbcce7e1b8c5f9b8226c1a1eb3ef74)

Three columns label short-term, long-term, and relational memory.

The three can coexist. Recent history supplies the immediate exchange; retrieval brings back relevant information from the past; graph memory retains relationships that the application wants to represent separately. Remembering something therefore need not mean carrying its entire original conversation into every future request.

### Replace repeated log batches with a retrievable pointer

[7:41](https://www.youtube.com/watch?v=DrfyORO8RqA&t=461s)

Return to the monitoring agent. Initially, every log retrieval enlarged the conversation. With a memory pointer, the tool retrieves the logs and stores them outside the model’s context. The agent retains an ID identifying that data. Another tool can inspect the stored logs and return a compact status, so the agent can answer a routine monitoring question without receiving the whole batch.

The observable change is in what the model receives: a pointer and a useful result replace the repeated raw log payload. If a later question requires the underlying logs, the agent passes the ID to a retrieval tool. Externalization keeps the original data available; selection determines when it returns to context. The design still depends on tools that can store, interpret and retrieve the data—the ID alone contains no diagnosis.

Where do the logs go, and what reaches the model instead? The flow below separates the large stored payload from the compact pointer and assessment. Its return path matters: the application can recover the logs when needed rather than relying entirely on an earlier summary.

![Selected presentation frame from Why Bigger Context Windows Won't Save Your Agent — Elizabeth Fuentes Leone, AWS at 522 seconds](https://ai.engineer/api/talk-essay-media/301832b5baf55022fe6b747695a8aaca5f807e828f4fb33120fbcc683060d67a)

The Memory Pointer Pattern connects tool returns and agent state to the context window and a next tool.

In the Strands example, tools are defined with a tool decorator, and tool context exposes agent state for managing this information. The memory pointer ID remains in the context while the associated data is handled through state and storage. This makes the division between model input and tool-accessible data part of the application’s architecture.

The same division becomes useful in a multi-agent Strands swarm. Copying one agent’s full context into another gives the recipient material it may never need. Instead, the agents share a memory pointer through invocation state. They can refer to the same large dataset while keeping their individual contexts focused. Shared access to data does not require identical conversation histories.

Large logs stay in storage; context carries a pointer
A tool can assess stored logs and return a compact result. The retained ID allows later retrieval when the underlying data is needed.
- Fetch application logs — A tool retrieves a large log batch.
- Store logs — Keep the payload outside context and identify it with a memory pointer ID.
- Inspect stored logs — A tool interprets the logs and produces a compact status.
- Agent context — Retain the pointer ID and the useful assessment.
- Retrieve when needed — Use the ID to request the underlying logs for a later question.
- Fetch application logs → Store logs (Large log payload)
- Store logs → Inspect stored logs (Logs available to the tool)
- Store logs → Agent context (Memory pointer ID)
- Inspect stored logs → Agent context (Compact status)
- Agent context → Retrieve when needed (Request logs by ID)
- Store logs → Retrieve when needed (Recover the stored logs)

### Give repeated tool calls an explicit stopping point

[10:44](https://www.youtube.com/watch?v=DrfyORO8RqA&t=644s)

An agent can also accumulate work by invoking the same tool again and again. An unclear tool response leaves the agent without a clear basis for deciding that the work is finished. Fuentes Leone pairs two remedies: make the tool’s response clear, and impose a maximum invocation count.

The example allows each of the illustrated tools to be invoked three times. A clear response helps the model choose the next step; the count limit bounds repetition even when that choice goes wrong. The limit prevents unlimited calls to those tools, but reaching it does not establish that the task succeeded. It supplies a stopping point for execution.

![Selected presentation frame from Why Bigger Context Windows Won't Save Your Agent — Elizabeth Fuentes Leone, AWS at 675 seconds](https://ai.engineer/api/talk-essay-media/a747d88cadbe3ce121dde6b2874fc0528b550699f3d453970024b7d8270bb093)

A slide contrasts a problem list with “Clear Status + Hard Limit.”

### Separate starting a slow job from collecting its result

[11:44](https://www.youtube.com/watch?v=DrfyORO8RqA&t=704s)

Some tool problems are about elapsed time rather than context size. An MCP tool or external API may take longer than the calling application can wait. AWS API Gateway is the example of an intermediary with a maximum response time: a slow downstream operation can outlast that limit and interrupt the request.

An asynchronous handle separates starting work from retrieving its answer. One tool starts the long job; another checks its status. The application retains the handle and can collect the result on a later invocation. The presented implementation uses FastAPI. Fuentes Leone reports improved responsiveness in her tests, without specifying a measured latency reduction; whether this pattern fits depends on whether the application can return before the result is ready.

![Selected presentation frame from Why Bigger Context Windows Won't Save Your Agent — Elizabeth Fuentes Leone, AWS at 798 seconds](https://ai.engineer/api/talk-essay-media/5913845dec4c4650ac8d94243dc04fa556afa4cf26c32f02d482f71765114d8e)

A code slide shows `start_long_job` and `check_job_status` tools.

What changes in the timing of the agent’s work? The diagram shows the long operation continuing between two invocations. The first call starts the job and preserves its handle; a later status check reconnects the agent to the result. The slow work remains, but a single request no longer has to wait for its entire duration.

A handle connects two invocations to one long-running job
Starting the job and retrieving its result are separate tool operations.
- Start long job — The first invocation initiates external work.
- Retain async handle — Keep a reference for a later invocation.
- External operation — The slow MCP or API operation produces its result.
- Check job status — A later invocation checks the job and retrieves its answer when available.
- Start long job → External operation (Initiate work)
- Start long job → Retain async handle (Preserve the handle)
- Retain async handle → Check job status (Resume on a later invocation)
- External operation → Check job status (Status and available result)

### Preserve useful evidence without passing everything

[13:45](https://www.youtube.com/watch?v=DrfyORO8RqA&t=825s)

The closing anti-patterns put a limit on enthusiasm for every technique above. Context stuffing includes everything because it is available, even when the answer needs only a small part. Indiscriminate summarization makes the opposite mistake: it reduces the history but may discard information needed to answer. Passing whole contexts between agents repeats the stuffing problem across the system.

The final cheat sheet maps concrete problems to concrete controls:

- **Large log or database outputs:** externalize the data, select relevant information, and keep a memory pointer.
- **Several agents needing the same data:** share the pointer through invocation state rather than copy the full payload into every context.
- **Repeated tool calls:** provide clear responses and limit invocation counts.
- **Slow external work:** use an asynchronous handle to retrieve the result later.

![Selected presentation frame from Why Bigger Context Windows Won't Save Your Agent — Elizabeth Fuentes Leone, AWS at 891 seconds](https://ai.engineer/api/talk-essay-media/612fab79acf9b16c1d15cfa5c063f6b3e0fc8b72c39ac0b270187184ee1135a9)

A slide maps large data, shared agent data, and tool loops to context management strategies.

For the log-watching agent, this produces a practical division of responsibilities. Storage keeps the evidence, tools inspect and retrieve it, state carries references, and the model receives what it needs for the current answer. The important decision is what crosses into context on each invocation—and how the application recovers detail when a compact result is no longer enough.

## Key takeaways

- A larger context window does not remove the need to select information: accumulated tool output can overwhelm context and leave relevant material neglected.
- Conversation managers control immediate history; long-term and graph memory let the application retrieve past information and relationships separately.
- Memory pointers keep large payloads available without repeatedly placing them in context, and can be shared through invocation state across agents.
- Clear tool responses guide the next decision; invocation limits bound repetition; async handles separate starting slow work from collecting its result.
- Compression is useful only if the retained information still supports the task. Preserve a way to retrieve underlying evidence when a summary is insufficient.

## Slides

### The Infinite Context Window Is a Myth

Elizabeth Fuentes Leone introduces context engineering for agents, explaining that large tool outputs can overflow the context window and degrade reasoning.

[0:37](https://www.youtube.com/watch?v=DrfyORO8RqA&t=37s) [Title slide for Context Engineering for AI Agents, listing Elizabeth Fuentes Leone and Morgan Willis.](https://assets.ai.engineer/sites/aiecode2025/sha256/49c26c326253da889047624463f8ed8658ca15968b366a679c94d4dc4e51ef74.webp)

The Infinite Context Window Is a Myth:
Context Engineering for AI Agents

Elizabeth Fuentes Leone
Developer Advocate/SDE, GenAI

Morgan Willis
Sr. Developer Advocate, GenAI

aws
AWS Builder Center

1

### Just Add More Tokens

As an agent repeatedly retrieves logs, its context grows. Fuentes Leone challenges the idea that expanding the window from 4K to 2M tokens fixes the problem.

[1:13](https://www.youtube.com/watch?v=DrfyORO8RqA&t=73s) [Context-window sizes progress from 4K to 2M tokens above the quote, “Just add more tokens, that'll fix it.”](https://assets.ai.engineer/sites/aiecode2025/sha256/526abf93e4da84441ad98b6542aa90f46139b3b3ec5121d5bdcceb679f541c6a.webp)

4K → 32K → 128K → 1M → 2M tokens

“Just add more tokens, that'll fix it”

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### Why It Doesn't Work

The U-curve illustrates lower attention to the middle of a context window than to its beginning or end. Adding tokens does not necessarily add useful signal.

[2:10](https://www.youtube.com/watch?v=DrfyORO8RqA&t=130s) [A U-shaped attention curve labels the middle of the context window “Lost in the Middle.”](https://assets.ai.engineer/sites/aiecode2025/sha256/28262b3e6437a72a9ddc21bcba3ad722d01d02166bd30e4f5d788da8a1087ae7.webp)

Why It Doesn't Work

Attention (U-curve)

Lost in the Middle

Context Window (tokens)

More tokens ≠ more useful signal

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### Context Engineering

Context engineering curates the window so the model gets information when it needs it. An agent may not need everything in the window, which can also contain prompt injection.

[2:37](https://www.youtube.com/watch?v=DrfyORO8RqA&t=157s) [Context engineering is described as giving the model needed information when it needs it and curating the context window.](https://assets.ai.engineer/sites/aiecode2025/sha256/54f29ba516fa9fb986c3af4675425a651effe46c7e18645e1e4ed71cf338bcea.webp)

Context Engineering

Giving the model the information it needs, when it needs it.

Curating the context window for optimal outcomes and token consumption.

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### Four Context Engineering Strategies

Leone groups context engineering into four moves: store large data externally, retrieve relevant information, compress it, and separate context across agents. A memory pointer can reference stored data.

[3:17](https://www.youtube.com/watch?v=DrfyORO8RqA&t=197s) [Four cards describe externalizing data, selecting relevant information, compressing tokens, and isolating context across agents.](https://assets.ai.engineer/sites/aiecode2025/sha256/a7496c24f266e24a8d95dbd6a6e9ee1acc1078cd384b65dfbbe4cd0c463af430.webp)

Four Context Engineering Strategies

Externalize
Move large data to persistent storage

Select
Retrieve only what is relevant

Compress
Reduce tokens: summarize, compact

Isolate
Separate context across agents

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### The Starting Point: Conversation Management

Strands presents three conversation-management approaches: keep recent messages, summarize older messages while keeping recent ones, or combine an older-message summary with recent messages.

[4:08](https://www.youtube.com/watch?v=DrfyORO8RqA&t=248s) [Three panels compare a sliding window, summarization, and a combination of summaries with recent messages.](https://assets.ai.engineer/sites/aiecode2025/sha256/d372b977c81acf04fc358b9d0f15d22f3a3d63043c76c3ef067c183b9c558e72.webp)

1
The Starting Point: Conversation Management
Compress

Conversation management: the built-in default Strands Agents

Sliding Window
Keep only the most recent messages

Summarization
Summarize older messages and keep recent ones

Combination
Combine summary of older messages with recent ones

The built-in default — before any advanced pattern

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### Creating a Strands Agent

Strands creates the agentic loop behind the scenes. This example gives the agent a coding system prompt and file-reading, editing, and shell tools.

[5:12](https://www.youtube.com/watch?v=DrfyORO8RqA&t=312s) [Python example creates a coding agent with file reading, editing, and shell tools.](https://assets.ai.engineer/sites/aiecode2025/sha256/e313f6c4207b1284bbec838d722c820e8ca4f00fb4278cee271f4ad6d50b0d0d.webp)

from strands import Agent
from strands_tools import file_read, editor, shell

agent = Agent(
    system_prompt="You are a coding agent.",
    tools=(file_read, editor, shell)
)

STRANDS AGENTS SDK

### Summarizing Conversation Manager

The agent’s conversation manager summarizes the oldest 50% of the history while preserving four recent messages verbatim.

[5:56](https://www.youtube.com/watch?v=DrfyORO8RqA&t=356s) [Python example configures a summarizing conversation manager to summarize half the history and preserve four recent messages.](https://assets.ai.engineer/sites/aiecode2025/sha256/c5f34666b8b1c728f96e81768b2999ee95d2e273d55416e9397caec831497b2b.webp)

Compress

from strands import Agent
from strands.agent.conversation_manager import (
    SummarizingConversationManager)

agent = Agent(
    conversation_manager=SummarizingConversationManager(
        summary_ratio=0.5,          # summarize oldest 50%
        preserve_recent_messages=4,  # keep recent turns verbatim
    ),
)

STRANDS AGENTS SDK

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### Tiered Memory

An agent can combine recent conversation history, retrieved long-term facts, and an entity graph that tracks how things connect.

[6:35](https://www.youtube.com/watch?v=DrfyORO8RqA&t=395s) [Three columns compare short-term conversation history, retrieved long-term facts, and relational memory using an entity graph.](https://assets.ai.engineer/sites/aiecode2025/sha256/e155bcaf8627484e4add6f7ac10bfa48fd20ed5e11dc0c34f12c987bde683239.webp)

Tiered Memory

Externalize
Compress

Short-term memory
• Recent conversation history
• Last k-turns always returned
• Sliding window + summarization

Long-term memory
• Extracted from conversation history
• Clean facts > raw conversation
• Scored retrieval

Relational memory
• Entity graph
• Traversal based
• How things connect

### The Memory Pointer Pattern

The tool stores 214 KB of logs in agent.state and returns a ~50-token pointer to the context window. A later tool uses that key to read the full data when needed.

[8:00](https://www.youtube.com/watch?v=DrfyORO8RqA&t=480s) [A tool stores logs in agent state and returns a small pointer to the context window; a later tool uses the key to read the data.](https://assets.ai.engineer/sites/aiecode2025/sha256/6335dcab8a395be8d5719e161de8d6722bbb2fa77c799b8d4756245c981e5546.webp)

The Memory Pointer Pattern
Single agent: log analysis via a pointer

2
Externalize
Select

Tool returns
214 KB of logs

externalize →

agent.state
full data lives here

pointer ↓

Context Window
"Stored at: logs-payment"  ~50 tokens

select by key →

Next tool
reads full data when needed

Full data never enters the model — only a tiny pointer does

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### Memory Pointer Tool Example

One tool stores application logs in agent state and returns a small pointer. A second tool uses that pointer to retrieve the logs for error analysis when needed.

[9:11](https://www.youtube.com/watch?v=DrfyORO8RqA&t=551s) [Two Python tools store application logs in agent state under a pointer and retrieve them for error analysis.](https://assets.ai.engineer/sites/aiecode2025/sha256/a307fd09e4a6e633e3ef3772f8ff16eae7b4251d3075d603b3870adfbace9147.webp)

Externalize
Select

@tool(context=True)
def fetch_application_logs(app_name, tool_context):
    logs = generate_logs(hours)      # ~214KB
    pointer = f"logs-{app_name}"
    # Externalize → agent.state
    tool_context.agent.state.set(pointer, logs)
    return f"Stored at: {pointer}"   # ~50 tokens

@tool(context=True)
def analyze_error_patterns(logs_pointer, tool_context):
    # Select → read full data only when needed
    logs = tool_context.agent.state.get(logs_pointer)

STRANDS AGENTS SDK

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### Memory Pointers Across Agents

The collector writes logs to shared invocation state; the analyzer reads and writes analysis, and the reporter reads it. The slide reports 145 KB processed without entering an LLM context window.

[9:47](https://www.youtube.com/watch?v=DrfyORO8RqA&t=587s) [Collector, analyzer, and reporter agents exchange logs and analysis through shared invocation state.](https://assets.ai.engineer/sites/aiecode2025/sha256/0d0341082cf47ce89dfb1b35a3c985e6e802b66b1afc7b6e8dfa102c028eed33.webp)

3
Now Scale It: One Pattern, Many Agents

Externalize
Select
Isolate

Strands Swarm: Memory Pointer Across Agents

Collector
fetch logs → store
↓ write

Analyzer
read logs → analyze
↕ read / write

Reporter
read analysis → report
↑ read

invocation_state — shared across all agents

"logs-payment"
145,310 bytes

"error_analysis"
135 bytes

"latency_analysis"
70 bytes

145 KB of logs processed by 3 agents — none of it entered any LLM context window

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### Multi-agent swarm: shared pointer

The collector stores logs in shared invocation state and hands a pointer to the analyzer. The swarm also includes a reporter, letting agents share information without passing all of it through their context windows.

[10:14](https://www.youtube.com/watch?v=DrfyORO8RqA&t=614s) [Code stores logs in shared invocation state and defines collector, analyzer, and reporter agents.](https://assets.ai.engineer/sites/aiecode2025/sha256/6693fd8fdcbade423aa1b31b2d1f3a6d6e5c424e04116ca0506f061b08cdbe68.webp)

Multi-agent swarm: shared pointer, scalable handoffs

Externalize   Select   Isolate

@tool(context=True)
def fetch_logs_swarm(app_name, tool_context):
    logs = generate_logs(hours)             # 145KB+
    # Externalize into SHARED state
    tool_context.invocation_state[pointer] = logs
    return f"Stored as '{pointer}'. Hand off to analyzer."
collector = Agent(name="collector", tools=[fetch_logs_swarm])
analyzer  = Agent(name="analyzer", tools=[analyze, latency])
reporter  = Agent(name="reporter", tools=[generate_report])
swarm = Swarm([collector, analyzer, reporter])

STRANDS AGENTS SDK

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### When the Agent Won't Stop

An ambiguous tool response can send an agent into repeated calls. Clear success or failure signals give it a stopping point, while LimitToolCounts sets a hard ceiling on calls.

[10:35](https://www.youtube.com/watch?v=DrfyORO8RqA&t=635s) [A comparison of repeated tool calls with clear success or failure states and a hard call limit.](https://assets.ai.engineer/sites/aiecode2025/sha256/17c93864741af9f475bcaadf09de6cba1ff9fe219c605f4859e13ac867327781.webp)

4

When the Agent Won't Stop
Reasoning loops, clear states + hard limit

Problem
• Tool says “more results may be available”
• Agent retries the same call
• Redundant calls, tokens burned, no progress

Clear States + Hard Limit
• Tools return SUCCESS / FAILED
• Agent stops on a clear signal
• LimitToolCounts caps the calls
• Hard ceiling regardless of the LLM

The Decoder: Language models can overthink

Compress

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### Clear states and tool call limits

The booking tool returns a clear success message, while LimitToolCounts caps flight searches and hotel price checks at three calls each to curb repeated tool loops.

[10:38](https://www.youtube.com/watch?v=DrfyORO8RqA&t=638s) [Code returns a booking success message and limits two tools to three calls each.](https://assets.ai.engineer/sites/aiecode2025/sha256/2bdbf6940ffa130d0a2dfe037ff50f81053ef31e1c18a68ba94c2e838747878a.webp)

Compress

@tool
def book_hotel(hotel, guest, nights):
    # Clear SUCCESS / FAILED ends the loop
    return f"SUCCESS: booking {conf} confirmed"

# LimitToolCounts – Strands Hooks Cookbook recipe
limit = LimitToolCounts(max_tool_counts={
    "search_flights": 3, "check_hotel_price": 3})
agent = Agent(tools=[...], hooks=[limit])

STRANDS AGENTS SDK

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### When a Tool Never Comes Back

A synchronous MCP call blocks and times out after 17.2 seconds. The async pattern returns a handle and polls while the API runs in the background, with a reported total of 1.7 seconds.

[11:52](https://www.youtube.com/watch?v=DrfyORO8RqA&t=712s) [A diagram compares a blocked synchronous MCP call with an asynchronous job handle and status polling.](https://assets.ai.engineer/sites/aiecode2025/sha256/21559f57ecf2014309196232e44f390846411dc6c06e5741092855c19e9995c7.webp)

5
When a Tool Never Comes Back
MCP timeouts: async handle, no frozen agent
Isolate

MCP Tool: Synchronous vs Async HandleId

Synchronous (blocked)
Agent → MCP Tool
calls a slow external API
15s BLOCKED
agent frozen, user waiting...
424 Error
times out after 17.2s
Total: 17.2 seconds

Async HandleId pattern
start_job()
returns now
handle: abc123
0.1s
check_status()
polls for result
COMPLETED
full result
Slow API runs in the background
Total: 1.7 seconds

Async handleId: the agent gets an immediate response and polls for results. No blocking, no 424 errors.

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### Asynchronous MCP job example

One MCP tool starts a background job and returns its ID; a second checks its status, letting the agent retrieve the result later.

[13:02](https://www.youtube.com/watch?v=DrfyORO8RqA&t=782s) [Code starts a background job and provides a separate tool to check its status.](https://assets.ai.engineer/sites/aiecode2025/sha256/3fea7e2eedc7be9e5c4aed63b6774a15d254c6f8c1dd069f4e9b26aa998221b0.webp)

Isolate

@mcp.tool()
async def start_long_job(task: str) -> str:
    job_id = str(uuid.uuid4())[:8]
    # Isolate: run off the agent loop
    asyncio.create_task(process_job(job_id, task))
    return f"STARTED: {job_id}. Poll check_job_status."
@mcp.tool()
async def check_job_status(job_id: str) -> str:
    job = JOBS.get(job_id)
    return job["status"]  # running | completed: <result>

STRANDS AGENTS SDK

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### Result — MCP Timeouts

In tests of the async handle, response time fell from 17.2s to 1.7s, with no more 424 timeouts.

[13:25](https://www.youtube.com/watch?v=DrfyORO8RqA&t=805s) [The slide reports response time decreasing from 17.2 seconds to 1.7 seconds and no more 424 timeouts.](https://assets.ai.engineer/sites/aiecode2025/sha256/2c437c080a67ba853f4c7e0f3e42c07465636d729d4c78f4a61946f2c8fad9b3.webp)

Result — MCP Timeouts

17.2s → 1.7s
response time · no more 424 timeouts

Isolate

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### Anti-Patterns

Stuffing context and passing everything between agents adds information they may not need; naive summarization can drop details needed for an answer.

[13:44](https://www.youtube.com/watch?v=DrfyORO8RqA&t=824s) [Three columns describe context stuffing, naive summarization, and context pollution.](https://assets.ai.engineer/sites/aiecode2025/sha256/70827227b8ccdf17737358bcff480fd9a7f135799815640b0b79529944f6d31b.webp)

Anti-Patterns

Context Stuffing
• Include everything and the kitchen sink
• Always reach for the largest window

Naive Summarization
• Important details get dropped
• Performance quietly goes down

Context Pollution
• Pass everything between agents
• One agent does everything

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### Match the Strategy to the Failure

For large tool outputs, externalize and select data with a memory pointer. Share invocation_state across agents; use clear states, LimitToolCounts, and an async handle for loops or hanging tools.

[14:39](https://www.youtube.com/watch?v=DrfyORO8RqA&t=879s) [Strategies address large tool outputs, shared data across agents, and agent loops or hanging tools.](https://assets.ai.engineer/sites/aiecode2025/sha256/6f168d66e0d64897812cd3026035794053b3fb673165e9931d26fcf810b1515e.webp)

Match the Strategy to the Failure

Tool returns large data (logs, docs, datasets)
Externalize + Select — memory pointer

Many agents need the same large data
Shared invocation_state + scoped context

Agent loops, or a tool hangs
Clear states / LimitToolCounts / async handle

© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

### Thank You

The presenters share resources for trying the demos in Strands Agents.

[15:12](https://www.youtube.com/watch?v=DrfyORO8RqA&t=912s) [Closing slide lists the presenters and offers Strands Agents resources through a QR code.](https://assets.ai.engineer/sites/aiecode2025/sha256/bbbc7f429089cecea78707701712d472ade86d4ba4535dc0e2d6b0adf00fc44a.webp)

Thank you!

Try it yourself, all demos in Strands Agents

Elizabeth Fuentes Leone
Developer Advocate/SDE, GenAI

Morgan Willis
Sr. Developer Advocate, GenAI

Resources
bit.ly/4xaaFMv

aws
© 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved.

## Full transcript

[0:12](https://www.youtube.com/watch?v=DrfyORO8RqA&t=12s) Hi. Well, first I have to say I am Elizabeth. I am no Morgan, but the guy for the agenda, they never change agenda, so we are almost the same but with different color of hair. Okay? So it's, it's going to be similar. So today I'm going to talk about the infinite context window is a myth. Yes. It's because right now agent system

[0:42](https://www.youtube.com/watch?v=DrfyORO8RqA&t=42s) breaks when tools returns a large amount of data. Context window overflow and the agent start to hallucinate and start the reasoning is degraded. So right now, context engineering help, help us to, uh, give us a better architecture for this agentic application. So we have some techniques that allows us to improve the context in-- the context window for this

[1:12](https://www.youtube.com/watch?v=DrfyORO8RqA&t=72s) a-agentic application. So imagine that you have a agent that is responsible to, uh, supervise some application. So this agent have to retrieve log, logs for that application. So every time this agent is doing the retrieve for the logs, he's putting data for the context window. And every time this context window is going to grow. It's going to grow every time because when we have, uh, one

[1:42](https://www.youtube.com/watch?v=DrfyORO8RqA&t=102s) session, and each session is going to retrieve the last session because it's going to remember everything. That's the way that a-agents remember, and they use the context window for that. In the past, about probably one year ago, before this agentic era, we saw that just add more token, that will fix it. Yeah, let's use more bigger context window. That is going to fix it. And today we know that is not true

[2:11](https://www.youtube.com/watch?v=DrfyORO8RqA&t=131s) because we have the, uh, attention U-curve. What is this? We have a lot of data, but if that data is super, super big, the agent is going to forget the middle in the, in the, in the curve. It's only going to remember the first part and the last part that we sent to that context window. And I'm talking here about context engineering. But--

[2:41](https://www.youtube.com/watch?v=DrfyORO8RqA&t=161s) I can move. But context engineering is giving the model the information it needs when it needs it. Sometimes the agent doesn't need all the information inside that context window. Sometimes the context window is poisoning the agent because you can have a prompt injection inside your context window. And the, uh, context engineering help us to curate the context window for optimal outcomes and token consumption. So

[3:11](https://www.youtube.com/watch?v=DrfyORO8RqA&t=191s) today I'm going to show you some techniques that can help you to improve the context window. And these techniques, uh, I manage for a strategy. We have, we have the externalize because move this, that, this big data to a persistent storage. You can create a memory pointer to store that data. I'm going to share the deck at the end, so you need to-- you don't need to have to... Please pay me attention,

[3:42](https://www.youtube.com/watch?v=DrfyORO8RqA&t=222s) and because I'm going to share you all the information that I'm going to talk here. And the second one is select. You can retrieve only what is relevant. We have compress, that reduce token because you can summarize and you can compact that information. And the last one is isolate because you can separate context across agents. And let's start. So the starting

[4:12](https://www.youtube.com/watch?v=DrfyORO8RqA&t=252s) point, conversation manager. This strategy, yeah, we have some strategies that are a little complicated, but we are going to start for the easy one that we can use inside the framework. So here in this strategy we are going to use a Strands agent. It's a framework like we are... AWS we maintain. It's completely open source. Yes, it's free and it's AWS. Yeah. It's open source, free, and it's completely model-agnostic.

[4:42](https://www.youtube.com/watch?v=DrfyORO8RqA&t=282s) So here with Strands you can use three different strategy inside the framework. So we have sliding window that allows you to keep only the most recent messages. We have summarization inside the framework that allows you to summarize older messages and keep recent one. And the last one is a combination of two above. We have... That you can combine summarize of older messages with recent one. So first let's see

[5:12](https://www.youtube.com/watch?v=DrfyORO8RqA&t=312s) what is a Strands. A Strands is this. So you only need one line of code to create the agentic loop. So this line here create all the agentic loop behind the scene. You don't need to create the nodes, the graph, nothing, because a Strands can do that for you. And you have the system prompt and the tools. And yes, this is simple because it's using Amazon Bedrock behind the scene. But if you want to use

[5:42](https://www.youtube.com/watch?v=DrfyORO8RqA&t=342s) Ollama, uh, Gemini, Anthropic, you only need to add one line because you can do that. You import the, the library for OpenAI, for example, and then you add the model line, and that's it. So let's return to our strategy. If you want to use summarization conversation manager- That's the only line that you add-- that you can add for this agentic loop. So you have the summary ratio, that is, in this case, is fifty

[6:11](https://www.youtube.com/watch?v=DrfyORO8RqA&t=371s) percent, and you want to preserve, preserve the last four messages. So every time that you invoke this agent in this session, this session is going to manage your context window in this way. So it's going to keep the four last messages, and it's going to summarize the other sixty percent. And yes, this is amazing, but what happen when you have a lot of memory and you don't want to lose, you don't want to lose all the memory inside that context

[6:42](https://www.youtube.com/watch?v=DrfyORO8RqA&t=402s) window? So you can use... Well, always we have short-term memory because short-term memory is when you have the recent conversation history. So you can use this, uh, applica- this, uh, this function that I just mentioned in the short-term memory. But what happen when you want to return and, uh, you for-- you are-- you have a new session for this agent, and you don't have short-term memory? You can have long-term memory, and you can create a vector database for

[7:12](https://www.youtube.com/watch?v=DrfyORO8RqA&t=432s) that long-term memory. You can have different type of memory inside that vector database with different prompts that can understand your conversation and save whatever you want. And the third one is relation memory. You can use Entity Graph. You can go to the, uh, to the guide for Neo4j. They, they can explain you more about that. You can use traversal-based it or health in connect. So you can understand. You can use a combination of three of those. You can have long-- short-term

[7:41](https://www.youtube.com/watch?v=DrfyORO8RqA&t=461s) memory for the mem-- the session that you have. Then you can retrieve the memory that is in the past, the long-term, long-term memory. And if you have some relation thing that you want to keep in a different way, you can add for that a graph memory as well. Let's continue with the other one. So what happen with this application where a lot of logs that I told you? You don't want to put that logs inside your context window every time that you invoke that agentic

[8:11](https://www.youtube.com/watch?v=DrfyORO8RqA&t=491s) application, that agent. You can save that inside a memory pointer. So where... how this work? You have the, the tools. The tools, uh, returns you oof and a bunch of, uh, uh, logs. You can use another tools that is going to capable to took that logs and save that logs in a storage, and you are going to retrieve an ID for that storage. And for that, using a Strands, you can have that using the agent

[8:41](https://www.youtube.com/watch?v=DrfyORO8RqA&t=521s) state. In the agent state, you are going to have all information for the tools. Then you can use another tool that is going to capable to understand that logs, and it's going to send, uh, um, it's going to send to the agent, "Hey, the logs has okay." You don't need the logs to understand that. But what happen is you need the logs. You can go and say, "Hey, this is my ID. Come on, retrieve the logs because I needed to know." So this is something that you can build in your architecture,

[9:11](https://www.youtube.com/watch?v=DrfyORO8RqA&t=551s) and it's something like this. You can have two different tools. That's the way that we create tools inside the Strands safe only with the tool decorator. So we have fetch application logs, and if you can see there, you have the tool context agent state, state. So we retrieve that information, and we save that in a memory pointer. We create a memory pointer ID that is going to preserve inside our context window. But what happen is

[9:41](https://www.youtube.com/watch?v=DrfyORO8RqA&t=581s) your application super complicated, and the tools is not enough. You can use, ah, I forget that. You can use a multi-agent application. So you can create a Strands swarm with multi agents. But you share the context window between agents is like add garbage to the other agents because not all the agents need the information between them.

[10:11](https://www.youtube.com/watch?v=DrfyORO8RqA&t=611s) So you can share the information between the invocation state pointer. So you can create an ID between that swarm, agentic swarm, and you can share the memory pointer between the la-- the invocation state between the agents, and that's the way that we create the swarm in a Strands Agent. And oh my God, nine minutes. I, I want to be fast. And the next one is...

[10:41](https://www.youtube.com/watch?v=DrfyORO8RqA&t=641s) Wait.

[10:44](https://www.youtube.com/watch?v=DrfyORO8RqA&t=644s) The next one is what happen when the agent, uh, wanna stop never. And sometimes we have this agent that is stay in the loop, like, forever, invoking the same tool, the same tool again, and it's never ending. So you can stop that with, um, a minimum amount on invocation inside the loop. So what is the problem? I just read the problem. To sell more soul may be available. So what's... that's happen when you no-- when you,

[11:14](https://www.youtube.com/watch?v=DrfyORO8RqA&t=674s) you, you don't have a clear response when you invoke the tool. So you can avoid that with the tool way, with a clear response and with amounts of invocation for that tool, and you do that like this. So you have a limited tool count. So you set max tool count. For this example is my tools search fly. You can-- You only can invoke that tool three times. And the other tool? Yeah, three time as well. So the agent

[11:44](https://www.youtube.com/watch?v=DrfyORO8RqA&t=704s) never is going to do, to do this, uh, eternal loop. It's only going to invoke that tools three times. And the last one, yes, I almost there. The last one is, uh, is not, uh, something that help you to the context window. It's something that you can use to help your context window because sometimes we are invoking our MCP tools or IMCP, or we have external API That

[12:14](https://www.youtube.com/watch?v=DrfyORO8RqA&t=734s) never answer you at the time that you need it. Sometimes, for example, we have API Gateway, AWS API Gateway. It have a, a maximum time that is going to receive the, the answer. So if you don't have that time, it's going to, uh, like stop your application because the delay. So you can avoid that using a, async handle. So when you use synchronous, your agent is going to wait forever for the answer for your MCP.

[12:45](https://www.youtube.com/watch?v=DrfyORO8RqA&t=765s) But if you have an async handle, you can invoke your MCP, your external API. So then you can save that, and you can retrieve the answer in the next invocation when you need it. Yes, this is going to depend of the case that you are building. And you can do that like this. Create MCP. This is a function that use FastAPI. And with FastAPI, you only need to create the tools. So I'm going to have two

[13:14](https://www.youtube.com/watch?v=DrfyORO8RqA&t=794s) different tools. One is the start long job, and another one is check job status. And I did a lot of tests using this, uh, async handle, and the difference is a lot. For example, if you have also the different, um, for, uh, the... Well, the agent never stop to answer me. So because I wait, then it can retrieve the information. And to close this session, six minutes,

[13:45](https://www.youtube.com/watch?v=DrfyORO8RqA&t=825s) we have the antipatterns. So what are you have to avoid? You have to avoid context stuffing. So you need, you don't need to include everything and the kitchen. You know? You don't have to include everything in the context window because the agent doesn't need all the information there. You can only share what the agent need to create the answer that your user or you're asking for. You can have, uh, native summarization. Sometimes

[14:15](https://www.youtube.com/watch?v=DrfyORO8RqA&t=855s) when you do native summarization, the agent, uh, can, uh, you can, uh, forget what you need. If you are doing whatever summarization, what you might need for, probably in that summarization, you are not going to have everything that agent is needed to answer you. And context population. Again, don't pass everything to the agent. The agent doesn't need all that information. And what is a good thing here? So tool returns large data.

[14:45](https://www.youtube.com/watch?v=DrfyORO8RqA&t=885s) Logs, uh, database, a lot of information. Externalize, select, and use a memory pointer. Many agents need the same large data. You can share invocation between steps. And agent loops or tool hops. You can have clear steps. You know, give a clear answer for the tool. And limited tools counts. And async handle. Thank you.

[15:16](https://www.youtube.com/watch?v=DrfyORO8RqA&t=916s) And of course, if you want to learn more about Strands Agent, we have a huge booth there. We have a lot of swag. We have a little, uh, Legos for Amazon that you can have. And see you there. We have the specialist. And I am Elizabeth, no Morgan, remember.  Thank you so much.
