AI Agent Architectures: Security, Environment, and Memory Challenges

Original Title: The Age of Async Agents — Cognition's Walden Yan & OpenInspect's Cole Murray

The Unseen Architectures of AI Agents: Beyond the Code, Towards Autonomous Factories

This conversation dives deep into the evolving landscape of AI agents, moving beyond the immediate utility of code generation to the complex infrastructure and strategic implications of building truly autonomous systems. It reveals the hidden consequences of architectural choices, particularly the tension between security and flexibility in agent execution environments and the long-term impact of how agents manage their "memory" and interactions. Those building or adopting AI agents, from individual developers to enterprise leaders, will gain a crucial advantage by understanding these downstream effects, enabling them to design more robust, secure, and scalable AI workflows that anticipate future challenges rather than merely solving present ones. The core insight is that the real value lies not just in the agent's intelligence, but in the sophisticated infrastructure that enables its reliable and secure operation, akin to building the factory that produces software, not just the software itself.

The Architecture of Autonomy: Harnessing the Agent's Power Safely

The shift from local, developer-in-the-loop AI tools to background and cloud-based agents signifies a fundamental change in how software development will be orchestrated. This transition, accelerated by significant model improvements around December 2025, has moved the focus from individual developer speed to the creation of "factories that create software." A critical, often overlooked, architectural decision is how to run these agents: "harness in the box" versus "out of the box."

Running an agent within the same sandbox environment where it executes tasks (harness in the box) offers simplicity and localized state management. However, it introduces significant security risks. As Walden Yan notes, "all of your secrets need to go into that box as well. And given the nature of AI, it can be unpredictable, and you could very easily end up accidentally exfiltrating your secrets, or other kind of unintended behavior." This direct coupling makes it difficult to enforce granular permissions, especially in enterprise settings where different users might interact with the same agent infrastructure but possess vastly different access levels.

The "out of the box" approach, where the agent's "brain" (the model and its logic) is separated from the execution environment (the sandbox), offers a more secure and flexible architecture. This separation, which Cognition adopted early on for Devin, allows for better control over permissions and secrets. "The other thing that this allows you to do is reuse any existing infrastructure you have for dev boxes perhaps," Walden explains. While this adds complexity, particularly in managing state between the brain and the hands (the sandbox), it provides a more robust foundation for enterprise adoption. This distinction is crucial: the immediate benefit of simplicity in a contained environment can lead to cascading security vulnerabilities and operational headaches down the line, whereas the upfront complexity of a separated architecture pays off in long-term manageability and security.

"The other thing that this allows you to do is reuse any existing infrastructure you have for dev boxes perhaps. So you don't have to worry as much about making a new type of dev box that has all the dependencies the brain needs, as you mentioned, the secrets the brain needs as well."

-- Walden Yan

The Perennial Problem of Repo Setup and Environment Consistency

A significant downstream consequence of adopting background agents is the challenge of maintaining consistent and functional development environments. As Cole Murray points out, "most teams don't really have great developer environment setups, if any." When agents need to interact with complex codebases, manage dependencies, and run applications, the "repo setup" becomes paramount. Simply providing an agent with access to a repository is insufficient if the environment it operates within is unstable, outdated, or lacks the necessary tools and credentials.

This problem is exacerbated by the nature of modern development. Many applications rely on Docker Compose for microservices, and attempting to run Docker within Docker for an agent's sandbox can lead to "really weird" configurations. The discussion highlights the necessity of using full Virtual Machines (VMs) for agents that need to run real applications and perform complex testing. Walden Yan elaborates on the infrastructure work Cognition undertook: "when we just built it off of raw VMs from cloud providers like EC2, the boot-up time was so slow... It would just be out cold for like 10 minutes because that’s just how long these systems took. They were not built for this repeated down and up usage."

The failure to adequately address environment setup and consistency has a direct impact on agent reliability. An agent that struggles to spin up a correct development environment, manage secrets, or execute tests will inevitably produce lower-quality output, leading to frustration and undermining the perceived value of the technology. This is where specialized infrastructure, like fast VM snapshotting and restoration, becomes a competitive advantage. Companies that invest in solving this "repo setup" problem create a smoother, more reliable experience for their agents, leading to higher success rates and faster iteration cycles -- a delayed payoff for upfront engineering effort.

