Amazon Bedrock AgentCore uses RLM to break context window limits
RLM decouples document size from context window via iterative code execution.
Traditional LLMs fail when documents exceed the context window — inputs are rejected or the model misses middle sections. Recursive Language Models (RLM) flip this paradigm: treat the document as an external environment. A root LLM receives only the query and an environment description, then writes code to search, slice, and process the document iteratively. For semantic understanding of specific sections, it delegates to sub-LLM calls, keeping intermediate results as Python variables in working memory rather than consuming context space. This recursive structure allows analysis of millions of characters without ever hitting a hard limit.
Amazon Bedrock AgentCore Code Interpreter provides the ideal execution environment. It offers a sandboxed Python runtime with persistent state across multiple code executions. The full document is loaded as a Python variable once, and a custom llm_query() function within the sandbox calls Amazon Bedrock directly to perform sub-LLM analysis. The root LLM agent (built with Strands Agents SDK) orchestrates the process by writing code that searches, slices, and calls sub-LLMs as needed. Public network mode allows outbound API calls to Bedrock. This architecture keeps the root LLM's context window focused on orchestration while document data and intermediate results remain in Python variables, enabling analysis of financial reports, legal documents, or research papers of any length.
- Root LLM writes Python code to explore document iteratively, avoiding context window overflow.
- Sub-LLMs analyze specific sections via Amazon Bedrock calls; results stored as Python variables for persistent working memory.
- Amazon Bedrock AgentCore Code Interpreter provides a sandboxed Python runtime with persistent state and public network access.
Why It Matters
Enables analysis of any document length without data loss or truncation, solving a core LLM limitation.