Habr AI→ original

Which code architectures suit AI agents best

AI agents write code, but they have constraints: limited memory and a limited context window. That means traditional architectures (TDD, OOP, MVC) work differen

Which code architectures suit AI agents best
Source: Habr AI. Collage: Hamidun News.
◐ Listen to article

AI-agents are writing code now, but they have limitations: memory and context window are much smaller than humans. This calls into question traditional code architecture approaches — approaches developed by humans for humans.

Why Architecture Suddenly Became More Important

When an agent writes code, it doesn't see the entire system. It needs to understand the task, find relevant files, understand how they're connected, make changes — all within a limited context window. Different architectures help (or hinder) this process differently. Some approaches contain information in compressed, structured form. Others are scattered across the system, requiring the agent to see a huge chunk of code and remember how everything is connected.

Which Architectures Work With Agents

Most useful for AI-agents:

  • TDD (test-driven development) — tests are a specification written in code. An agent can quickly understand what a function does by looking at tests.
  • Functional programming — functions are isolated from each other, don't require deep context about system state.
  • DDD (domain-driven design) — explicitly separates domains, each domain is almost independent.
  • Hexagonal architecture — clear boundaries between layers, adapters explicitly describe interaction.
  • CQRS (command query responsibility segregation) — commands and queries are explicitly separated, logic is clear.

Less useful or requiring caution:

  • OOP with inheritance — encapsulation is good, but deep class hierarchies require seeing the entire inheritance graph.
  • MVC/MVVM — structured, but controllers often contain logic that doesn't lie on the surface.
  • Microservices — good for separating responsibility, but the agent must remember how they interact.
  • Event-driven architecture — requires tracking global state and events scattered across the system.

Why Context Decides Everything

A human can hold an entire system's architecture in their head. An agent cannot. For an agent, only what lies in its context window right now matters. Architectures like TDD or DDD work because they place information in an obvious place. A test tells the agent what a function does. A domain boundary tells where one area of responsibility ends and another begins. Functions that don't depend on global state are easier to understand without context. Interfaces that explicitly describe how components interact save context window.

"In the age of agents, architecture is not about code beauty, but

about information compressibility into the context window".

In Practice

Projects that already use TDD or DDD get an advantage right now. Their code is easier for agents. Projects with blurred boundaries and implicit state require more effort and errors from the agent. This doesn't mean you need to rewrite all code. It means that when choosing between several ways to solve a problem, you should choose the architecturally clean option — because it will work with agents more effectively.

What This Means

Developers and architects can start choosing approaches not only because they're theoretically correct, but because they work with AI limitations. TDD and DDD are not just good practices — they become a competitive advantage in the world of AI programming.

ZK
Hamidun News
AI news without noise. Daily editorial selection from 400+ sources. A product by Zhemal Khamidun, Head of AI at Alpina Digital.
What do you think?
Loading comments…