"One thing I’ve not seen a lot of other players do well is how do you manage what’s actually on the box? And this can be complex for many reasons. Let’s say you have a big repository that’s changing and updating a lot with changing dependencies. How do you make sure that the working environment of the agent actually stays up to date, has all the credentials it needs to, let’s say, run the app and test it and all the things you want your autonomous agent to be able to set up?"

-- Walden Yan

The Unsolved Frontier of Agent Memory and Knowledge Management

While agent capabilities in executing tasks and generating code have advanced rapidly, the management of "memory" and "knowledge" remains a significant challenge. The aspiration is for agents to learn and adapt over time, retaining context and understanding user preferences. However, the practical implementation is fraught with difficulty. Cole Murray states plainly, "memory as a whole is a pretty unsolved problem, and it is why I’ve been hesitant to add it. I think there are parts of memory and that can be addressed, but I think as a whole, it’s a very difficult retrieval problem."

The core issue lies in both generating useful memories and retrieving them effectively. Auto-generated memories, where the agent prompts the user for approval to remember specific interactions or preferences, have proven more successful than expecting users to proactively document everything. However, this process is not without its own complexities. Walden Yan explains the delicate balance: "Generation, you don’t want it to remember something like, if you asked one time to like, ‘Oh, please open as a draft PR,’ you don’t want to be like, ‘Oh, everyone forever now should get their PRs as draft PRs.’ But you do want some conveyor. Maybe you want to say like, ‘Oh, Cole generally likes things to be created as draft PRs.’" Similarly, retrieving the correct memory from thousands of entries without overwhelming the agent's context window is a constant struggle.

The long-term consequence of poorly managed memory is an agent that fails to learn effectively, leading to repeated mistakes or an inability to adapt to evolving project needs. This can manifest as codebases that "regress to your worst engineer," as Cole Murray puts it, where AI-generated code starts adopting suboptimal patterns due to a lack of nuanced understanding or an inability to recall best practices. The companies that invest in solving memory pruning, temporal aspects of memory, and efficient retrieval mechanisms will unlock agents that become true long-term collaborators, rather than tools that need constant re-teaching.

"I think the other one we touched on earlier is kind of the harness in the box versus out of the box. I think long term, the architecture will eventually come back out of the box. Some of the newer tools that I've added are calling back into the control plane so that you don't have the secrets in the sandbox. And so I think long term, I probably will pull the actual agent out of the box. But I think for now, it's fine."

-- Cole Murray

Actionable Takeaways

  • Prioritize Secure Agent Architecture: When designing or selecting agent infrastructure, favor solutions that separate the agent's "brain" from its execution environment ("out of the box"). This upfront investment in security and separation will prevent downstream issues with permissions and secret management.
  • Invest in Robust Dev Environment Management: Recognize that consistent and reliable development environments are critical for agent success. Allocate resources to automate setup, dependency management, and credential provisioning for agent sandboxes. This is a foundational requirement for reliable agent operation.
  • Develop a Strategy for Agent Memory: Acknowledge that memory and knowledge management are still evolving. Begin experimenting with auto-generated memories and skills, but be prepared to invest in robust retrieval and pruning mechanisms to prevent context dilution and ensure agents learn effectively over time.
  • Embrace VM-Based Execution for Complex Tasks: For agents requiring the execution of full applications or intricate testing, prioritize VM-based environments over container-only solutions. This provides a more accurate simulation of production environments and avoids complexities like Docker-in-Docker.
  • Integrate Agents Deeply into Workflows: Move beyond simple tool calls. Focus on integrating agents into existing workflows like Slack, GitHub, and SRE monitoring tools. This requires building first-party integrations where standard MCPs fall short, ensuring agents operate as natural collaborators within the team's ecosystem.
  • Prepare Codebases for AI Collaboration: Actively work to make codebases more testable locally. This includes setting up local databases, mock servers, and reducing reliance on direct integration with live services. This effort, while challenging for older codebases, is essential for enabling agents to perform end-to-end testing and development autonomously.
  • Establish AI Code Review Standards: Implement linting rules and automated checks (e.g., Semgrep) to guard against common AI coding "slop" patterns like excessive getattr calls, untyped tuples, or problematic backward compatibility shims. This proactive measure prevents code quality degradation over time.

---
Handpicked links, AI-assisted summaries. Human judgment, machine efficiency.
This content is a personally curated review and synopsis derived from the original podcast episode.